coverage: check-html can be used recursively
[platform/upstream/automake.git] / contrib / t / parallel-tests-html-recursive.sh
1 #! /bin/sh
2 # Copyright (C) 2012 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 # Recursive use of 'check-html'.  See Automake bug#11287.
18
19 . ./defs || exit 1
20
21 # Try the variants that are tried in check-html.am.
22 while :; do
23   for r2h in $RST2HTML rst2html rst2html.py; do
24     echo "$me: running $r2h --version"
25     $r2h --version && break 2
26     : For shells with busted 'set -e'.
27   done
28   skip_all_ "no proper rst2html program found"
29 done
30 unset r2h
31
32 cp "$am_top_srcdir"/contrib/check-html.am . \
33   || fatal_ "cannot fetch 'check-html.am' from contrib"
34
35 cat >> configure.ac << 'END'
36 AM_EXTRA_RECURSIVE_TARGETS([check-html])
37 AC_CONFIG_FILES([sub/Makefile sub/more/Makefile])
38 AC_OUTPUT
39 END
40
41 cat > Makefile.am << 'END'
42 SUBDIRS = sub
43 EXTRA_DIST = $(TESTS)
44 TEST_SUITE_LOG = mylog.log
45 TESTS = foo.test bar.sh mu
46 XFAIL_TESTS = bar.sh
47 check_SCRIPTS = bla
48 bla:
49         echo '#!/bin/sh' > $@-t
50         echo 'echo Blah Blah Blah' >> $@-t
51         chmod a+x,a-w $@-t
52         mv -f $@-t $@
53 CLEANFILES = bla
54 include $(srcdir)/check-html.am
55 END
56
57 mkdir sub
58 echo SUBDIRS = more > sub/Makefile.am
59
60 mkdir sub/more
61 cat > sub/more/Makefile.am << 'END'
62 include $(top_srcdir)/check-html.am
63 TEST_EXTENSIONS = .test .sh
64 TESTS = sh.sh test.test
65 LOG_COMPILER = true
66 test.log: sh.log
67 nodist_check_DATA = x.txt
68 $(nodist_check_DATA):
69         echo $@ > $@
70 CLEANFILES = $(nodist_check_DATA)
71 EXTRA_DIST = $(TESTS)
72 END
73
74 cat > foo.test <<'END'
75 #! /bin/sh
76 ./bla
77 exit 77
78 END
79
80 cat > bar.sh <<'END'
81 #! /bin/sh
82 echo "this is $0"
83 exit 1
84 END
85
86 cat > mu <<'END'
87 #! /bin/sh
88 set -x
89 test -f sub/more/test.log
90 test -f sub/more/sh.log
91 END
92
93 cat > sub/more/test.test << 'END'
94 #!/bin/sh
95 echo "this is $0"
96 set -x
97 test -f sh.log
98 test -f x.txt
99 exit 77
100 END
101
102 cat > sub/more/sh.sh << 'END'
103 #!/bin/sh
104 set -x
105 test ! -f test.log
106 test -f x.txt
107 END
108
109
110 cat > sub/more/mu << 'END'
111 #!/bin/sh
112 exit 99
113 END
114
115 chmod a+x foo.test bar.sh mu sub/more/test.test sub/more/sh.sh
116
117 $ACLOCAL
118 $AUTOCONF
119 $AUTOMAKE -a
120
121 ./configure
122
123 $MAKE check-html
124 grep 'Blah Blah Blah' mylog.html
125 grep 'this is .*bar\.sh' mylog.html
126 grep 'this is .*test\.test' sub/more/test-suite.html
127 # check-html should cause check_SCRIPTS and check_DATA to be created.
128 test -f bla
129 test -f sub/more/x.txt
130
131 # "make clean" should remove HTML files.
132 $MAKE clean
133 test ! -e mylog.html
134 test ! -e sub/more/test-suite.html
135 test ! -e bla
136 test ! -e sub/more/x.txt
137
138 # Create HTML output for individual tests.
139
140 $MAKE bla
141 $MAKE foo.html bar.sh.html
142 grep 'Blah Blah Blah' foo.html
143 grep 'this is .*bar\.sh' bar.sh.html
144 test ! -e mu.hml
145
146 ocwd=$(pwd) || fatal_ "getting current workind directory"
147 ( cd sub/more \
148     && $MAKE sh.html \
149     && test -f sh.html \
150     && test ! -e test.html \
151     && $MAKE test.html \
152     && grep 'this is .*test\.test' test.html) || exit 1
153
154 # HTML output removed by mostlyclean.
155 $MAKE check-html
156 test -f mylog.html
157 test -f sub/more/test-suite.html
158 $MAKE mostlyclean
159 find . -name '*.html' | grep . && exit 1
160
161 $MAKE distcheck
162
163 :