Ver código fonte

More clean test result

Matthew Wang 11 anos atrás
pai
commit
6bae53b2fd
2 arquivos alterados com 29 adições e 20 exclusões
  1. 28
    17
      tests/regression.sh
  2. 1
    3
      tests/test_cdiff.py

+ 28
- 17
tests/regression.sh Ver arquivo

@@ -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 "$@"

+ 1
- 3
tests/test_cdiff.py Ver arquivo

@@ -63,10 +63,8 @@ class TestPatchStream(unittest.TestCase):
63 63
         items = ['hello', 'world', 'again', 'and', 'again']
64 64
         stream = cdiff.PatchStream(Sequential(items))
65 65
 
66
-        out = []
67 66
         _ = stream.read_stream_header(2)
68
-        for item in stream:
69
-            out.append(item)
67
+        out = list(stream)
70 68
         self.assertEqual(out, items)
71 69
 
72 70