-
Notifications
You must be signed in to change notification settings - Fork 1
/
verify_single.sh
executable file
·49 lines (44 loc) · 1.5 KB
/
verify_single.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
#!/bin/bash
if [[ -n "$REBUILD" ]]; then
echo -e "\033[1;31mWARNING: option REBUILD is set, will overwrite differing files\033[0m"
fi
export AUDOSCORE_SECURITY_TOKEN="2c976d0b02898e9eb05155806bb65973";
( ./run_test.sh ) > /dev/null 2> /dev/null
error=0
for i in `find expected/ -type f`; do
testfile=${i/expected/test.latest}
if [[ -r "$testfile" ]]; then
sed -i -e 's/Exception(test timed out after \([^ ]*\) milliseconds): [^"]*/TimeoutException after \1 ms/g' $testfile
sed -i -e 's/StackOverflowError(): [^"]*/StackOverflowError()/g' $testfile
if [[ "$i" == expected/run*.err ]] && [[ -s "$testfile" ]]; then
# pretty print as json before diffing (if size > 0)
cat $testfile | python -m json.tool > ${testfile}.new
if [[ $? -ne 0 ]]; then
echo -e "Above JSON is broken" >> $testfile
else
mv ${testfile}.new $testfile
fi
fi
diff -w -u -I '^make' -I '^Makefile:' -I '^javac ' -I '^\s*at java\.lang\.Class\.forName' $i $testfile
ec=$?
if [[ $ec -ne 0 ]] && [[ "$i" == expected/run*.err ]]; then
# in case of JSON, try to parse and compare as JSON
java -cp ../../lib/junitpoints.jar:../../lib/json-simple-1.1.1.jar tools.jsondiff.JSONDiff $i $testfile
ec=$?
if [[ -n "$REBUILD" ]]; then
# in case of JSON, store pretty printed version
cp $testfile $i
fi
fi
else
echo "$testfile does not exist..."
ec=-1
fi
error=$((error|ec))
if [[ $ec -ne 0 ]] && [[ -n "$REBUILD" ]]; then
cp $testfile $i
fi
done;
rm -rf $(readlink -f test.latest)
rm test.latest
exit $error