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