-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathtest.sh
executable file
·88 lines (72 loc) · 1.68 KB
/
test.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
HERE="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$HERE/$SOURCE"
done
HERE="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
. $HERE/../common.sh wizeng
make_wizeng || exit $?
target=$TEST_TARGET
print_testing
cd $HERE
if [ "$#" = 0 ]; then
TESTS=$(ls *.wasm)
else
TESTS="$@"
fi
RAW=${RAW:=0}
function run_test() {
local test=$1
local flags=""
local args=""
echo "##+$test"
if [ -f $test.args ]; then
args=$(cat $test.args)
fi
if [ -f $test.flags ]; then
flags=$(cat $test.flags)
fi
local P=$T/$test
if [ -f $test.in ]; then
$WIZENG_CMD -colors=false $flags $test -- $args < $test.in > $P.out 2> $P.err
else
$WIZENG_CMD -colors=false $flags $test -- $args > $P.out 2> $P.err
fi
echo $? > $P.exit
for check in "out" "err" "exit"; do
if [ -f $test.$check ]; then
diff $test.$check $P.$check | tee $P.$check.diff
DIFF=${PIPESTATUS[0]}
if [ "$DIFF" != 0 ]; then
if [ -f failures.$target ]; then
grep $test failures.$target
if [ $? = 0 ]; then
continue # test was found in expected failures
fi
fi
if [ -f failures.$target.$TEST_MODE ]; then
grep $test failures.$target.$TEST_MODE
if [ $? = 0 ]; then
continue # test was found in expected failures
fi
fi
echo "##-fail: $P.$check.diff"
return 1
fi
fi
done
echo "##-ok"
}
function run_tests() {
printf "##>%d\n" $#
for t in $@; do
run_test $t
done
}
if [ "$RAW" = 0 ]; then
run_tests $TESTS | $PROGRESS
else
run_tests $TESTS
fi