tests: work around strangeness in MSYS
[automake.git] / tests / parallel-tests-extra-programs.test
blob51d6ef36acf87c46053874a7bb5101544a8376f6
1 #! /bin/sh
2 # Copyright (C) 2011 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 <http://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 am_parallel_tests=yes
22 . ./defs || Exit 1
24 cat >> configure.in << 'END'
25 AC_PROG_CC
26 AC_OUTPUT
27 END
29 # Will be extended later.
30 cat > Makefile.am << 'END'
31 TEST_EXTENSIONS = .bin .test
32 EXTRA_PROGRAMS =
33 TESTS =
34 END
37 # Now try various kinds of test dependencies ...
40 # 1. A program that is also a test, and whose source files
41 # already exist.
43 cat >> Makefile.am <<'END'
44 EXTRA_PROGRAMS += foo.bin
45 TESTS += foo.bin
46 foo_bin_SOURCES = foo.c
47 END
49 cat > foo.c <<'END'
50 #include <stdio.h>
51 int main (void)
53 printf ("foofoofoo\n");
54 return 0;
56 END
58 # 2. A program that is also a test, and whose source files
59 # are buildable by make.
60 cat >> Makefile.am <<'END'
61 EXTRA_PROGRAMS += bar.bin
62 TESTS += bar.bin
63 bar_bin_SOURCES = bar.c
64 bar.c: foo.c
65 sed -e 's/foofoofoo/barbarbar/' foo.c > $@
66 END
68 # 3. A test script that already exists, whose execution depends
69 # on a program whose source files already exist and which is
70 # not itself a test.
71 cat >> Makefile.am <<'END'
72 EXTRA_PROGRAMS += y
73 TESTS += baz.test
74 baz.log: y$(EXEEXT)
75 END
77 cat > baz.test <<'END'
78 #!/bin/sh
79 $srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
80 END
81 chmod a+x baz.test
83 cat > y.c <<'END'
84 #include <stdio.h>
85 int main (void)
87 printf ("y\n");
88 return 0;
90 END
92 # 4. A program that is also a test, but whose source files
93 # do not exit and are not buildable by make.
95 cat >> Makefile.am <<'END'
96 EXTRA_PROGRAMS += none.bin
97 TESTS += none.bin
98 none_bin_SOURCES = none.c
99 END
102 # Setup done, go with the tests.
105 $ACLOCAL
106 $AUTOCONF
107 $AUTOMAKE -a
109 ./configure
111 # What we check now:
112 # 1. even if we cannot build the `none.bin' program, all the other
113 # test programs should be built, and all the other tests should
114 # be run;
115 # 2. still, since we cannot create the `none.log' file, the
116 # `test-suite.log' file shouldn't be created (as it depends
117 # on *all* the test logs).
119 st=0
120 $MAKE check >stdout 2>stderr || st=$?
121 cat stdout
122 cat stderr >&2
123 ls -l
124 test $st -gt 0 || Exit 1
126 # Files that should have been created, with the expected content.
127 cat bar.c
128 grep foofoofoo foo.log
129 grep barbarbar bar.log
130 grep yepyepyep baz.log
131 # Files that shouldn't have been created.
132 test ! -f none.log
133 test ! -f test-suite.log
134 # Expected testsuite progress output.
135 grep '^PASS: baz\.test$' stdout
136 # Don't anchor the end of the next two patterns, to allow for non-empty
137 # $(EXEEXT).
138 grep '^PASS: foo\.bin' stdout
139 grep '^PASS: bar\.bin' stdout
140 # Expected error messages from make.
141 $EGREP 'none\.(bin|o|c)' stderr
143 # What we check now:
144 # 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
145 # pass;
146 # 2. on a lazy re-run, the passed tests are not re-run, and
147 # 3. their log files are not updated or touched.
149 : > stamp
150 $sleep
152 echo 'int main (void) { return 0; }' > none.c
154 st=0
155 RECHECK_LOGS= $MAKE -e check >stdout || st=$?
156 cat stdout
157 ls -l
158 test $st -eq 0 || Exit 1
160 # For debugging.
161 stat stamp foo.log bar.log baz.log || :
163 # Files that shouldn't have been updated or otherwise touched.
164 is_newest stamp foo.log bar.log baz.log
165 # Files that should have been created now.
166 test -f none.log
167 test -f test-suite.log
168 # Tests that shouldn't have been re-run.
169 $EGREP '(foo|bar)\.bin|baz\.test$' stdout && Exit 1
170 # Tests that should have been run. Again, we don't anchor the end
171 # of the next pattern, to allow for non-empty $(EXEEXT).
172 grep '^PASS: none\.bin' stdout