-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testall.sh
executable file
·56 lines (43 loc) · 949 Bytes
/
testall.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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TESTFOLDER=./tests
TMPFOLDER=./tmp
JSDEC=$1
TRAVIS=$2
RMCMD="rm -rf"
ERROR=false
DIFF="diff -u"
if [ -z "$TRAVIS" ]; then
RMCMD="rmdir"
DIFF="diff --color=always -u"
fi
if [ -z "$JSDEC" ]; then
echo "$0 <jsdec folder> <ci>"
exit 1
fi
. "$SCRIPT_DIR/common.sh"
build_testsuite "$JSDEC"
TESTS=$(find "$TESTFOLDER" -name "*.json" | sed "s/.json//g")
mkdir "$TMPFOLDER"
for ELEM in $TESTS; do
NAME=$(basename "$ELEM")
OUTPUTFILE="$TMPFOLDER/$NAME.output.txt"
run_test "$JSDEC" "$ELEM.json" > "$OUTPUTFILE" || break
DIFFOUTPUT=$(diff -u "$ELEM.output.txt" "$OUTPUTFILE")
if [ ! -z "$DIFFOUTPUT" ]; then
echo "[XX]: $NAME"
$DIFF "$ELEM.output.txt" "$OUTPUTFILE"
ERROR=true
break
else
echo "[OK]: $NAME"
rm "$OUTPUTFILE"
fi
done
if [ ! "$TMPFOLDER" == "/tmp" ] ; then
$RMCMD "$TMPFOLDER"
fi
if $ERROR; then
exit 1;
fi
exit 0;