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