-
Notifications
You must be signed in to change notification settings - Fork 24
/
run-tests.sh
executable file
·98 lines (89 loc) · 2.72 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
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
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env bash
shopt -s nullglob
# This script is located on the root of the repository:
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Check that ngless is in the PATH and correctly installed:
if ! ngless --check-install ; then
echo "$(which ngless) --check-install failed."
exit 1
fi
TEST_PREFIX="$1"
echo ">>> Running tests with: $(ngless --version-debug) <<<"
ok="yes"
failed_tests=""
for testdir in tests/*; do
if test -d "$testdir"; then
# Run only tests with specified PREFIX
# Useful to run only 'long-' tests or 'regression'
if [[ "x$TEST_PREFIX" != "x" ]] && [[ "$testdir" != tests/${TEST_PREFIX}* ]]; then
continue
fi
cur_ok=yes
if test -f "${testdir}/TRAVIS_SKIP" -a "x$TRAVIS" = xtrue; then
echo "Skipping $testdir on Travis"
continue
fi
echo "Running $testdir"
cd "$testdir"
mkdir -p temp
validate_arg=""
if [[ $testdir == tests/error-validation-* ]] ; then
validate_arg="-n"
fi
cmd_args=""
if test -f cmdargs ; then
cmd_args="$(cat cmdargs)"
fi
ngless --quiet -t temp $cmd_args $validate_arg *.ngl > output.stdout.txt 2>output.stderr.txt
ngless_exit=$?
if [[ $testdir == tests/error-* ]] ; then
if test $ngless_exit -eq "0"; then
echo "NGLess exited with exit code 0, even though an error was expected in test"
cur_ok=no
fi
else
if test $ngless_exit -ne "0"; then
echo "Error non-zero exit in test: $testdir"
cur_ok=no
fi
fi
for f in expected.*; do
out=output${f#expected}
diff -u "$f" "$out"
if test $? -ne "0"; then
echo "ERROR in test $testdir: $out did not match $f"
cur_ok=no
fi
done
if test -x ./check.sh; then
./check.sh
if test $? -ne "0"; then
echo "ERROR in test $testdir: ./check.sh failed"
cur_ok=no
fi
fi
if test $cur_ok = "no"; then
echo "ERROR: Output from from ngless was:"
cat output.stdout.txt
cat output.stderr.txt
ok=no
failed_tests="${failed_tests} ${testdir}"
fi
if test -x ./cleanup.sh; then
./cleanup.sh
fi
rm -rf temp
rm -rf ./*.output_ngless
rm -f output.*
cd "$basedir"
fi
done
if test $ok = "yes"; then
echo "All done."
else
echo "The following tests failed:"
for f in $failed_tests; do
echo " - $f"
done
exit 1
fi