tests: expose automake bug#14560
[platform/upstream/automake.git] / t / test-metadata-recheck.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 # Test the "make recheck" semantics for custom test drivers, as documented
18 # in the Automake manual.
19
20 . test-init.sh
21
22 cat >> configure.ac << 'END'
23 AC_OUTPUT
24 END
25
26 cat > Makefile.am << 'END'
27 LOG_DRIVER = ./dummy-driver
28 TEST_EXTENSIONS =
29 TESTS =
30 END
31
32 #
33 # Tests to be re-run by "make recheck"
34 #
35
36 : > y-1
37 echo "foo bar" > y-2
38 echo ":recheck:" > y-3
39 echo ":recheck:yes" > y-4
40 echo ":recheck: who cares" > y-5
41 echo ":recheck: $tab   y" > y-6
42 echo ":recheck: yeah!$tab$tab " > y-7
43 cat > y-10 <<END
44 :foo:
45 :recheck: ???
46 END
47 cat > y-11 <<END
48 :recheck: YES
49 :foo:
50 END
51 cat > y-12 <<END
52 foo
53 :recheck:yes
54
55 bar
56 zardoz
57 END
58
59 echo "  $tab $tab$tab    :recheck: yes" > y-8
60
61 # The :test-result: fields and the fist line of the log should be
62 # irrelevant for the decision of whether "make recheck" should or
63 # should not re-run a test.
64
65 echo ":test-result: PASS" > y-100
66
67 echo "PASS: y-101"
68
69 cat > y-102 <<END
70 PASS: y-102
71 ===========
72
73 :test-result: PASS
74 END
75
76 #
77 # Tests *not* to be re-run by "make recheck"
78 #
79
80 echo ":recheck:no" > n-1
81 echo ":recheck: no " > n-2
82 echo ":recheck: $tab   no" > n-3
83 echo ":recheck: no $tab$tab " > n-4
84 cat > n-5 <<END
85 :foo:
86 :recheck:no
87 END
88 cat > n-6 <<END
89 :recheck: no
90 :foo:
91 END
92 cat > n-7 <<END
93 foo
94 :recheck: no$tab$tab
95
96 bar
97 zardoz
98 END
99
100 echo "  $tab $tab$tab    :recheck: no" > n-8
101
102 # The :test-result: fields should be irrelevant for the decision of
103 # whether "make recheck" should or should not re-run a test.
104 cat > n-100 <<END
105 :test-result: FAIL
106 :test-result: XPASS
107 :test-result: ERROR
108 :test-result: UNKNOWN
109 :recheck: no
110 END
111
112 rechecked=$(echo y-[0-9]*)
113
114 for t in [yn]-[0-9]*; do echo $t; done \
115   | sed 's/.*/TESTS += &/' >> Makefile.am
116
117 cat Makefile.am # For debugging.
118
119 cat > dummy-driver <<'END'
120 #!/bin/sh
121 set -e; set -u
122 while test $# -gt 0; do
123   case $1 in
124     --log-file) log_file=$2; shift;;
125     --trs-file) trs_file=$2; shift;;
126     --test-name) test_name=$2; shift;;
127     --expect-failure|--color-tests|--enable-hard-errors) shift;;
128     --) shift; break;;
129      *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
130   esac
131   shift
132 done
133 : > $test_name.run
134 : > $log_file
135 cp $1 $trs_file
136 END
137 chmod a+x dummy-driver
138
139 $ACLOCAL
140 $AUTOCONF
141 $AUTOMAKE
142
143 ./configure
144
145 # The ':test-result:' fields should be ignored by "make recheck",
146 # but should cause the testsuite report to detect errors.
147 $MAKE check && exit 1
148 ls -l
149 for t in $tests; do test -f $t.run; done
150 rm -f *.run
151
152 # But now the tests that actually get re-run have only ':test-result:'
153 # fields indicating success, so "make recheck" must pass.  Still, the
154 # next "make recheck" call should still re-run the same set of tests.
155 for iteration in 1 2; do
156   using_gmake || $sleep # Required by BSD make.
157   $MAKE recheck
158   ls -l
159   for t in $rechecked; do test -f $t.run; done
160   find . -name 'n-*.run' | grep . && exit 1
161   : For shells with busted 'set -e'.
162 done
163
164 :