tests: expose automake bug#14560
[platform/upstream/automake.git] / t / test-driver-is-distributed.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 regression of parallel-tests:
18 #  - 'test-driver' script not correctly distributed when TESTS is
19 #    defined in a subdir Makefile
20
21 am_create_testdir=empty
22 . test-init.sh
23
24 ocwd=$(pwd) || fatal_ "getting current working directory"
25
26 for i in 1 2; do
27   mkdir D$i
28   cd D$i
29   if test $i -eq 1; then
30     auxdir=.
31     test_driver=test-driver
32   else
33     auxdir=build-aux
34     test_driver=$auxdir/test-driver
35     mkdir $auxdir
36   fi
37   mkdir tests
38   unindent > configure.ac << END
39     AC_INIT([$me], [1.0])
40     AC_CONFIG_AUX_DIR([$auxdir])
41     AM_INIT_AUTOMAKE
42     AC_CONFIG_FILES([Makefile tests/Makefile])
43     AC_OUTPUT
44 END
45   unindent > Makefile.am << END
46     SUBDIRS = tests
47     check-local: test-top
48     test-top: distdir
49         ls -l \$(distdir) \$(distdir)/* ;: For debugging.
50         test -f \$(distdir)/$test_driver
51     .PHONY: test-top
52 END
53   unindent > tests/Makefile.am << END
54     check-local: test-sub
55     test-sub:
56         echo ' ' \$(DIST_COMMON) ' ' | grep '[ /]$test_driver '
57     TESTS = foo.test
58     EXTRA_DIST = \$(TESTS)
59 END
60   unindent > tests/foo.test << 'END'
61     #!/bin/sh
62     exit 0
63 END
64   chmod a+x tests/foo.test
65   $ACLOCAL
66   $AUTOCONF
67   $AUTOMAKE -a
68   ./configure
69   $MAKE test-top
70   cd tests
71   $MAKE test-sub
72   cd ..
73   $MAKE distcheck
74   # Try code path without automatic installation of required files.
75   mv -f Makefile.in Makefile.sav
76   mv -f tests/Makefile.in tests/Makefile.sav
77   $AUTOMAKE
78   diff Makefile.in Makefile.sav
79   diff tests/Makefile.in tests/Makefile.sav
80   cd "$ocwd" || fatal_ "cannot chdir back to '$ocwd'"
81 done
82
83 :