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