-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-tests.sh
executable file
·51 lines (47 loc) · 1.38 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
#!/bin/bash
#set -e
#set -x
# Diff for showing failed tests (differing actual output vs expected output).
DIFF=("diff" "-Nu")
if which colordiff >/dev/null; then
DIFF=("colordiff" "-Nu")
fi
if which wdiff >/dev/null; then
DIFF=("wdiff" $(echo -e "--start-delete=\e[91m") $(echo -e "--end-delete=\e[0m") $(echo -e "--start-insert=\e[92m") $(echo -e "--end-insert=\e[0m"))
fi
# Dogfooding is also possible.
if which wbdiff >/dev/null; then
DIFF=("wbdiff" "--skip-equal" "--fuzzy" "--no-header")
fi
for t in tests/*
do
echo "Checking $t"
if ! [ -f "$t/expected" ]; then
echo "MISSING_EXPECTED_FILE"
continue
fi
if ! [ -f "$t/left" ] && ! [ -f "$t/right" ]; then
echo "MISSING_INPUT_FILES"
continue
fi
FUZZY=()
if echo "$t" | grep -q "fuzzy"; then
FUZZY=("--fuzzy" "--fuzzy-weighted")
fi
# Uncomment if you want to update expected output files.
# BE ABSOLUTLY SURE THEY ARE CORRECT!
#./wbdiff "${FUZZY[@]}" --no-color -- "$t/left" "$t/right" > "$t/expected"
env time ./wbdiff "${FUZZY[@]}" --no-color -- "$t/left" "$t/right" > "$t/output"
grep -v 'Initial context length used' "$t/expected" > "$t/expected.filtered"
grep -v 'Initial context length used' "$t/output" > "$t/output.filtered"
cmp "$t/expected.filtered" "$t/output.filtered"
O=$?
"${DIFF[@]}" "$t/expected.filtered" "$t/output.filtered"
if [ "x$O" = "x0" ]; then
echo "OK"
else
echo "FAIL"
exit $O
fi
echo
done