Merge branch 'maint'
[platform/upstream/automake.git] / t / test-trs-recover.sh
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 # Check parallel harness features:
18 #  - recovery from deleted '.trs' files, in various scenarios
19 # This test is complex and tricky, but that's acceptable since we are
20 # testing semantics that are potentially complex and tricky.
21
22 . ./defs || exit 1
23
24 cat >> configure.ac <<END
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 TESTS = foo.test bar.test baz.test
30 TEST_LOG_COMPILER = $(SHELL)
31 END
32
33 # Creative quoting below to please maintainer-check.
34 echo exit '$TEST_STATUS' > foo.test
35 echo exit '$TEST_STATUS' > bar.test
36 : > baz.test
37
38 TEST_STATUS=0; export TEST_STATUS
39
40 # Slower and possible overkill in some situations, but also clearer
41 # and safer.
42 update_stamp () { $sleep && touch stamp && $sleep; }
43
44 $ACLOCAL
45 $AUTOCONF
46 $AUTOMAKE -a
47
48 ./configure
49
50 : Create the required log files.
51 $MAKE check
52
53 : Recreate by hand.
54 rm -f foo.trs bar.trs baz.trs
55 $MAKE foo.trs
56 test -f foo.trs
57 test ! -f bar.trs
58 test ! -f baz.trs
59
60 : Recreate by hand, several at the same time.
61 rm -f foo.trs bar.trs baz.trs
62 $MAKE foo.trs bar.trs
63 test -f foo.trs
64 test -f bar.trs
65 test ! -f baz.trs
66
67 : Recreate by hand, with a failing test.
68 rm -f foo.trs bar.trs
69 TEST_STATUS=1 $MAKE bar.trs baz.trs >stdout || { cat stdout; exit 1; }
70 cat stdout
71 test ! -f foo.trs
72 test -f bar.trs
73 test -f baz.trs
74 grep '^FAIL: bar\.test' stdout
75 $EGREP '^(baz|foo)\.test' stdout && exit 1
76
77 : Recreate with a sweeping "make check", and ensure that also up-to-date
78 : '.trs' files are remade.
79 update_stamp
80 rm -f foo.trs bar.trs
81 $MAKE check
82 test -f foo.trs
83 test -f bar.trs
84 is_newest baz.trs stamp
85
86 : Recreate with a sweeping "make check" with failing tests.  Again,
87 : ensure that also up-to-date '.trs' files are remade -- this time we
88 : grep the "make check" output verify that.
89 rm -f foo.trs bar.trs
90 TEST_STATUS=1 $MAKE check >stdout && { cat stdout; exit 1; }
91 test -f foo.trs
92 test -f bar.trs
93 grep '^FAIL: foo\.test' stdout
94 grep '^FAIL: bar\.test' stdout
95 grep '^PASS: baz\.test' stdout
96
97 : Recreate with a "make check" with redefined TESTS.
98 rm -f foo.trs bar.trs baz.trs
99 TESTS=foo.test $MAKE -e check
100 test -f foo.trs
101 test ! -f bar.trs
102 test ! -f baz.trs
103
104 : Recreate with a "make check" with redefined TEST_LOGS.
105 rm -f foo.trs bar.trs baz.trs
106 TEST_LOGS=bar.log $MAKE -e check
107 test ! -f foo.trs
108 test -f bar.trs
109 test ! -f baz.trs
110
111 : Interactions with "make recheck" are OK.
112 rm -f foo.trs bar.trs baz.log baz.trs
113 $MAKE recheck >stdout || { cat stdout; exit 1; }
114 cat stdout
115 test -f foo.trs
116 test -f bar.trs
117 test ! -f baz.trs
118 test ! -f baz.log
119 grep '^PASS: foo\.test' stdout
120 grep '^PASS: bar\.test' stdout
121 grep 'baz\.test' stdout && exit 1
122 count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
123
124 : Setup for the next check.
125 $MAKE check
126 test -f foo.trs
127 test -f bar.trs
128 test -f baz.trs
129
130 : Recreate by remaking the global test log, and ensure that up-to-date
131 : '.trs' files are *not* remade.
132 update_stamp
133 rm -f foo.trs bar.trs test-suite.log
134 $MAKE test-suite.log >stdout || { cat stdout; exit 1; }
135 cat stdout
136 grep '^PASS: foo\.test' stdout
137 grep '^PASS: bar\.test' stdout
138 grep 'baz\.test' stdout && exit 1
139 stat *.trs *.log stamp || : # For debugging.
140 # Check that make has updated what it needed to, but no more.
141 test -f foo.trs
142 test -f bar.trs
143 is_newest stamp baz.trs
144 is_newest test-suite.log foo.trs bar.trs
145
146 : Setup for the next check.
147 $MAKE check
148 test -f foo.trs
149 test -f bar.trs
150 test -f baz.trs
151
152 : Interactions with lazy test reruns are OK.
153 rm -f foo.trs
154 update_stamp
155 touch bar.test
156 RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; exit 1; }
157 cat stdout
158 # Check that make has updated what it needed to, but no more.
159 test -f foo.trs
160 is_newest bar.trs bar.test
161 is_newest stamp baz.trs
162 grep '^PASS: foo\.test' stdout
163 grep '^PASS: bar\.test' stdout
164 grep 'baz\.test' stdout && exit 1
165
166 :