tests: expose automake bug#14560
[platform/upstream/automake.git] / t / tap-doc2.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 # Check that an example given in the documentation really works.
18 # See section "Using the TAP test protocol", subsection "Use TAP
19 # with the Automake test harness".
20
21 am_create_testdir=empty
22 . test-init.sh
23
24 cat > Makefile.am <<'END'
25 TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
26                   $(top_srcdir)/build-aux/tap-driver.sh
27 TESTS = foo.test bar.test baz.test
28 EXTRA_DIST = $(TESTS)
29 END
30
31 cat > configure.ac <<'END'
32 AC_INIT([GNU Try Tap], [1.0], [bug-automake@gnu.org])
33 AC_CONFIG_AUX_DIR([build-aux])
34 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
35 AC_CONFIG_FILES([Makefile])
36 AC_REQUIRE_AUX_FILE([tap-driver.sh])
37 AC_PROG_AWK
38 AC_OUTPUT
39 END
40
41 cat > foo.test <<'END'
42 #!/bin/sh
43 echo 1..4 # Number of tests to be executed.
44 echo 'ok 1 - Swallows fly'
45 echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
46 echo 'ok 3 - Pigs fly # SKIP not enough acid'
47 echo '# I just love word plays...'
48 echo 'ok 4 - Flies fly too :-)'
49 END
50
51 cat > bar.test <<'END'
52 #!/bin/sh
53 echo 1..3
54 echo 'not ok 1 - Bummer, this test has failed.'
55 echo 'ok 2 - This passed though.'
56 echo 'Bail out! Ennui kicking in, sorry...'
57 echo 'ok 3 - This will not be seen.'
58 END
59
60 cat > baz.test <<'END'
61 #!/bin/sh
62 echo 1..1
63 echo ok 1
64 # Exit with error, even if all the tests have been successful.
65 exit 7
66 END
67
68 chmod a+x *.test
69
70 # Strip extra "informative" lines that could be printed by Solaris
71 # Distributed Make.
72 mkdir build-aux
73 cp "$am_scriptdir"/tap-driver.sh build-aux \
74   || framework_failure_ "fetching the perl TAP driver"
75
76 (export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || exit 1
77
78 ./configure --help # Sanity check.
79 ./configure || skip_ "configure failed"
80
81 case $MAKE in *\ -j*) skip_ "can't work easily with concurrent make";; esac
82
83 # Prevent Sun Distributed Make from trying to run in parallel.
84 DMAKE_MODE=serial; export DMAKE_MODE
85
86 run_make -O -e FAIL check
87
88 cat > exp <<'END'
89 PASS: foo.test 1 - Swallows fly
90 XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
91 SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
92 PASS: foo.test 4 - Flies fly too :-)
93 FAIL: bar.test 1 - Bummer, this test has failed.
94 PASS: bar.test 2 - This passed though.
95 ERROR: bar.test - Bail out! Ennui kicking in, sorry...
96 PASS: baz.test 1
97 ERROR: baz.test - exited with status 7
98 END
99
100 sed -n '/^PASS: foo\.test/,/^ERROR: baz\.test/p' stdout > got
101
102 cat exp
103 cat got
104 diff exp got
105
106 grep '^Please report to bug-automake@gnu\.org$' stdout
107
108 run_make -O check \
109   TESTS='foo.test baz.test' \
110   TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit'
111
112 cat > exp <<'END'
113 PASS: foo.test 1 - Swallows fly
114 XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
115 SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
116 # foo.test: I just love word plays...
117 PASS: foo.test 4 - Flies fly too :-)
118 PASS: baz.test 1
119 END
120
121 sed -n '/^PASS: foo\.test/,/^PASS: baz\.test/p' stdout > got
122
123 cat exp
124 cat got
125 diff exp got
126
127 # Sanity check the distribution.
128 cat > bar.test <<'END'
129 #!/bin/sh
130 echo 1..1
131 echo ok 1
132 END
133 echo AM_TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile.in
134 ./config.status Makefile
135 $MAKE distcheck
136
137 rm -f Makefile.in # To avoid a maintainer-check failure.
138
139 :