tests: avoid two spurious failures on FreeBSD
[automake.git] / t / tap-basic.sh
blob4781ce5ac3a5f8133ebeff4c2d0c6a49541cffa1
1 #! /bin/sh
2 # Copyright (C) 2011-2012 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 # Basic TAP support:
18 # - LOG_COMPILER support;
19 # - basic support for TODO and SKIP directives, and "Bail out!" magic;
20 # - testsuite progress output on console;
21 # - runtime overriding of TESTS and TEST_LOGS;
22 # - correct counts of test results (both in summary and in progress
23 # output on console).
24 # Note that some of the features checked here are checked in other
25 # test cases too, usually in a more thorough and detailed way.
27 . ./defs || exit 1
29 fetch_tap_driver
31 cat >> configure.ac <<END
32 AC_OUTPUT
33 END
35 cat > Makefile.am << 'END'
36 TEST_LOG_DRIVER = $(srcdir)/tap-driver
37 ## Defining LOG_COMPILER should work and not intefere with the
38 ## tap-driver script.
39 TEST_LOG_COMPILER = cat
40 TESTS = success.test
42 ok.test:
43 echo '1..3' > $@-t
44 echo 'ok 1' >> $@-t
45 echo 'not ok 2 # TODO' >>$@-t
46 echo 'ok 3 # SKIP' >>$@-t
47 cat $@-t ;: For debugging.
48 mv -f $@-t $@
49 END
51 cat > success.test << 'END'
52 1..20
53 ok 1
54 ok 2 two
55 ok 3 - three
56 ok 4 four four
57 not ok 5
58 not ok 6 six
59 not ok 7 - seven
60 not ok 8 eight eight
61 ok 9 # TODO
62 ok 10 ten # TODO
63 ok 11 - eleven # TODO
64 ok 12 twelve twelve # TODO
65 not ok 13 # TODO
66 not ok 14 fourteen # TODO
67 not ok 15 - fifteen # TODO
68 not ok 16 sixteen sixteen # TODO
69 ok 17 # SKIP
70 ok 18 eighteen # SKIP
71 ok 19 - nineteen # SKIP
72 ok 20 twenty twenty # SKIP
73 END
75 $ACLOCAL
76 $AUTOCONF
77 $AUTOMAKE
79 ./configure
81 # Basilar usage and testsuite progress output.
83 $MAKE check >stdout && { cat stdout; exit 1; }
84 cat stdout
86 count_test_results total=20 pass=4 fail=4 xpass=4 xfail=4 skip=4 error=0
88 test -f success.log
89 test -f test-suite.log
91 cat > exp << 'END'
92 PASS: success.test 1
93 PASS: success.test 2 two
94 PASS: success.test 3 - three
95 PASS: success.test 4 four four
96 FAIL: success.test 5
97 FAIL: success.test 6 six
98 FAIL: success.test 7 - seven
99 FAIL: success.test 8 eight eight
100 XPASS: success.test 9 # TODO
101 XPASS: success.test 10 ten # TODO
102 XPASS: success.test 11 - eleven # TODO
103 XPASS: success.test 12 twelve twelve # TODO
104 XFAIL: success.test 13 # TODO
105 XFAIL: success.test 14 fourteen # TODO
106 XFAIL: success.test 15 - fifteen # TODO
107 XFAIL: success.test 16 sixteen sixteen # TODO
108 SKIP: success.test 17 # SKIP
109 SKIP: success.test 18 eighteen # SKIP
110 SKIP: success.test 19 - nineteen # SKIP
111 SKIP: success.test 20 twenty twenty # SKIP
114 $FGREP ': success.test' stdout > got
116 cat exp
117 cat got
118 diff exp got
120 # Override TESTS from the command line.
122 rm -f *.log *.test
124 cat > bail.test <<'END'
125 1..1
126 Bail out!
127 ok 1
130 TESTS=bail.test $MAKE -e check >stdout && { cat stdout; exit 1; }
131 cat stdout
133 count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
135 test ! -e success.log
136 test -f bail.log
137 test -f test-suite.log
139 grep '^ERROR: bail\.test - Bail out!' stdout
140 grep '^PASS:' stdout && exit 1
141 test $($FGREP -c ': bail.test' stdout) -eq 1
142 $FGREP 'success.test' stdout && exit 1
144 # Override TEST_LOGS from the command line, making it point to a test
145 # (ok.test) that has to be generated at make time.
147 rm -f *.log *.test
149 TEST_LOGS=ok.log $MAKE -e check >stdout || { cat stdout; exit 1; }
150 cat stdout
152 count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
154 test -f ok.test
155 test -f ok.log
156 test ! -e success.log
157 test ! -e bail.log
158 test -f test-suite.log
160 $EGREP '(bail|success)\.test' stdout && exit 1
162 cat > exp << 'END'
163 PASS: ok.test 1
164 XFAIL: ok.test 2 # TODO
165 SKIP: ok.test 3 # SKIP
168 $FGREP ': ok.test' stdout > got
170 cat exp
171 cat got
172 diff exp got