-
Notifications
You must be signed in to change notification settings - Fork 6
/
runtests.sh
executable file
·65 lines (63 loc) · 1.29 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
#!/bin/sh
# set -v
# set -x
dir=$(pwd)
pre_c='build'
if [ "x$1" != "x" ]; then
pre_c=$1
fi
failing=()
j=1
useless_input="test
";
cd $dir
for i in $(find tests -maxdepth 1 -name 'test*.ctr' | sort --version-sort); do
fexpect="${i%%.ctr}.exp"
fcrash="${i%%.ctr}.crash"
crash=false
if [ ! -f $fexpect ]; then
if [ ! -f $fcrash ]; then
echo "No expect file, skipping $i"
continue
fi
crash=true
fi
fitem=$i
echo -n "$fitem interpret";
result=`echo "$useless_input" | timeout 15 ${pre_c}/ctr --compact ${fitem}`
rv=$?
if [ $rv -ne 0 ] && [ $rv -ne 1 ]; then
if ! $crash; then
echo " [Failed with result $rv]"
failing+=($fitem)
continue
fi
result=''
elif $crash; then
echo " [Failed, expected crash]"
failing+=($fitem)
continue
fi
expected=`cat $fexpect`
if [ "$result" = "$expected" ]; then
echo " [$j]"
j=$((j+1))
else
echo "FAIL."
echo "EXPECTED:"
echo $expected
echo ""
echo "BUT GOT:"
echo $result
failing+=("$fitem");
# sleep 0.5 && echo ""
fi
headline=$(head -n 1 $fitem)
# sleep 0.2 && clear
done
echo ""
if [ ${#failing[@]} -gt 10 ]; then
echo Tests failing: ${failing[@]}
exit 1
fi
exit 0