test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / contrib / t / parallel-tests-html.sh
1 #! /bin/sh
2 # Copyright (C) 2009-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 parallel-tests features:
18 #  - check-html
19 #  - recheck-html
20
21 . test-init.sh
22
23 # Try the variants that are tried in check-html.am.
24 while :; do
25   for r2h in $RST2HTML rst2html rst2html.py; do
26     echo "$me: running $r2h --version"
27     $r2h --version && break 2
28     : For shells with busted 'set -e'.
29   done
30   skip_all_ "no proper rst2html program found"
31 done
32 unset r2h
33
34 cp "$am_top_srcdir"/contrib/check-html.am . \
35   || fatal_ "cannot fetch 'check-html.am' from contrib"
36
37 cat >> configure.ac << 'END'
38 AC_OUTPUT
39 END
40
41 cat > Makefile.am << 'END'
42 TEST_SUITE_LOG = mylog.log
43 TESTS = foo.test bar.test baz.test
44 check_SCRIPTS = bla
45 bla:
46         echo bla > $@
47 CLEANFILES = bla
48 include $(srcdir)/check-html.am
49 END
50
51 cat > foo.test <<'END'
52 #! /bin/sh
53 echo "this is $0"
54 test -f bla || exit 1
55 exit 0
56 END
57
58 cat > bar.test <<'END'
59 #! /bin/sh
60 echo "this is $0"
61 exit 99
62 END
63
64 cat > baz.test <<'END'
65 #! /bin/sh
66 echo "this is $0"
67 exit 1
68 END
69
70 chmod a+x foo.test bar.test baz.test
71
72 $ACLOCAL
73 $AUTOCONF
74 $AUTOMAKE -a
75
76 ./configure
77
78 $MAKE check-html && exit 1
79 test -f mylog.html
80 # check-html should cause check_SCRIPTS to be created.
81 test -f bla
82
83 # "make clean" should remove HTML files.
84 $MAKE clean
85 test ! -e mylog.html
86 test ! -e bla
87
88 # Always create the HTML output, even if there were no failures.
89 rm -f mylog.html
90 run_make TESTS=foo.test check-html
91 test -f mylog.html
92
93 # Create summarizing HTML output also with recheck-html.
94 rm -f mylog.html
95 run_make TESTS=foo.test recheck-html
96 test -f mylog.html
97
98 # Create HTML output for an individual test.
99 $MAKE foo.html
100 grep 'this is .*foo\.test' foo.html
101 test ! -e bar.html
102 test ! -e baz.html
103
104 # Create HTML output for individual tests.  Since the pre-existing log
105 # files are expected to be used for the HTML conversion, this should
106 # go smoothly even for failed tests.
107 $MAKE bar.html baz.html
108 grep 'this is .*bar\.test' bar.html
109 grep 'this is .*baz\.test' baz.html
110
111 # HTML output removed by mostlyclean.
112 $MAKE mostlyclean
113 test ! -e foo.html
114 test ! -e bar.html
115 test ! -e baz.html
116 test ! -e mylog.html
117
118 # check-html and recheck-html should cause check_SCRIPTS to be created,
119 # and recheck-html should rerun no tests if check has not been run.
120
121 $MAKE clean
122 test ! -e mylog.html
123 run_make TEST_LOGS=foo.log check-html
124 test -f bla
125 test -f foo.log
126 test ! -e bar.log
127 test ! -e baz.log
128 test -f mylog.html
129
130 $MAKE clean
131 run_make TESTS=foo.test recheck-html
132 test -f bla
133 test ! -e foo.log
134 test -f mylog.html
135
136 $MAKE clean
137 $MAKE recheck-html
138 test -f bla
139 test ! -e foo.log
140 test ! -e bar.log
141 test ! -e baz.log
142 test -f mylog.html
143
144 :