Merge branch 'yacc-quote-fix'
[automake.git] / tests / tap-doc2.test
blob7600e22f98eabe5c20dbcafda095b4443038ee67
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 # 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".
21 am_create_testdir=empty
22 am_parallel_tests=yes
23 . ./defs || Exit 1
25 cat > Makefile.am <<'END'
26 TEST_LOG_DRIVER = $(PERL) $(srcdir)/build-aux/tap-driver.pl
27 TESTS = foo.test bar.test baz.test
28 EXTRA_DIST = $(TESTS)
29 END
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 parallel-tests -Wall -Werror])
35 AC_CONFIG_FILES([Makefile])
36 AC_REQUIRE_AUX_FILE([tap-driver.pl])
37 AC_PATH_PROG([PERL], [perl])
38 test -n "$PERL" || AC_MSG_ERROR([perl not found])
39 $PERL -MTAP::Parser -e 1 || AC_MSG_ERROR([TAP::Parser not found])
40 AC_OUTPUT
41 END
43 cat > foo.test <<'END'
44 #!/bin/sh
45 echo 1..4 # Number of tests to be executed.
46 echo 'ok 1 - Swallows fly'
47 echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
48 echo 'ok 3 - Pigs fly # SKIP not enough acid'
49 echo '# I just love word plays...'
50 echo 'ok 4 - Flies fly too :-)'
51 END
53 cat > bar.test <<'END'
54 #!/bin/sh
55 echo 1..3
56 echo 'not ok 1 - Bummer, this test has failed.'
57 echo 'ok 2 - This passed though.'
58 echo 'Bail out! Ennui kicking in, sorry...'
59 echo 'ok 3 - This will not be seen.'
60 END
62 cat > baz.test <<'END'
63 #!/bin/sh
64 echo 1..1
65 echo ok 1
66 # Exit with error, even if all the test case has been successful.
67 exit 7
68 END
70 chmod a+x *.test
72 # Strip extra "informative" lines that could be printed by Solaris
73 # Distributed Make.
74 mkdir build-aux
75 cp "$am_scriptdir"/tap-driver.pl build-aux \
76 || framework_failure_ "fetching the perl TAP driver"
78 (export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || Exit 1
80 ./configure --help # Sanity check.
81 ./configure || skip_ "configure failed"
83 case $MAKE in *\ -j*) skip_ "can't work easily with concurrent make";; esac
85 # Prevent Sun Distributed Make from trying to run in parallel.
86 DMAKE_MODE=serial; export DMAKE_MODE
88 $MAKE check >stdout && { cat stdout; Exit 1; }
89 cat stdout
91 cat > exp <<'END'
92 PASS: foo.test 1 - Swallows fly
93 XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
94 SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
95 PASS: foo.test 4 - Flies fly too :-)
96 FAIL: bar.test 1 - Bummer, this test has failed.
97 PASS: bar.test 2 - This passed though.
98 ERROR: bar.test - Bail out! Ennui kicking in, sorry...
99 PASS: baz.test 1
100 ERROR: baz.test - exited with status 7
103 sed -n '/^PASS: foo\.test/,/^ERROR: baz\.test/p' stdout > got
105 cat exp
106 cat got
107 diff exp got
109 grep '^Please report to bug-automake@gnu\.org$' stdout
111 env \
112 TESTS='foo.test baz.test' \
113 TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit' \
114 $MAKE -e check >stdout || { cat stdout; Exit 1; }
116 cat > exp <<'END'
117 PASS: foo.test 1 - Swallows fly
118 XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
119 SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
120 # foo.test: I just love word plays...
121 PASS: foo.test 4 - Flies fly too :-)
122 PASS: baz.test 1
125 sed -n '/^PASS: foo\.test/,/^PASS: baz\.test/p' stdout > got
127 cat exp
128 cat got
129 diff exp got
131 # Sanity check the distribution.
132 cat > bar.test <<'END'
133 #!/bin/sh
134 echo 1..1
135 echo ok 1
137 echo AM_TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile.in
138 ./config.status Makefile
139 $MAKE distcheck