-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_tests.sh
executable file
·59 lines (51 loc) · 1.07 KB
/
run_tests.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
#!/bin/sh
if [ "$*" = "" ]
then
echo Tests not run, missing required arguments
echo usage: $0 [command_to_run_your_interpreter]
exit 1
fi
if ! hash ${1%% *} 2>/dev/null
then
echo Tests not run, could not find command "${1%% *}"
exit 1
fi
tests="**/*.code"
diff_options="-u"
if diff --color=always empty.data empty.data 2>/dev/null
then
diff_options="-u --color=always"
fi
for t in $tests
do
t=${t%\.code}
code=$t.code
data=$t.data
expected=$t.expected
if [ ! -f $data ]
then
data=empty.data
fi
printf "Testing %s... " "$t"
if [ $t != "${t%bad*}" ]
then
output=$($* $code $data)
if [ "$output" != "${output%ERROR:*}" ]
then
printf "\033[0;32mPASSED\033[0m\n"
else
printf "\033[0;31mFAILED\033[0m\n"
printf "\033[1mexpected error, got following output:\033[0m\n"
echo "$output"
fi
else
output=$($* $code $data | diff $diff_options - $expected)
if [ $? -eq 0 ]
then
printf "\033[0;32mPASSED\033[0m\n"
else
printf "\033[0;31mFAILED\033[0m\n"
echo "$output"
fi
fi
done