-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests
executable file
·97 lines (84 loc) · 2.31 KB
/
run_tests
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
#!/bin/bash
# Tests all files in ./tests/ and output whether we accept it or not
# Extra arguments are passed to our compiler (such as --plain for less colors)
mkdir -p build
ghc Main.hs -outputdir build/ -o build/splang -O || exit 1
rm -f run_tests.log
echo "Parsing tests"
for f in ./tests/parser/*.spl
do
echo "*** Parsing $f" >> run_tests.log
./build/splang --parse-only "$@" $f >> run_tests.log
if [ $? -ne 0 ]; then
echo -e "\033[31m$f failed parsing\033[0m"
else
echo -e "\033[32m$f succeeded parsing\033[0m"
fi
done
echo "Scoping tests"
for f in ./tests/scoping/*.spl
do
echo "*** Scoping $f" >> run_tests.log
./build/splang --scope-only "$@" $f >> run_tests.log
if [ $? -ne 0 ]; then
echo -e "\033[31m$f failed compiling\033[0m"
else
echo -e "\033[32m$f succeeded compiling\033[0m"
fi
done
echo "Typing tests"
for f in ./tests/typing/*.spl
do
echo "*** Type checking $f" >> run_tests.log
./build/splang "$@" $f >> run_tests.log
if [ $? -ne 0 ]; then
echo -e "\033[31m$f failed compiling\033[0m"
else
echo -e "\033[32m$f succeeded compiling\033[0m"
fi
done
echo "See run_tests.log for the details"
ssmmachine="../ssm-nogui/build/ssm-nogui.jar"
echo "Codegen tests for SSM"
for f in ./tests/codegen/*.spl
do
echo "*** Codegen $f" >> run_tests.log
./build/splang $f > code.ssm
if [ $? -ne 0 ]; then
echo -e "\033[31m$f failed to generate code\033[0m"
else
echo -e "\033[32m$f succeeded generating code\033[0m"
if [ -e $f.output ]; then
cat $f.output > output_check.txt
java -jar $ssmmachine code.ssm > output_ssm.txt
diff output_check.txt output_ssm.txt
if [ $? -ne 0 ]; then
echo -e "\033[31m -> see diff above\033[0m"
else
echo -e "\033[32m -> no diff :)\033[0m"
fi
fi
fi
done
echo "Codegen tests for LLVM"
for f in ./tests/codegen/*.spl
do
echo "*** Codegen $f" >> run_tests.log
./build/splang $f --target=llvm > code.ll
if [ $? -ne 0 ]; then
echo -e "\033[31m$f failed to generate code\033[0m"
else
echo -e "\033[32m$f succeeded generating code\033[0m"
if [ -e $f.output ]; then
cat $f.output > output_check.txt
lli code.ll > output_ll.txt
diff output_check.txt output_ll.txt
if [ $? -ne 0 ]; then
echo -e "\033[31m -> see diff above\033[0m"
else
echo -e "\033[32m -> no diff :)\033[0m"
fi
fi
fi
done
echo "See run_tests.log for the details"