-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_all.sh
executable file
·64 lines (64 loc) · 1.49 KB
/
run_all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
USAGE="./run_all.sh [-d <dataset (bugsinpy/defects4j)>] [-s <save dir>] [-f <save file suffix>] [-m diffs/lines] <projects file>"
dataset="bugsinpy"
savefile="backtrack_2"
mode="diffs"
while getopts ":hd:s:f:m:" opt; do
case ${opt} in
d )
dataset="$OPTARG"
;;
s )
savedir="$OPTARG"
;;
f )
savefile="$OPTARG"
;;
m )
mode="$OPTARG"
;;
h )
echo "$USAGE"
exit 0
;;
\? )
echo "$USAGE"
exit 0
;;
esac
done
shift $((OPTIND -1))
if [ ! "$savedir" ]; then
savedir="$dataset"
fi
projects_file="$1"
projects_file="$(readlink -f "$(echo ${projects_file/"~"/~})")"
if [ $# -lt 1 ] || [ ! -f "$projects_file" ]; then
echo "$USAGE"
echo "Please provide a valid projects file"
exit 0
fi
if [ "$dataset" == "defects4j" ]; then
file_type=".java"
elif [ "$dataset" == "bugsinpy" ]; then
file_type=".py"
else
echo "ERROR: unknown dataset: $dataset"
exit 1
fi
for project in $(cat "$projects_file"); do
echo "$project"
all_shas="projects/$project/all_shas"
diffs="projects/$project/diffs"
bug_shas="$savedir/${project}_shas.csv"
out="$savedir/${project}_$savefile.json"
if [ "$mode" == "lines" ]; then
shas="$savedir/${project}.csv"
elif [ "$mode" == "diffs" ]; then
shas="$savedir/${project}_shas.csv"
else
echo "ERROR: unknown mode: $mode"
exit 1
fi
java -jar backtrack.jar --file-type $file_type $(< $savedir/${project}_src.txt) $mode $all_shas $diffs $shas > $out
done