-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests.sh
executable file
·72 lines (63 loc) · 1.56 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
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
#
# test suite for noct
#
gen=.gen
test=test
expect=$test/expect
err=$gen/err.txt
# force a 4-second limit on retro's runtime during the tests
# (because if we generate invalid syntax, it can mess retro up,
# and retro will sit around waiting for more input )
timelimit="timelimit -t2 -T2"
# choose a language backend to test
case "$1" in
haxe) ext=hx ;;
retro) ext=rx ;;
#java) ext=java ;;
#pascal) ext=pas ;;
#oberon) ext=mod ;;
*)
echo "usage: $0 BACKEND"
echo
echo "Available Backends:"
echo
echo " haxe retro"
#echo " oberon pascal"
#echo " java javascript"
echo
exit 1
;;
esac
# reset 'expected' directory to whatever's checked into git:
rm -f $expect/*
git checkout -- $expect
rm -rf $err
# run the test suite
for f in $test/given/*.mod ; do
# strip the path and extension:
name=${f/$test\/given\//}
name=${name/\.mod/}
# let make figure out how to compile it
echo make $gen/$name.$ext
echo -e "\e[33m" # brown
make $gen/$name.$ext | tail -n +2 || exit -1
# now invoke it:
clear
echo -e "\e[36m" # cyan
case $1 in
haxe) haxe -cp $gen -cp targets/haxe/neko -x $name
mv -f $name.n $gen
;;
retro) $timelimit retro --with $gen/$name.rx
;;
*) echo "sorry, don't know how to run $1 yet."
;;
esac
echo -e "\e[0m" # normal
echo "[ end of $name.$ext source was: ]"
echo -e "\e[33m" # brown
cat $gen/$name.$ext
echo -e "\e[0m" # normal
echo '[ press enter to continue, ^C to terminate ]' ; read
done