doc: typos in test file.
[automake.git] / t / test-driver-custom-multitest-recheck2.sh
blob1177f1b0e7110a73413bdb5abc46f3d4f9ceeb21
1 #! /bin/sh
2 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Custom test drivers: try the "recheck" functionality with test protocols
18 # that allow multiple testcases in a single test script. In particular,
19 # check that this still works when we override $(TESTS) and $(TEST_LOGS)
20 # at make runtime.
21 # See also related tests 'test-driver-custom-multitest-recheck.sh' and
22 # 'parallel-tests-recheck-override.sh'.
24 . test-init.sh
26 cp "$am_testaux_srcdir"/trivial-test-driver . \
27 || fatal_ "failed to fetch auxiliary script trivial-test-driver"
29 cat >> configure.ac << 'END'
30 AC_OUTPUT
31 END
33 cat > Makefile.am << 'END'
34 TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
35 TESTS = a.test b.test c.test
36 END
38 cat > a.test << 'END'
39 #! /bin/sh
40 echo PASS: 1
41 echo PASS: 2
42 : > a.run
43 END
45 cat > b.test << 'END'
46 #! /bin/sh
47 echo SKIP: b0
48 if test -f b.ok; then
49 echo XFAIL: b1
50 else
51 echo FAIL: b2
53 : > b.run
54 END
56 cat > c.test << 'END'
57 #! /bin/sh
58 if test -f c.err; then
59 echo ERROR: xxx
60 elif test -f c.ok; then
61 echo PASS: ok
62 else
63 echo XPASS: xp
65 : > c.run
66 END
68 chmod a+x *.test
70 $ACLOCAL
71 $AUTOCONF
72 $AUTOMAKE
74 for vpath in : false; do
75 if $vpath; then
76 mkdir build
77 cd build
78 srcdir=..
79 else
80 srcdir=.
83 $srcdir/configure
85 : Run the tests for the first time.
86 run_make -O -e FAIL check
87 # All the test scripts should have run.
88 test -f a.run
89 test -f b.run
90 test -f c.run
91 count_test_results total=5 pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0
93 rm -f *.run
95 : An empty '$(TESTS)' or '$(TEST_LOGS)' means that no test should be run.
96 for var in TESTS TEST_LOGS; do
97 run_make -O "$var=" recheck
98 count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
99 test ! -e a.run
100 test ! -e b.run
101 test ! -e c.run
102 done
103 unset var
105 : a.test was successful the first time, no need to re-run it.
106 using_gmake || $sleep # Required by BSD make.
107 run_make -O TESTS=a.test recheck
108 count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
109 test ! -e a.run
110 test ! -e b.run
111 test ! -e c.run
113 : b.test failed, it should be re-run. And make it pass this time.
114 using_gmake || $sleep # Required by BSD make.
115 echo OK > b.ok
116 run_make -O TEST_LOGS=b.log recheck
117 test ! -e a.run
118 test -f b.run
119 test ! -e c.run
120 count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
122 rm -f *.run
124 : No need to re-run a.test or b.test anymore.
125 using_gmake || $sleep # Required by BSD make.
126 run_make -O TEST_LOGS=b.log recheck
127 count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
128 test ! -e a.run
129 test ! -e b.run
130 test ! -e c.run
131 using_gmake || $sleep # Required by BSD make.
132 run_make -O TESTS='a.test b.test' recheck
133 count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
134 test ! -e a.run
135 test ! -e b.run
136 test ! -e c.run
138 : No need to re-run a.test anymore, but c.test should be rerun,
139 : as it contained an XPASS. And this time, make it fail with
140 : an hard error.
141 echo dummy > c.err
142 run_make -e FAIL -O TEST_LOGS='a.log c.log' recheck
143 count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
144 test ! -e a.run
145 test ! -e b.run
146 test -f c.run
148 rm -f *.run *.err
150 : c.test contained and hard error the last time, so it should be re-run.
151 : This time, make it pass
152 # Use 'echo', not ':'; see comments above for why.
153 using_gmake || $sleep # Required by BSD make.
154 echo dummy > c.ok
155 run_make -O TESTS='c.test a.test' recheck
156 count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
157 test ! -e a.run
158 test ! -e b.run
159 test -f c.run
161 rm -f *.run *.err *.ok
163 : Nothing should be rerun anymore, as all tests have been eventually
164 : successful.
165 using_gmake || $sleep # Required by BSD make.
166 run_make -O recheck
167 count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
168 test ! -e a.run
169 test ! -e b.run
170 test ! -e c.run
172 cd $srcdir
174 done