test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / tap-bailout-suppress-later-errors.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # TAP support:
18 #  - A "Bail out!" directive causes the driver to ignore any TAP
19 #    result or error in the rest of the following TAP stream.
20
21 . test-init.sh
22
23 . tap-setup.sh
24
25 # Various errors that can all be squashed into a single test script.
26 cat > foo.test << 'END'
27 1..5
28 Bail out!
29 # All possible test results.
30 # Test out-of-order.
31 ok 4
32 # Extra TAP plan.
33 1..2
34 # Another bailout directive.
35 Bail out! Not seen.
36 # Stop now, with too few tests run.
37 END
38
39 # Tests run after a "SKIP" plan.
40 cat > bar.test << 'END'
41 1..0 # SKIP
42 Bail out!
43 ok 1
44 END
45
46 # Too many tests run.
47 cat > baz.test << 'END'
48 1..1
49 ok 1
50 Bail out!
51 ok 2
52 ok 3
53 END
54
55 run_make -e FAIL -O TESTS='foo.test bar.test baz.test' check
56 count_test_results total=5 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=3
57
58 grep '^ERROR: foo\.test - Bail out!$' stdout
59 grep '^ERROR: bar\.test - Bail out!$' stdout
60 grep '^SKIP: bar\.test'               stdout
61 grep '^ERROR: baz\.test - Bail out!$' stdout
62 grep '^PASS: baz\.test 1$'            stdout
63
64 $FGREP 'Not seen' stdout && exit 1
65
66 test $($FGREP -c ': foo.test' stdout) -eq 1
67 test $($FGREP -c ': bar.test' stdout) -eq 2
68 test $($FGREP -c ': baz.test' stdout) -eq 2
69
70 :