tests: work around strangeness in MSYS
[automake.git] / tests / tap-plan-errors.test
blobe3c02c8bdae91f16b75915ff15022702299f3a1b
1 #! /bin/sh
2 # Copyright (C) 2011 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # TAP support: the following situations should be flagged as errors:
18 # - unmatched test plan (too few tests run)
19 # - multiple test plans
20 # - missing test plan
21 # - misplaced test plan (tests run after a late plan)
22 # Checks about unplanned tests are performed in 'tap-unplanned.test'
23 # and 'tap-skip-whole-badcount.test'. More checks about corner-cases
24 # in TAP plans are performed in 'tap-plan-corner.test'.
26 am_parallel_tests=yes
27 . ./defs || Exit 1
29 . "$testsrcdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
31 my_check ()
33 cat > all.test
34 test -n "$err" || fatal_ "\$err not set before calling my_check"
35 cat all.test # For debugging.
36 $MAKE check >stdout && { cat stdout; Exit 1; }
37 cat stdout
38 count_test_results "$@"
39 grep "^ERROR: all\\.test $err$" stdout
40 unset err
43 err='- too few tests run (expected 2, got 1)'
44 my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
45 1..2
46 ok 1
47 END
49 err='- too few tests run (expected 12, got 3)'
50 my_check total=4 pass=2 fail=0 xpass=0 xfail=1 skip=0 error=1 <<END
51 ok 1
52 ok 2
53 not ok 3 # TODO
54 1..12
55 END
57 err='- too few tests run (expected 1, got 0)'
58 my_check total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
59 1..1
60 END
62 err='2 # AFTER LATE PLAN'
63 my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
64 ok 1
65 1..2
66 ok 2
67 END
69 err='5 # AFTER LATE PLAN'
70 my_check total=5 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
71 ok 1
72 ok 2
73 ok 3
74 ok 4
75 1..5
76 ok 5
77 END
79 err='- missing test plan'
80 my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
81 ok 1
82 END
85 # The two test plans here are deliberately equal.
86 err='- multiple test plans'
87 my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
88 1..2
89 ok 1
90 ok 2
91 1..2
92 END
94 # The second plan is diagnosed as extra, and only the first one is
95 # relevant w.r.t. the number of the expected test.
96 err='- multiple test plans'
97 my_check total=4 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
98 1..3
99 ok 1
100 ok 2
101 1..2
102 ok 3
105 # As above, in a slightly different situation.
106 err='- multiple test plans'
107 my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
108 1..2
109 ok 1
110 ok 2
111 1..4