doc: update Vala documentation
[automake.git] / t / test-driver-custom-multitest.sh
blob09fdae72c294216f1921adb8423a1a59d4ca2931
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: check that we can easily support test protocols
18 # that allow multiple testcases in a single test script. This test not
19 # only checks implementation details in Automake's custom test drivers
20 # support, but also serves as a "usability test" for our APIs.
22 . test-init.sh
24 cp "$am_testaux_srcdir"/trivial-test-driver . \
25 || fatal_ "failed to fetch auxiliary script trivial-test-driver"
27 cat >> configure.ac << 'END'
28 AC_OUTPUT
29 END
31 cat > Makefile.am << 'END'
32 TEST_EXTENSIONS = .t
33 T_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
35 TESTS = \
36 pass.t \
37 fail.t \
38 fail2.t \
39 pass-fail.t \
40 pass4-skip.t \
41 pass3-skip2-xfail.t \
42 pass-xpass-fail-xfail-skip-error.t
43 END
45 cat > pass.t << 'END'
46 echo %% pass %%
47 echo PASS: pass
48 END
50 cat > fail.t << 'END'
51 echo %% fail %%
52 echo FAIL: fail
53 END
55 cat > fail2.t << 'END'
56 echo %% fail2 %%
57 echo FAIL: stdout >&1
58 echo FAIL: stderr >&2
59 echo :PASS: this should be ignored
60 END
62 cat > pass-fail.t << 'END'
63 echo %% pass-fail %%
64 echo 'FAIL: this fails :-('
65 echo 'some random message'
66 echo 'some random warning' >&2
67 echo 'PASS: this passes :-)'
68 echo 'INFO: blah'
69 echo 'WARNING: blah blah' >&2
70 END
72 cat > pass4-skip.t << 'END'
73 echo %% pass4-skip %%
74 echo PASS: on stdout >&1
75 echo PASS: on stderr >&2
76 echo PASS: 3
77 echo PASS: 4
78 echo SKIP: 1
79 echo this FAIL: should be ignored
80 echo FAIL as should this
81 exit 99
82 END
84 cat > pass3-skip2-xfail.t << 'END'
85 echo %% pass4-skip2-xfail %%
86 echo 'PASS: -v'
87 echo 'PASS: --verbose'
88 echo 'SKIP: Oops, unsupported system.'
89 echo 'PASS: -#-#-#-'
90 cp || echo "SKIP: cp cannot read users' mind" >&2
91 mv || echo "XFAIL: mv cannot read users' mind yet"
92 exit 127
93 END
95 cat > pass-xpass-fail-xfail-skip-error.t << 'END'
96 echo PASS:
97 echo FAIL:
98 echo XFAIL:
99 echo XPASS:
100 echo SKIP:
101 echo ERROR:
102 echo %% pass-xpass-fail-xfail-skip-error %%
105 chmod a+x *.t
107 $ACLOCAL
108 $AUTOCONF
109 $AUTOMAKE
111 for vpath in : false; do
112 if $vpath; then
113 mkdir build
114 cd build
115 srcdir=..
116 else
117 srcdir=.
120 $srcdir/configure
122 run_make -O -e FAIL check || { cat test-suite.log; exit 1; }
123 cat test-suite.log
124 # Couple of sanity checks. These might need to be updated if the
125 # 'trivial-test-driver' script is changed.
126 $FGREP INVALID.NAME stdout test-suite.log && exit 1
127 test -f BAD.LOG && exit 1
128 test -f BAD.TRS && exit 1
129 # These log files must all have been created by the testsuite.
130 cat pass.log
131 cat fail.log
132 cat fail2.log
133 cat pass-fail.log
134 cat pass4-skip.log
135 cat pass3-skip2-xfail.log
136 cat pass-xpass-fail-xfail-skip-error.log
138 count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1
140 tst=pass-xpass-fail-xfail-skip-error
141 grep "^PASS: $tst\.t, testcase 1" stdout
142 grep "^FAIL: $tst\.t, testcase 2" stdout
143 grep "^XFAIL: $tst\.t, testcase 3" stdout
144 grep "^XPASS: $tst\.t, testcase 4" stdout
145 grep "^SKIP: $tst\.t, testcase 5" stdout
146 grep "^ERROR: $tst\.t, testcase 6" stdout
148 # Check that the content of, and only of, the test logs with at least
149 # one failing test case has been copied into 'test-suite.log'. Note
150 # that test logs containing skipped or xfailed test cases are *not*
151 # copied into 'test-suite.log' -- a behaviour that deliberately differs
152 # from the one of the built-in Automake test drivers.
153 grep '%%' test-suite.log # For debugging.
154 grep '%% fail %%' test-suite.log
155 grep '%% fail2 %%' test-suite.log
156 grep '%% pass-fail %%' test-suite.log
157 grep '%% pass-xpass-fail-xfail-skip-error %%' test-suite.log
158 test $(grep -c '%% ' test-suite.log) -eq 4
160 run_make -O TESTS='pass.t pass3-skip2-xfail.t' check
161 cat test-suite.log
162 count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0
164 cd $srcdir
166 done