-
Notifications
You must be signed in to change notification settings - Fork 3
/
Test.bash
69 lines (54 loc) · 1.47 KB
/
Test.bash
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
#!/bin/bash
# Rebuild 'Main' in case it has been changed...
ghc Main.hs -o Main.exe
if [ $? -eq 0 ]; then
echo Main.exe Rebuilt
else
echo Main.exe Failed
exit
fi
# All files should be in the 'Tests' directory
cd Unit
# Search all directories
for d in */; do
cd $d
echo "cd $d"
# We only search for files with the 'java' extension
# Note that currently we can only run Java 7 '.class'
# files, so we must cross-compile it...
for f in *.java; do
filename=$(basename "${f%.*}")
# Skip
if [ -f "$filename.skip" ]; then
echo "Skipping $filename"
continue
fi
bootstrap=$(java -verbose 2>/dev/null | sed -ne '1 s/\[Opened \(.*\)\]/\1/p')
echo "bootstrap: $bootstrap, file: $f"
javac -target 1.7 -source 1.7 -bootclasspath $bootstrap $f
../../Main.exe -cp ../../rt:./ "$filename" 1> tmp.out 2> tmp.err
# Check if program completed successfully...
if [ $? -eq 0 ]; then
# Check output differences
diff tmp.out "$filename.good" > "$filename.diff"
diffLen="$(wc -c $filename.diff | awk '{print $1}')"
# Output differences if incorrect...
if [ $diffLen -eq 0 ]; then
echo "[$filename]: SUCCESS"
else
echo "[$filename]: OUTPUT-DIFF"
cat "$filename.diff"
fi
rm "$filename.diff"
else
echo "[$filename]: RUNTIME ERROR"
cat tmp.err
fi
# Cleanup temporaries
rm "$filename.class"
rm tmp.out
rm tmp.err
done
cd ../
done
cd ../