-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·173 lines (162 loc) · 5.3 KB
/
test.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
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh
FILES="
doc/Tamsin.markdown
doc/System_Module.markdown
doc/Tested_Examples.markdown
"
GLOB="eg/*.tamsin lib/*.tamsin mains/*.tamsin"
mkdir -p tmp
if [ x$1 = 'x-f' ]; then
shift
echo "(Testing on Falderal files '$1' only)"
FILES=$1
shift
fi
MODE=compiled
if [ x$1 = xcompiled -o x$1 = xinterpreted ]; then
MODE=$1
shift
fi
if [ x$1 = x ]; then
$0 interpreter &&
$0 compiler &&
$0 tcompiler &&
$0 bootstrap &&
echo "All tests passed!"
exit $?
fi
if [ x$1 = xtamsin ]; then
echo "Testing things written in Tamsin only."
$0 compiled scanner &&
$0 compiled grammar &&
$0 compiled parser &&
$0 compiled desugarer &&
$0 compiled analyzer &&
$0 micro &&
$0 tcompiler &&
echo "All tests passed!"
exit $?
fi
if [ x$1 = xthorough ]; then
echo "Testing EVERYTHING. This will take more than 8 minutes. (On a FAST machine.)"
$0 interpreter &&
$0 compiler &&
$0 interpreted scanner &&
$0 interpreted grammar &&
$0 interpreted parser &&
$0 interpreted desugarer &&
$0 interpreted analyzer &&
$0 compiled scanner &&
$0 compiled grammar &&
$0 compiled parser &&
$0 compiled desugarer &&
$0 compiled analyzer &&
$0 micro &&
$0 tcompiler &&
$0 bootstrap &&
echo "All tests passed!"
exit $?
fi
ok() {
echo 'ok'
}
test_it() {
MODE=$1
SRC=$2
LIBS=$3
CMD=$4
BIN=$5
if [ x$BIN = x ]; then
BIN=foo
fi
if [ $MODE = "compiled" ]; then
make c_src/libtamsin.a || exit 1
echo "*** Compiling $SRC (with $LIBS)"
echo "*** and testing it against '$CMD'..."
bin/tamsin compile $LIBS $SRC > tmp/foo.c && \
gcc -g -Ic_src -Lc_src tmp/foo.c -o $BIN -ltamsin || exit 1
for EG in $GLOB; do
echo $EG
$CMD $EG | bin/wrap > tmp/python-cmd.txt
$BIN <$EG | bin/wrap > tmp/tamsin-cmd.txt
diff -ru tmp/python-cmd.txt tmp/tamsin-cmd.txt > tmp/output.diff
diff -ru tmp/python-cmd.txt tmp/tamsin-cmd.txt || exit 1
done
elif [ $MODE = "interpreted" ]; then
echo "*** Interpreting $SRC (with $LIBS)"
echo "*** and testing it against '$CMD'..."
for EG in $GLOB; do
echo $EG
$CMD $EG | bin/wrap > tmp/python-cmd.txt
bin/tamsin $LIBS $SRC <$EG | bin/wrap > tmp/tamsin-cmd.txt
diff -ru tmp/python-cmd.txt tmp/tamsin-cmd.txt > tmp/output.diff
diff -ru tmp/python-cmd.txt tmp/tamsin-cmd.txt || exit 1
done
echo "Passed."
exit 0
else
echo "BAD MODE"
exit 1
fi
echo "Passed."
exit 0
}
if [ x$1 = xinterpreter -o x$1 = xi ]; then
echo "*** Testing Python interpreter..."
falderal $VERBOSE --substring-error fixture/tamsin.py.markdown $FILES
elif [ x$1 = xerror-reporting ]; then
echo "*** Testing error reporting in Python interpreter..."
falderal $VERBOSE --substring-error fixture/tamsin.py.markdown doc/Error_Reporting.markdown
elif [ x$1 = xcompiler ]; then
make c_src/libtamsin.a || exit 1
echo "*** Testing compiler..."
falderal $VERBOSE --substring-error fixture/compiler.py.markdown $FILES
elif [ x$1 = xgrammar ]; then
test_it $MODE "mains/grammar.tamsin" \
"lib/tamsin_scanner.tamsin" \
"ok" \
"bin/tamsin-grammar"
elif [ x$1 = xscanner ]; then
test_it $MODE "mains/scanner.tamsin" \
"lib/tamsin_scanner.tamsin" \
"./bin/tamsin scan" \
"bin/tamsin-scanner"
elif [ x$1 = xparser ]; then
test_it $MODE "mains/parser.tamsin" \
"lib/list.tamsin lib/tamsin_scanner.tamsin lib/tamsin_parser.tamsin" \
"./bin/tamsin parse" \
"bin/tamsin-parser"
elif [ x$1 = xdesugarer ]; then
test_it $MODE "mains/desugarer.tamsin" \
"lib/list.tamsin lib/tamsin_scanner.tamsin lib/tamsin_parser.tamsin lib/tamsin_analyzer.tamsin" \
"./bin/tamsin desugar" \
"bin/tamsin-desugarer"
elif [ x$1 = xanalyzer ]; then
# libs and mains need libs
GLOB="eg/*.tamsin"
test_it $MODE "mains/analyzer.tamsin" \
"lib/list.tamsin lib/tamsin_scanner.tamsin lib/tamsin_parser.tamsin lib/tamsin_analyzer.tamsin" \
"./bin/tamsin analyze" \
"bin/tamsin-analyzer"
elif [ x$1 = xtcompiler ]; then
make bin/tamsin-compiler || exit 1
echo "*** Testing Tamsin-in-Tamsin compiler..."
falderal $VERBOSE --substring-error fixture/compiler.tamsin.markdown $FILES
elif [ x$1 = xbootstrap ]; then
make bin/bootstrapped-compiler || exit 1
echo "*** Testing Bootstrapped Tamsin-in-Tamsin compiler..."
falderal $VERBOSE --substring-error fixture/bootstrapped.markdown $FILES
elif [ x$1 = xmicro ]; then
make bin/micro-tamsin || exit 1
echo "*** Testing Micro-Tamsin interpreter..."
FILES="doc/Micro-Tamsin.markdown"
falderal $VERBOSE --substring-error fixture/micro-tamsin.markdown $FILES
elif [ x$1 = xmini ]; then
make bin/mini-tamsin || exit 1
echo "*** Testing Mini-Tamsin interpreter..."
FILES="doc/Micro-Tamsin.markdown" # note: does not use Mini-Tamsin.md yet
falderal $VERBOSE --substring-error fixture/mini-tamsin.markdown $FILES
else
echo "Unknown test '$1'."
exit 1
fi