automake: require ABOUT-NLS only at gnits strictness.
[automake.git] / t / parallel-tests-extra-programs.sh
blob2e06664e4e5e003e4d0ab1ba3d61ad19ea38be2c
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 test harness: check that $(TESTS) can lazily depend on
18 # (or even be) $(EXTRA_PROGRAMS).
20 required='cc native'
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_OUTPUT
26 END
28 # Will be extended later.
29 cat > Makefile.am << 'END'
30 TEST_EXTENSIONS = .bin .test
31 EXTRA_PROGRAMS =
32 TESTS =
33 END
36 # Now try various kinds of test dependencies ...
39 # 1. A program that is also a test, and whose source files
40 # already exist.
42 cat >> Makefile.am <<'END'
43 EXTRA_PROGRAMS += foo.bin
44 TESTS += foo.bin
45 foo_bin_SOURCES = foo.c
46 END
48 cat > foo.c <<'END'
49 #include <stdio.h>
50 int main (void)
52 printf ("foofoofoo\n");
53 return 0;
55 END
57 # 2. A program that is also a test, and whose source files
58 # are buildable by make.
59 cat >> Makefile.am <<'END'
60 EXTRA_PROGRAMS += bar.bin
61 TESTS += bar.bin
62 bar_bin_SOURCES = bar.c
63 bar.c: foo.c
64 sed -e 's/foofoofoo/barbarbar/' foo.c > $@
65 END
67 # 3. A test script that already exists, whose execution depends
68 # on a program whose source files already exist and which is
69 # not itself a test.
70 cat >> Makefile.am <<'END'
71 EXTRA_PROGRAMS += y
72 TESTS += baz.test
73 baz.log: y$(EXEEXT)
74 END
76 cat > baz.test <<'END'
77 #!/bin/sh
78 $srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
79 END
80 chmod a+x baz.test
82 cat > y.c <<'END'
83 #include <stdio.h>
84 int main (void)
86 printf ("y\n");
87 return 0;
89 END
91 # 4. A program that is also a test, but whose source files
92 # do not exit and are not buildable by make.
94 cat >> Makefile.am <<'END'
95 EXTRA_PROGRAMS += none.bin
96 TESTS += none.bin
97 none_bin_SOURCES = none.c
98 END
101 # Setup done, go with the tests.
104 $ACLOCAL
105 $AUTOCONF
106 $AUTOMAKE -a
108 ./configure
110 # What we check now:
111 # 1. even if we cannot build the 'none.bin' program, all the other
112 # test programs should be built, and all the other tests should
113 # be run;
114 # 2. still, since we cannot create the 'none.log' file, the
115 # 'test-suite.log' file shouldn't be created (as it depends
116 # on *all* the test logs).
118 run_make -E -O -e IGNORE -- -k check
119 ls -l
120 if using_gmake; then
121 test $am_make_rc -gt 0 || exit 1
122 else
123 # Don't trust exit status of "make -k" for non-GNU make.
124 $MAKE check && exit 1
125 : For shells with busted 'set -e'.
128 # Files that should have been created, with the expected content.
129 cat bar.c
130 grep foofoofoo foo.log
131 grep barbarbar bar.log
132 grep yepyepyep baz.log
133 # Files that shouldn't have been created.
134 test ! -e none.log
135 test ! -e test-suite.log
136 # Expected testsuite progress output.
137 grep '^PASS: baz\.test$' stdout
138 # Don't anchor the end of the next two patterns, to allow for non-empty
139 # $(EXEEXT).
140 grep '^PASS: foo\.bin' stdout
141 grep '^PASS: bar\.bin' stdout
142 # Expected error messages from make. Some make implementations (e.g.,
143 # FreeBSD make) seem to print the error on stdout instead, so check for
144 # it there as well.
145 $EGREP 'none\.(bin|o|c)' stderr stdout
147 # What we check now:
148 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
149 # pass;
150 # 2. on a lazy re-run, the passed tests are not re-run, and
151 # 3. their log files are not updated or touched.
153 : > stamp
154 $sleep
156 echo 'int main (void) { return 0; }' > none.c
158 run_make -O -e IGNORE check RECHECK_LOGS=
159 ls -l # For debugging.
160 test $am_make_rc -eq 0 || exit 1
162 # For debugging.
163 stat stamp foo.log bar.log baz.log || :
165 # Files that shouldn't have been updated or otherwise touched.
166 is_newest stamp foo.log bar.log baz.log
167 # Files that should have been created now.
168 test -f none.log
169 test -f test-suite.log
170 # Tests that shouldn't have been re-run.
171 $EGREP '(foo|bar)\.bin|baz\.test$' stdout && exit 1
172 # Tests that should have been run. Again, we don't anchor the end
173 # of the next pattern, to allow for non-empty $(EXEEXT).
174 grep '^PASS: none\.bin' stdout