tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / parallel-tests-log-compiler-1.sh
1 #! /bin/sh
2 # Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Check parallel-tests features:
18 # - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
19 #   and xxx_LOG_FLAGS), also with AC_SUBST'd stuff.
20 # See also related test 'parallel-tests-log-compiler-2.sh'.
21
22 . test-init.sh
23
24 cat >> configure.ac << 'END'
25 AC_SUBST([acsubst_compiler], [t-compiler])
26 AC_CONFIG_LINKS([chk-compiler:chk-compiler])
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 # Note that automake should not match the '/test' part of 'sub/test'
32 # as '.test' suffix.
33 TESTS = foo.chk bar.test baz bla.t bli.suff sub/test
34
35 TEST_EXTENSIONS = .chk .test .t
36
37 CHK_LOG_COMPILER = ./chk-compiler
38 TEST_LOG_COMPILER = $(SHELL) $(srcdir)/test-compiler
39 T_LOG_COMPILER = @acsubst_compiler@
40 LOG_COMPILER = @SHELL@ -x $(srcdir)/noext-compiler
41
42 CHK_LOG_FLAGS = --chk
43
44 AM_TEST_LOG_FLAGS = --am-test
45
46 T_LOG_FLAGS = --t
47 AM_T_LOG_FLAGS = --am-t
48
49 AM_LOG_FLAGS = -a
50 LOG_FLAGS = -b
51
52 # 't-compiler' is deliberately not distributed; it should be available
53 # in PATH also from "make distcheck".
54 EXTRA_DIST = $(TESTS) chk-compiler test-compiler noext-compiler
55 END
56
57 mkdir sub
58
59 cat > chk-compiler <<'END'
60 #! /bin/sh
61 test x"$1" = x"--chk" || {
62   echo "$0: invalid command line: $*" >&2
63   exit 1
64 }
65 shift
66 exec "$@"
67 exit 127
68 END
69 sed 's/--chk/--am-test/' chk-compiler > test-compiler
70
71 mkdir bin
72 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
73
74 cat > bin/t-compiler <<'END'
75 #! /bin/sh
76 if test x"$1,$2" != x"--am-t,--t"; then
77   echo "$0: invalid command line: $*" >&2
78   exit 1
79 fi
80 shift; shift
81 exec "$@"
82 exit 127
83 END
84 sed 's/--am-t,--t/-a,-b/' bin/t-compiler > noext-compiler
85
86 chmod a+x chk-compiler chk-compiler test-compiler bin/t-compiler noext-compiler
87
88 cat >foo.chk << 'END'
89 #! /bin/sh
90 exit 0
91 END
92 chmod a+x foo.chk
93 cp foo.chk bar.test
94 cp foo.chk baz
95 cp foo.chk bla.t
96 cp foo.chk bli.suff
97 cp foo.chk sub/test
98
99 $ACLOCAL
100 $AUTOCONF
101 $AUTOMAKE -a
102
103 ./configure
104 $MAKE check || { cat test-suite.log; exit 1; }
105 ls -l . sub
106 cat test-suite.log
107 test -f foo.log
108 test -f bar.log
109 test -f baz.log
110 test -f bla.log
111 test -f bli.suff.log
112 test -f sub/test.log
113
114 run_make -e FAIL T_LOG_FLAGS=--bad check
115 cat test-suite.log
116 cat bla.log
117 # With the above flag overridden, bla.t should fail ...
118 $EGREP '(^ *|/)t-compiler:.* invalid .*--bad' bla.log
119 # ... but no other test should.
120 grep -v '^FAIL: bla\.t ' bla.log | grep 'FAIL:' && exit 1
121
122 # Try also with a VPATH build.
123 $MAKE distcheck
124
125 :