-
Notifications
You must be signed in to change notification settings - Fork 27
/
runtests
executable file
·69 lines (60 loc) · 1.79 KB
/
runtests
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
#!/bin/bash
#
# This script runs all the automated tests, or a select set of tests
# named on the command line.
#
# Inputs are image files (.jpg and .png), expected imago results are the
# matching .txt files.
#
# The "--all" argument to runtests runs all tests, even the ones marked
# "skip".
OPTIONAL_SKIP="-name skip -prune -o"
if [ "$1" = "--all" ]; then
OPTIONAL_SKIP=""
shift
fi
# Run all tests in 'tests/' by default, or whatever ones the user named
# on the command-line. Ignore any subdirectories named "skip", so that
# flaky tests can be easily (temporarily?) disabled.
if [ -z "$*" ]; then
INPUT_SEARCH='tests/'
else
INPUT_SEARCH="$*"
fi
INPUTS=$(find $INPUT_SEARCH $OPTIONAL_SKIP \( -name '*.jpg' -o -name '*.png' \) -print | sort)
FAILED=''
for INPUT in $INPUTS; do
echo running test: $INPUT
# Skip input image files that don't have a matching .txt file
# containing expected output.
EXPECTED=$(dirname $INPUT)/$(basename ${INPUT%.*}).txt
if [ ! -f $EXPECTED ]; then
echo "no expected-output file found"
continue
fi
# Run imago on the input file, check for failure.
rm -f $INPUT.out
./imago --rng-seed "runtests rng seed" $INPUT > $INPUT.out
if [ $? -ne 0 ]; then
echo "ERROR: imago returned failure"
FAILED="$FAILED $INPUT"
continue
fi
# imago ran successfully on the input file, compare output to expected.
diff -u $EXPECTED $INPUT.out
if [ $? -ne 0 ]; then
echo "ERROR: imago produced unexpected output"
FAILED="$FAILED $INPUT"
else
# clean up after this passed test
rm -f $INPUT.out
fi
done
# Report all the tests that failed.
if [ -n "$FAILED" ]; then
echo "tests failed:"
for F in $FAILED; do
echo " $F"
done
exit 1
fi