doc: update Vala documentation
[automake.git] / t / parallel-tests-basics.sh
blob8511d8187b59f20501af9800149e7907764d298b
1 #! /bin/sh
2 # Copyright (C) 2009-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 # Basic checks on parallel-tests support:
18 # - console output
19 # - log files, and what goes in 'test-suite.log'
20 # - make clean
21 # - dependencies between tests
22 # - TESTS redefinition at runtime
23 # - TEST_LOGS redefinition at runtime
24 # - RECHECK_LOGS redefinition at runtime
26 . test-init.sh
28 cat >> configure.ac << 'END'
29 AC_OUTPUT
30 END
32 cat > Makefile.am << 'END'
33 TESTS = foo.test bar.test baz.test
34 XFAIL_TESTS = bar.test
35 foo.log: bar.log
36 bar.log: baz.log
37 END
39 # foo.test and bar.test sleep to ensure their logs are always strictly newer
40 # than the logs of their prerequisites, for HP-UX make. The quoting pleases
41 # maintainer-check.
42 cat > foo.test <<'END'
43 #! /bin/sh
44 echo "this is $0"
45 sleep '1'
46 exit 0
47 END
48 cat > bar.test <<'END'
49 #! /bin/sh
50 echo "this is $0"
51 sleep '1'
52 exit 99
53 END
54 cat > baz.test <<'END'
55 #! /bin/sh
56 echo "this is $0"
57 exit 1
58 END
59 chmod a+x foo.test bar.test baz.test
61 $ACLOCAL
62 $AUTOCONF
63 $AUTOMAKE -a
65 ./configure
67 run_make -O -e FAIL check
68 count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
69 test -f test-suite.log
70 cat test-suite.log
71 test $(grep -c '^FAIL:' test-suite.log) -eq 1
72 test $(grep -c '^ERROR:' test-suite.log) -eq 1
73 $EGREP '^(X?PASS|XFAIL|SKIP)' test-suite.log && exit 1
74 test -f baz.log
75 test -f bar.log
76 test -f foo.log
78 $MAKE clean
79 test ! -e baz.log
80 test ! -e bar.log
81 test ! -e foo.log
82 test ! -e test-suite.log
84 # Check dependencies: baz.test needs to run before bar.test,
85 # but foo.test is not needed.
86 # Note that this usage has a problem: the summary will only
87 # take bar.log into account, because the $(TEST_SUITE_LOG) rule
88 # does not "see" baz.log. Hmm.
89 run_make -O -e FAIL TESTS='bar.test' check
90 grep '^FAIL: baz\.test$' stdout
91 grep '^ERROR: bar\.test$' stdout
93 test -f baz.log
94 test -f bar.log
95 test ! -e foo.log
96 test -f test-suite.log
98 # Upon a lazy rerun, foo.test should be run, but the others shouldn't.
99 # Note that the lazy rerun still exits with a failure, due to the previous
100 # test failures.
101 # Note that the previous test and this one taken together expose the timing
102 # issue that requires the check-TESTS rule to always remove TEST_SUITE_LOG
103 # before running the tests lazily.
104 run_make -O -e FAIL check RECHECK_LOGS=
105 test -f foo.log
106 grep '^PASS: foo\.test$' stdout
107 grep bar.test stdout && exit 1
108 grep baz.test stdout && exit 1
109 grep '^# PASS: *1$' stdout
110 grep '^# FAIL: *1$' stdout
111 grep '^# ERROR: *1$' stdout
113 # Now, explicitly retry with all test logs already updated, and ensure
114 # that the summary is still displayed.
115 run_make -O -e FAIL check RECHECK_LOGS=
116 grep foo.test stdout && exit 1
117 grep bar.test stdout && exit 1
118 grep baz.test stdout && exit 1
119 grep '^# PASS: *1$' stdout
120 grep '^# FAIL: *1$' stdout
121 grep '^# ERROR: *1$' stdout
123 # Lazily rerunning only foo should only rerun this one test.
124 run_make -O -e FAIL check RECHECK_LOGS=foo.log
125 grep foo.test stdout
126 grep bar.test stdout && exit 1
127 grep baz.test stdout && exit 1
128 grep '^# PASS: *1$' stdout
129 grep '^# FAIL: *1$' stdout
130 grep '^# ERROR: *1$' stdout
132 $MAKE clean
133 run_make -O -e FAIL TEST_LOGS=baz.log check
134 grep foo.test stdout && exit 1
135 grep bar.test stdout && exit 1
136 grep baz.test stdout
138 $MAKE clean
139 run_make -O -e FAIL TESTS=baz.test check
140 grep foo.test stdout && exit 1
141 grep bar.test stdout && exit 1
142 grep baz.test stdout