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