This repository has been archived by the owner on Jan 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-runner.sh
executable file
·162 lines (137 loc) · 3.18 KB
/
test-runner.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
cd $(dirname $0)
[ -d grift-suite ] && [ -d migeed ] || {
printf "Couldn't find test suite directories. Run $0 from the 'hm-in-smt' root or with a relative path.\n"
exit 3
}
usage() {
printf "Usage: $(basename $0) [-q] TOOL SUITE [--print-types]\n\n"
printf " TOOL 'migeed', 'ins-and-outs', 'smt', 'no-context', or 'grift'\n"
printf " SUITE 'grift', 'migeed', or 'adversarial'\n"
printf " -q quiet mode\n"
printf " --print-types show inferred types\n"
exit 4
}
if [ $# -eq 0 ]
then
usage
fi
QUIET=
if [ "$1" = "-q" ]
then
QUIET="-q"
shift
fi
tool="$1"
case $tool in
(migeed|ins-and-outs|smt|no-context|grift) ;;
(*) usage;;
esac
STACK_YAML="../../Maximal-Migration/stack.yaml" stack ghc Migrate.hs -- -o /tmp/migeed >/dev/null 2>/dev/null
shift
if [ "$1" = "grift" ]; then
: ${SUITE_DIR="grift-suite"}
: ${EXT="*.grift"}
elif [ "$1" = "migeed" ]; then
: ${SUITE_DIR="migeed"}
: ${EXT="*.gtlc"}
elif [ "$1" = "adversarial" ]; then
: ${SUITE_DIR="adversarial"}
: ${EXT="*.gtlc"}
else
usage
fi
shift
if [ "$1" = "--print-types" ]; then
: ${PRINT_TYPES=1}
echo "PRINTING TYPES"
shift
fi
total=0
failures=0
last_group=""
if [ "$*" ]
then
PAT="$1"
shift
for kw in "$@"
do
PAT="$PAT\|$kw"
done
files=$(find "$SUITE_DIR" -name "$EXT" | grep -e "$PAT")
else
files=$(find "$SUITE_DIR" -name "$EXT")
fi
first_header=1
needs_header=
header() {
if ! [ "$first_header" ]
then
printf "\n"
fi
first_header=
printf "\033[1m$test_group\033[0m\n"
printf "====================================\n"
}
for test_file in $files
do
test_name=$(basename $test_file)
test_name=${test_name%.grift}
test_group=$(dirname $test_file)
test_group=${test_group#./}
if ! [ "$test_group" = "$last_group" ]
then
last_group=$test_group
if [ "$QUIET" ]
then
needs_header=1
else
header
fi
fi
if ! [ "$QUIET" ]
then
printf "%27s..." "$test_name"
fi
OUT="$(dirname $test_file)/$test_name.out"
ERR="$(dirname $test_file)/$test_name.err"
timeout 5 ./run_tool.sh $tool $test_file >$OUT 2>$ERR
status=$?
: $((total += 1))
if [ $status -eq 0 ]
then
rm $ERR
if ! [ "$QUIET" ]
then
printf "....\033[32mOK\033[0m"
fi
else
: $((failures += 1))
if [ "$QUIET" ]
then
if [ "$needs_header" ]
then
header
needs_header=
fi
printf "%27s..." "$test_name"
fi
printf "\033[31mFAILED\033[0m"
fi
if [ "$PRINT_TYPES" ] && [ $status -eq 0 ]; then
printf " "
tail -n 1 $OUT
else
printf "\n"
fi
done
printf "====================================\n"
printf "\033[1m%d\033[0m/\033[1m%d\033[0m passed" \
$((total - failures)) $total
if [ $failures -eq 0 ]
then
printf " (\033[32mPASSED\033[0m)\n"
else
printf " (\033[31m%d\033[0m failures)\n" $failures
fi
[ $failures -eq 0 ]