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