|
@@ -1,9 +1,9 @@
|
1
|
1
|
#!/bin/bash
|
2
|
2
|
|
3
|
|
-set -o errexit
|
|
3
|
+TOP_DIR=$(cd $(dirname $0)/.. && pwd) || exit 1
|
|
4
|
+cd $TOP_DIR || exit 1
|
4
|
5
|
|
5
|
|
-SELF_DIR=$(cd $(dirname $0) && pwd) || exit 1
|
6
|
|
-CDIFF=$SELF_DIR/../cdiff
|
|
6
|
+CDIFF=./cdiff
|
7
|
7
|
|
8
|
8
|
# To test with py3k: PYTHON=python3 make test
|
9
|
9
|
PYTHON=${PYTHON:-python}
|
|
@@ -26,37 +26,48 @@ function fail()
|
26
|
26
|
fi
|
27
|
27
|
}
|
28
|
28
|
|
29
|
|
-function cmpOutput()
|
|
29
|
+function cmp_output()
|
30
|
30
|
{
|
31
|
31
|
local input=${1:?}
|
32
|
32
|
local expected_out=${2:?}
|
33
|
33
|
local cdiff_opt=${3:-""}
|
|
34
|
+ local cmd
|
34
|
35
|
|
35
|
|
- echo -n "Test option '$cdiff_opt' with input '$input' ... "
|
36
|
|
- if $PYTHON $CDIFF $cdiff_opt $input 2>/dev/null \
|
37
|
|
- | diff -ubq $expected_out - >& /dev/null; then
|
|
36
|
+ cmd=$(printf "%-8s $CDIFF %-25s %-20s " $PYTHON "$input" "$cdiff_opt")
|
|
37
|
+ printf "$cmd"
|
|
38
|
+ if $cmd 2>/dev/null | diff -ubq $expected_out - >& /dev/null; then
|
38
|
39
|
pass
|
39
|
40
|
return 0
|
40
|
41
|
else
|
41
|
|
- fail "(expected output: '$expected_out')"
|
|
42
|
+ fail "!= $expected_out"
|
42
|
43
|
return 1
|
43
|
44
|
fi
|
44
|
45
|
}
|
45
|
46
|
|
46
|
47
|
function main()
|
47
|
48
|
{
|
48
|
|
- local rc=0
|
|
49
|
+ local total=0
|
|
50
|
+ local e=0
|
49
|
51
|
local d
|
50
|
52
|
|
51
|
|
- for d in $SELF_DIR/*/; do
|
52
|
|
- cmpOutput "${d}in.diff" ${d}out.normal "-c always" || rc=1
|
53
|
|
- cmpOutput "${d}in.diff" ${d}out.side-by-side "-c always -s" || rc=1
|
54
|
|
- cmpOutput "${d}in.diff" ${d}out.w70 "-c always -s -w70" || rc=1
|
55
|
|
- cmpOutput "${d}in.diff" "${d}in.diff" "-c auto" || rc=1
|
56
|
|
- cmpOutput "${d}in.diff" "${d}in.diff" "-c auto -s" || rc=1
|
57
|
|
- cmpOutput "${d}in.diff" "${d}in.diff" "-c auto -s -w70" || rc=1
|
|
53
|
+ for d in tests/*/; do
|
|
54
|
+ d=${d%/}
|
|
55
|
+ cmp_output $d/in.diff $d/out.normal "-c always" || ((e++))
|
|
56
|
+ cmp_output $d/in.diff $d/out.side-by-side "-c always -s" || ((e++))
|
|
57
|
+ cmp_output $d/in.diff $d/out.w70 "-c always -s -w70" || ((e++))
|
|
58
|
+ cmp_output $d/in.diff $d/in.diff "-c auto" || ((e++))
|
|
59
|
+ cmp_output $d/in.diff $d/in.diff "-c auto -s" || ((e++))
|
|
60
|
+ cmp_output $d/in.diff $d/in.diff "-c auto -s -w70" || ((e++))
|
|
61
|
+ (( total += 6 ))
|
58
|
62
|
done
|
59
|
|
- return $rc
|
|
63
|
+
|
|
64
|
+ if (( e > 0 )); then
|
|
65
|
+ echo "*** $e out of $total tests failed." >&2
|
|
66
|
+ return 1
|
|
67
|
+ else
|
|
68
|
+ echo "All $total tests passed."
|
|
69
|
+ return 0
|
|
70
|
+ fi
|
60
|
71
|
}
|
61
|
72
|
|
62
|
73
|
main "$@"
|