-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
runtests.sh
executable file
·122 lines (113 loc) · 2.63 KB
/
runtests.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
#!/bin/sh
# usage: test/runtests.sh [testfile]
# cmd="valgrind ./potion" test/runtests.sh
cmd=${cmd:-bin/potion-s}
ECHO=/bin/echo
SED=sed
EXPR=expr
count=0; failed=0; pass=0
EXT=pn
cmdi="$cmd -I"; cmdx="$cmdi -X"
cmdc="$cmd -c"; extc=b
if test -z $1; then
${ECHO} running potion API tests
bin/potion-test
${ECHO} running p2 API tests
bin/p2-test
${ECHO} running GC tests
bin/gc-test
fi
while [ $pass -lt 6 ]; do
${ECHO};
if [ $pass -eq 0 ]; then
t=0;
whattests="$cmd VM tests"
elif [ $pass -eq 1 ]; then
t=1;
whattests="$cmd compiler tests"
elif [ $pass -eq 2 ]; then
t=2;
whattests="$cmd JIT tests"
jit=`$cmd -v | sed "/jit=1/!d"`;
if [ "$jit" = "" ]; then
pass=`expr $pass + 1`
cmd=bin/p2; t=0; EXT=pl
cmdi="$cmd --inspect"; cmdx="$cmdi -J";
cmdc="$cmd --compile"; extc=c
whattests="$cmd VM tests"
fi;
elif [ $pass -eq 3 ]; then
cmd=bin/p2; t=0; EXT=pl
cmdi="$cmd --inspect"; cmdx="$cmdi -J";
cmdc="$cmd --compile"; extc=c
whattests="$cmd VM tests"
elif [ $pass -eq 4 ]; then
t=1;
whattests="$cmd compiler tests"
elif [ $pass -eq 5 ]; then
t=2;
whattests="$cmd JIT tests"
jit=`$cmd -v | sed "/jit=1/!d"`
if [ "$jit" = "" ]; then
pass=`expr $pass + 1`
break
fi
fi
if test -n "$1" && test -f "$1"; then
what=$1
if [ ${what%.pl} = $what -a $EXT = pl -a $pass -ge 3 ]; then
${ECHO} skipping p2
pass=6
break
fi
if [ ${what%.pn} = $what -a $EXT = pn -a $pass -le 3 ]; then
${ECHO} skipping potion
pass=3
cmd=bin/p2; t=0; EXT=pl
cmdi="$cmd --inspect"; cmdx="$cmdi -J";
cmdc="$cmd --compile"; extc=c
whattests="$cmd VM tests"
fi
else
what=test/**/*.$EXT
fi
${ECHO} running $whattests
for f in $what; do
look=`cat $f | sed "/\#=>/!d; s/.*\#=> //"`
#echo look=$look
if [ $t -eq 0 ]; then
echo $cmdi -B $f
for=`$cmdi -B $f | sed "s/\n$//"`
elif [ $t -eq 1 ]; then
echo $cmdc $f
$cmdc $f > /dev/null
fb=$f$extc
echo $cmdi -B $fb
for=`$cmdi -B $fb | sed "s/\n$//"`
rm -rf $fb
else
echo $cmdx $f
for=`$cmdx $f | sed "s/\n$//"`
fi;
if [ "$look" != "$for" ]; then
${ECHO}
${ECHO} "** $f: expected <$look>, but got <$for>"
failed=`expr $failed + 1`
else
# ${ECHO} -n .
jit=`$cmd -v | ${SED} "/jit=1/!d"`
if [ "$jit" = "" ]; then
${ECHO} "* skipping"
break
fi
fi
count=`expr $count + 1`
done
pass=`expr $pass + 1`
done
${ECHO}
if [ $failed -gt 0 ]; then
${ECHO} "$failed FAILS ($count tests)"
else
${ECHO} "OK ($count tests)"
fi