Merge branch master into maint after 1.12 release
[platform/upstream/automake.git] / t / test-trs-basic.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 harness features:
18 #  - creation and removal of '.trs' auxiliary files
19 #  - check some internals regarding the use of '.trs' files.
20
21 am_parallel_tests=yes
22 . ./defs || Exit 1
23
24 cat >> configure.ac <<END
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 TEST_EXTENSIONS = .sh .test
30 TESTS = foo.test bar.sh sub/zardoz.test
31 TEST_LOG_COMPILER = $(SHELL)
32 SH_LOG_COMPILER = $(SHELL)
33
34 ## Used to check some internal details.  And yes, the quotes around
35 ## '$bases' are deliberate: they check for whitespace normalization.
36 tb:
37         $(am__set_TESTS_bases); echo "$$bases" > $@
38 END
39
40 cat > foo.test << 'END'
41 #! /bin/sh
42 exit $FOO_STATUS
43 END
44 : > bar.sh
45 mkdir sub
46 : > sub/zardoz.test
47
48 FOO_STATUS=0; export FOO_STATUS
49
50 $ACLOCAL
51 $AUTOCONF
52 $AUTOMAKE -a
53
54
55 #
56 # Check some internal details first.
57 #
58
59 for vpath in : false; do
60
61   if $vpath; then
62     srcdir=..
63     mkdir build
64     cd build
65   else
66     srcdir=.
67   fi
68
69   $srcdir/configure
70
71   $MAKE tb
72   test x"`cat tb`" = x"foo bar sub/zardoz"
73   rm -f tb
74   # Please don't change the order of the stuff in TESTS, below.
75   TESTS='foo.test foo2.sh foo-log foolog.test a.log.b.sh 0.exe' $MAKE -e tb
76   test x"`cat tb`" = x"foo foo2 foo-log foolog a.log.b 0.exe"
77   rm -f tb
78
79   cd $srcdir
80
81 done
82
83 #
84 # The 'test-suite.stamp' file and the '.trs' files get created by
85 # "make check" and removed by "make clean" and "make mostlyclean".
86 #
87
88 : > unrelated.trs
89 : > sub/foo.trs
90
91 $MAKE check
92 test -f foo.trs
93 test -f bar.trs
94 test -f sub/zardoz.trs
95 $MAKE clean
96 test ! -f foo.trs
97 test ! -f bar.trs
98 test ! -f sub/zardoz.trs
99 # Unrelated '.trs' files shouldn't be removed.
100 test -f unrelated.trs
101 test -f sub/foo.trs
102
103 # The files should be properly created in case of testsuite failure too.
104 FOO_STATUS=1 $MAKE check && Exit 1
105 test -f foo.trs
106 test -f bar.trs
107 test -f sub/zardoz.trs
108 $MAKE mostlyclean
109 test ! -f foo.trs
110 test ! -f bar.trs
111 test ! -f sub/zardoz.trs
112 # Unrelated '.trs' files shouldn't be removed.
113 test -f unrelated.trs
114 test -f sub/foo.trs
115
116 #
117 # Try with a subset of TESTS.
118 #
119
120 TESTS=foo.test $MAKE -e check
121 test -f foo.trs
122 test ! -f bar.trs
123 test ! -f sub/zardoz.trs
124 $MAKE clean
125 test ! -f foo.trs
126 TESTS='foo.test bar.sh' $MAKE -e check
127 test -f foo.trs
128 test -f bar.trs
129 test ! -f sub/zardoz.trs
130 # "make clean" shouldn't remove '.trs' files for tests not in $(TESTS).
131 TESTS=bar.sh $MAKE -e clean
132 test -f foo.trs
133 test ! -f bar.trs
134
135 $MAKE clean
136
137 #
138 # Try with a subset of TEST_LOGS.
139 #
140
141 TEST_LOGS=sub/zardoz.log $MAKE -e check
142 test ! -f foo.trs
143 test ! -f bar.trs
144 test -f sub/zardoz.trs
145 $MAKE clean
146 test ! -f sub/zardoz.trs
147 TEST_LOGS='foo.log bar.log' $MAKE -e check
148 test -f foo.trs
149 test -f bar.trs
150 test ! -f sub/zardoz.trs
151 # "make clean" shouldn't remove '.trs' files for tests whose log
152 # is not in $(TEST_LOGS).
153 TEST_LOGS=foo.log $MAKE -e clean
154 test ! -f foo.trs
155 test -f bar.trs
156 test ! -f sub/zardoz.trs
157
158 :