Merge branch 'maint'
[platform/upstream/automake.git] / t / check-tests-in-builddir.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 that the testsuite driver can find test in the srcdir as
18 # well as in builddir, and that is prefers those in the builddir.
19
20 # For gen-testsuite-part: ==> try-with-serial-tests <==
21 . ./defs || exit 1
22
23 cat >> configure.ac << 'END'
24 AC_OUTPUT
25 END
26
27 cat > Makefile.am << 'END'
28 TESTS = foo.test bar.test
29 EXTRA_DIST = $(TESTS)
30 END
31
32 cat > foo.test << 'END'
33 #! /bin/sh
34 exit ${FOO_EXIT_STATUS-0}
35 END
36 chmod a+x foo.test
37
38 unset FOO_EXIT_STATUS || :
39
40 $ACLOCAL
41 $AUTOCONF
42 $AUTOMAKE -a
43
44 mkdir build
45 cd build
46
47 ../configure
48
49 cat > bar.test << 'END'
50 #! /bin/sh
51 exit 0
52 END
53 chmod a+x bar.test
54
55 $MAKE check >out 2>&1 || { cat out; exit 1; }
56 cat out
57 # The serial test driver does not strip VPATH components from
58 # the name of the test, but the parallel driver should.
59 if test x"$am_serial_tests" = x"yes"; then
60   grep '^PASS: .*foo\.test *$' out
61 else
62   grep '\.\./foo' out && exit 1
63   grep '^PASS: foo\.test *$' out
64 fi
65 grep '^PASS: bar\.test *$' out
66
67 rm -f test-suite.log foo.log bar.log
68
69 FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 && { cat out; exit 1; }
70 cat out
71 # The serial test driver does not strip VPATH components from
72 # the name of the test, but the parallel driver should.
73 if test x"$am_serial_tests" = x"yes"; then
74   grep '^FAIL: .*foo\.test *$' out
75 else
76   grep '\.\./foo' out && exit 1
77   grep '^FAIL: foo\.test *$' out
78 fi
79 grep '^PASS: bar\.test *$' out
80
81 rm -f test-suite.log foo.log bar.log
82
83 # Check that if the same test is present in srcdir and builddir,
84 # the one in builddir is preferred.
85 cp bar.test foo.test
86 FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 || { cat out; exit 1; }
87 cat out
88 grep '^PASS: foo\.test *$' out
89 grep '^PASS: bar\.test *$' out
90
91 # The tests in the builddir must be preferred also by "make dist".
92 FOO_EXIT_STATUS=1 $MAKE distcheck
93
94 :