-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrun-tests.sh
executable file
·79 lines (71 loc) · 1.99 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
#!/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 macrel is in the PATH
if ! which macrel ; then
echo "which macrel failed."
exit 1
fi
echo ">>> Running tests with: $(macrel --version) <<<"
ok="yes"
failed_tests=""
for testdir in tests/*; do
if test -d "$testdir"; then
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"
if [[ -d out ]]; then
rm -rf out
fi
mkdir -p temp
export TMPDIR="$PWD/temp"
./command.sh >stdout.txt 2>stderr.txt
macrel_exit=$?
if [[ $testdir == tests/error-* ]] ; then
if test $macrel_exit -eq "0"; then
echo "Macrel exited with exit code 0, even though an error was expected in test"
cur_ok=no
fi
else
if test $macrel_exit -ne "0"; then
echo "Error non-zero exit in test: $testdir"
echo "STDOUT:"
cat stdout.txt
echo
echo "STDERR:"
cat stderr.txt
cur_ok=no
fi
fi
for f in expected.*; do
out=out/macrel.out${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 $cur_ok = "no"; then
ok=no
failed_tests="${failed_tests} ${testdir}"
fi
rm stdout.txt stderr.txt
rm -rf temp/
rm -rf out/
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