tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / tap-doc.sh
blob69c56f00cd491991e328ac208342a2757d05aedd
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 "Simple Tests" subsection "Script-based Testsuites".
20 . ./defs || exit 1
22 fetch_tap_driver
24 cat >> configure.ac <<END
25 AC_PROG_CC
26 AC_OUTPUT
27 END
29 cat > Makefile.am << 'END'
30 TESTS = foo.sh zardoz.tap bar.sh mu.tap
31 TEST_EXTENSIONS = .sh .tap
32 TAP_LOG_DRIVER = $(srcdir)/tap-driver
33 ## Ensure the test scripts are run in the correct order.
34 mu.log: bar.log
35 bar.log: zardoz.log
36 zardoz.log: foo.log
37 END
39 cat > foo.sh <<'END'
40 #!/bin/sh
41 exit 0
42 END
44 cat > bar.sh <<'END'
45 #!/bin/sh
46 exit 77
47 END
49 cat > zardoz.tap << 'END'
50 #!/bin/sh
51 echo 1..4
52 echo 'ok 1 - Daemon started'
53 echo 'ok 2 - Daemon responding'
54 echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted'
55 echo 'ok 4 - Daemon stopped'
56 END
58 cat > mu.tap << 'END'
59 #!/bin/sh
60 echo 1..2
61 echo 'ok'
62 echo 'not ok # TODO frobnication not yet implemented'
63 END
65 chmod a+x *.sh *.tap
67 $ACLOCAL
68 $AUTOCONF
69 $AUTOMAKE -a
71 ./configure
73 $MAKE check >stdout || { cat stdout; exit 1; }
74 cat stdout
76 cat > exp <<'END'
77 PASS: foo.sh
78 PASS: zardoz.tap 1 - Daemon started
79 PASS: zardoz.tap 2 - Daemon responding
80 SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
81 PASS: zardoz.tap 4 - Daemon stopped
82 SKIP: bar.sh
83 PASS: mu.tap 1
84 XFAIL: mu.tap 2 # TODO frobnication not yet implemented
85 END
87 sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > t
88 cat t
89 # Strip extra "informative" lines that could be printed by Solaris
90 # Distributed Make.
91 LC_ALL=C $EGREP -v ' --> ([0-9][0-9]* job|[Jj]ob output)' t > got
93 cat exp
94 cat got
95 diff exp got