test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / test-driver-cond.sh
blob935a8251120cc0067f9fa3eb80be3e80667c8e0b
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 # parallel-tests:
18 # - Automake can correctly handle conditionals contents for the
19 # LOG_DRIVER variables.
21 . test-init.sh
23 cp "$am_testaux_srcdir"/trivial-test-driver . \
24 || fatal_ "failed to fetch auxiliary script trivial-test-driver"
25 cp "$am_scriptdir"/tap-driver.sh . \
26 || fatal_ "failed to fetch auxiliary script tap-driver.sh"
28 cat >> configure.ac << END
29 AM_CONDITIONAL([COND1], [:])
30 AM_CONDITIONAL([COND2], [false])
31 AM_CONDITIONAL([COND3], [false])
32 AC_SUBST([PERL], ['$PERL'])
33 AC_SUBST([my_LOG_DRIVER], ['\${SHELL} \${top_srcdir}/trivial-test-driver'])
34 AM_SUBST_NOTMAKE([my_LOG_DRIVER])
35 AC_OUTPUT
36 END
38 $ACLOCAL
39 $AUTOCONF
41 cat > Makefile.am << 'END'
42 TESTS = foo bar.test baz.sh
43 EXTRA_DIST = $(TESTS) tap-driver.sh trivial-test-driver
44 TEST_EXTENSIONS = .test .sh
45 LOG_DRIVER =
46 SH_LOG_DRIVER = $(tap_rulez)
47 if COND1
48 LOG_DRIVER += @my_LOG_DRIVER@
49 if COND2
50 tap_rulez = false
51 else !COND2
52 tap_rulez = $(PERL) $(srcdir)/tap-driver.sh
53 endif !COND2
54 endif COND1
55 END
57 cat > foo <<'END'
58 #!/bin/sh
59 echo "PASS: from $0"
60 echo "SKIP: from $0"
61 exit 1 # exit status should be ignored by the trivial-test-driver.
62 END
64 cat > bar.test <<'END'
65 #!/bin/sh
66 exit 0
67 END
69 cat > baz.sh <<'END'
70 #!/bin/sh
71 echo 1..3
72 echo 'ok 1'
73 echo 'not ok 2 # TODO'
74 echo 'not ok 3 # TODO'
75 END
77 chmod a+x foo bar.test baz.sh
79 $AUTOMAKE -a
80 test -f test-driver
82 grep DRIVER Makefile.in || exit 99 # For debugging.
84 grep '^my_LOG_DRIVER *=' Makefile.in \
85 && fatal_ 'unexpected $(my_LOG_DRIVER) in Makefile.in'
87 grep '^TEST_LOG_DRIVER =.*\$(SHELL).*/test-driver' Makefile.in
89 $PERL -MTAP::Parser -e 1 \
90 || skip_ "cannot import TAP::Parser perl module"
92 ./configure
94 do_count ()
96 count_test_results total=6 pass=3 fail=0 skip=1 xfail=2 xpass=0 error=0
97 grep '^PASS: foo, testcase 1 *$' stdout
98 grep '^SKIP: foo, testcase 2 *$' stdout
99 grep '^PASS: bar\.test *$' stdout
100 $EGREP 'PASS: baz\.sh 1( |$)' stdout
101 $EGREP 'XFAIL: baz\.sh 2( |$)' stdout
102 $EGREP 'XFAIL: baz\.sh 3( |$)' stdout
105 run_make -O -e IGNORE check
106 cat test-suite.log
107 cat foo.log
108 cat bar.log
109 cat baz.log
110 test $am_make_rc -eq 0 || exit 1
111 do_count
113 run_make -O distcheck
114 do_count