3 # This script runs the regression tests in src/regression.
4 # It also compiles the tests in benchmark/tests
11 echo >&2 "usage: $name [-fail] [-short] [-test-reg reg] [mlton flags ...]"
22 flags
[${#flags[@]}]="-type-check"
23 flags
[${#flags[@]}]="true"
24 while [ "$#" -gt 0 ]; do
40 testRegs
[${#testRegs[@]}]="$1"
44 flags
[${#flags[@]}]="$1"
52 src
=`cd "$dir/.." && pwd`
54 lib
="$src/build/lib/mlton"
56 cont
='callcc.sml callcc2.sml callcc3.sml once.sml'
57 flatArray
='finalize.sml flat-array.sml flat-array.2.sml'
58 intInf
='conv.sml conv2.sml fixed-integer.sml harmonic.sml int-inf.*.sml slow.sml slower.sml smith-normal-form.sml'
59 signal
='finalize.sml signals.sml signals2.sml signals3.sml signals4.sml suspend.sml weak.sml'
60 thread
='thread0.sml thread1.sml thread2.sml mutex.sml prodcons.sml same-fringe.sml timeout.sml'
61 world
='world1.sml world2.sml world3.sml world4.sml world5.sml world6.sml'
62 tmp
=/tmp
/z.regression.$$
65 # whitelist tests that are known to fail (will still run but exit cleanly)
66 declare -A whitelisted
67 if [ -a $src/regression
/whitelist
] ; then
69 echo "whitelisting $f..."
71 done <$src/regression
/whitelist
76 if [[ ${whitelisted["$f"]} ]] ; then
83 eval `"$src/bin/platform"`
86 echo "compilation of $f failed with ${flags[*]}"
89 "$mlton" -verbose 1 ||
(echo 'no mlton present' && exitFail
=true
)
90 echo "flags = ${flags[*]}"
95 for f
in fail
/*.sml
; do
97 ( "$mlton" "${flags[@]}" -stop tc
"$f" >/dev
/null
2>&1 &&
98 echo "compilation of $f should have failed but did not" && ignore
=$
(isWhitelisted
$f) && if [ "$ignore" -eq 0 ] ; then exitFail
=true
; fi ) ||
102 if [ "$exitFail" = true
] ; then
110 if [ $HOST_OS = mingw
]; then
115 f
=`basename "$f" .sml`
118 for (( i
= 0 ; $i < ${#testRegs[@]} ; i
++ )); do
119 if [ "$f" = "${testRegs[$i]}" ]; then
136 # Work-around hurd bug (http://bugs.debian.org/551470)
138 mutex|prodcons|signals|signals2|signals3|signals4|
suspend|thread2|timeout|world5
)
145 cmdline|command-line|
echo|filesys|posix-exit|signals|signals2|signals3|signals4|socket|
suspend|textio
.2|unixpath|world
*)
160 extraFlags
[${#extraFlags[@]}]="-const"
161 extraFlags
[${#extraFlags[@]}]="Exn.keepHistory true"
166 echo "\$(SML_LIB)/basis/basis.mlb
167 \$(SML_LIB)/basis/mlton.mlb
168 \$(SML_LIB)/basis/sml-nj.mlb
171 \"allowOverload true\"
172 \"allowExtendedTextConsts true\"
173 \"nonexhaustiveBind ignore\"
174 \"nonexhaustiveMatch ignore\"
175 \"redundantBind ignore\"
176 \"redundantMatch ignore\"
179 "$mlton" "${flags[@]}" "${extraFlags[@]}" -output "$f" "$mlb"
180 if [ "$?" -ne '0' ] ||
[ ! -x "$f" ]; then
186 if [ ! -r "$f".nonterm
-a -x "$f" ]; then
187 nonZeroMsg
='Nonzero exit status.'
189 nonZeroMsg
="$nonZeroMsg"'\r'
191 ( "./$f" ||
echo -e "$nonZeroMsg" ) >$tmp 2>&1
192 if [ -r "$f.ok" ]; then
193 compare
="$f.$HOST_ARCH-$HOST_OS.ok"
194 if [ ! -r $compare ]; then
198 newcompare
="$f.sed.ok"
199 sed $
's/$/\r/' <"$compare" > "$newcompare"
200 compare
="$newcompare"
202 if ! diff "$compare" "$tmp"; then
203 echo "$f: difference with ${flags[*]} ${extraFlags[*]}"
204 ignore
=$
(isWhitelisted
$f)
205 if [ "$ignore" -eq 0 ] ; then
213 if $short ||
$testReg ; then
214 if [ "$exitFail" = true
] ; then
221 "$src/bin/mmake" clean
>/dev
/null
222 cd "$src/benchmark/tests"
224 f
=`basename "$f" .sml`
232 echo "val _ = Main.doit 0" |
cat "$f.sml" - > "$tmpf.sml"
233 $mlton -output "$tmpf" "${flags[@]}" \
234 -default-ann 'nonexhaustiveBind ignore'\
235 -default-ann 'nonexhaustiveMatch ignore'\
236 -default-ann 'redundantBind ignore' \
237 -default-ann 'redundantMatch ignore' \
239 if [ $?
-ne 0 ]; then
243 rm -f "$tmpf" "$tmpf.sml"
247 "$src/bin/mmake" clean
>/dev
/null
249 for f
in mllex mlyacc mlprof
; do
253 "$src/bin/mmake" -W "$f" >/dev
/null
254 "$mlton" "${flags[@]}" -output "$tmpf" "$f.mlb"
255 if [ $?
-ne 0 ]; then
264 if [ "$exitFail" = true
] ; then