-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests.sh
executable file
·44 lines (36 loc) · 1 KB
/
run-tests.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
#!/bin/bash
fail() {
echo "FAIL - $1" >&2
exit 1
}
run_test_case() {
local scripts want wantExit outputs name testcasesdir rootdir runparts
runparts=$1
rootdir=$2
name=$(basename ${rootdir})
scripts=${rootdir}/scripts
args=${rootdir}/args
gotStderr=${rootdir}/gotStderr
gotStdout=${rootdir}/gotStdout
wantStderr=${rootdir}/wantStderr
wantStdout=${rootdir}/wantStdout
wantExit=${rootdir}/wantExit
rm -f ${gotStdout} ${gotStderr}
echo -n -e "[${name}] ${runparts} $(<${args}) ${scripts} 1>${gotStdout} 2>${gotStderr} " >&2
${runparts} $(<${args}) ${scripts} 1>${gotStdout} 2>${gotStderr} <AUTHORS
[ $? = $(<${wantExit}) ] || fail exitCode
diff -u ${wantStdout} ${gotStdout} || fail stdout
diff -u ${wantStderr} ${gotStderr} || fail stderr
echo "OK" >&2
}
set -eo pipefail;
[[ $TEST_TRACE ]] && set -x
set -u
runparts=$1
testdata=$2
[ -x ${runparts} ]
[ -d ${testdata} ]
testcases="$(ls -d ${testdata}/TestCase*)"
for tc in ${testcases}; do
run_test_case ${runparts} ${tc}
done