Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / check-tests-in-builddir.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 set -e
23
24 cat >> configure.in << 'END'
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 TESTS = foo.test bar.test
30 EXTRA_DIST = $(TESTS)
31 END
32
33 cat > foo.test << 'END'
34 #! /bin/sh
35 exit ${FOO_EXIT_STATUS-0}
36 END
37 chmod a+x foo.test
38
39 unset FOO_EXIT_STATUS || :
40
41 $ACLOCAL
42 $AUTOCONF
43 $AUTOMAKE -a
44
45 mkdir build
46 cd build
47
48 ../configure
49
50 cat > bar.test << 'END'
51 #! /bin/sh
52 exit 0
53 END
54 chmod a+x bar.test
55
56 $MAKE check >out 2>&1 || { cat out; Exit1; }
57 cat out
58 # The simple-tests driver does not strip VPATH components from
59 # the name of the test, but the parallel-tests driver should.
60 if test x"$parallel_tests" = x"yes"; then
61   grep '\.\./foo' out && Exit 1
62   grep '^PASS: foo.test *$' out
63 else
64   grep '^PASS: .*foo.test *$' out
65 fi
66 grep '^PASS: bar.test *$' out
67
68 rm -f test-suite.log foo.log bar.log
69
70 FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 && { cat out; Exit1; }
71 cat out
72 # See comments above.
73 if test x"$parallel_tests" = x"yes"; then
74   grep '\.\./foo' out && Exit 1
75   grep '^FAIL: foo.test *$' out
76 else
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; Exit1; }
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 :