forked from valderman/haste-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.sh
executable file
·73 lines (59 loc) · 1.93 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
#!/bin/bash
hastec=hastec
if [[ $JS == "" ]] ; then
if [[ $(which nodejs) != "" ]] ; then
JS=nodejs
else
JS=node
fi
fi
runTest() {
module=$1
quiet=$2
echo "Running test $module..."
ghc_output=`runghc -DTEST_MODULE=$module TestDriver.hs`
if [[ $quiet == 1 ]] ; then
$hastec --start=asap -O0 -DTEST_MODULE=$module TestDriver.hs --out=TestDriver.tmp > /dev/null 2>&1
else
$hastec -O0 --verbose --debug --start=asap -DTEST_MODULE=$module TestDriver.hs --out=TestDriver.tmp
fi
echo "if(typeof print == 'undefined') {print = console.log}" > TestDriver.js
cat TestDriver.tmp >> TestDriver.js
haste_output=`$JS TestDriver.js`
if [[ $quiet == 1 ]] ; then
$hastec -O2 --start=asap -DO2 -DTEST_MODULE=$module TestDriver.hs --out=TestDriver.tmp > /dev/null 2>&1
else
$hastec -O2 --verbose --debug --start=asap -DO2 -DTEST_MODULE=$module --out=TestDriver.tmp TestDriver.hs
fi
echo "if(typeof print == 'undefined') {print = console.log}" > TestDriver.O2.js
cat TestDriver.tmp >> TestDriver.O2.js
haste_opt_output=`$JS TestDriver.O2.js`
if [[ "$ghc_output" != "$haste_output" ]] ; then
thistest="failed"
echo " GHC disagrees with hastec output!"
echo " GHC says '$ghc_output', but hastec says '$haste_output'"
fi
if [[ "$ghc_output" != "$haste_opt_output" ]] ; then
thistest="failed"
echo " GHC disagrees with hastec -O2 output!"
echo " GHC says '$ghc_output', but hastec says '$haste_opt_output'"
fi
}
if [[ "$1" != "" ]] ; then
runTest $1 0
exit 0
fi
let failed=0
let tests=0
for file in Tests/*.hs; do
let tests=$tests+1
thistest="success"
module=`echo $file | sed -e s/Tests\\\/// | sed -e s/\.hs//`
runTest $module 1
if [[ $thistest == "failed" ]] ; then
let failed=$failed+1
fi
done
echo
let success=$tests-$failed
echo "$success/$tests succeeded"