Merge branch 'maint'
[platform/upstream/automake.git] / t / test-driver-is-distributed.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 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 am_parallel_tests=yes
23 . ./defs || Exit 1
24
25 ocwd=`pwd` || fatal_ "getting current working directory"
26
27 do_check ()
28 {
29   whereopts=$1 auxdir=$2
30   case $#,$whereopts in
31     2,ac) ac_opts=parallel-tests am_code= ;;
32     2,am) am_opts=parallel-tests ac_code= ;;
33        *) fatal_ "do_check: bad usage";;
34   esac
35   mkdir $whereopts
36   cd $whereopts
37   mkdir tests
38   unindent > configure.ac << END
39     AC_INIT([$me], [1.0])
40     AC_CONFIG_AUX_DIR([$auxdir])
41     AM_INIT_AUTOMAKE([$ac_opts])
42     AC_CONFIG_FILES([Makefile tests/Makefile])
43     AC_OUTPUT
44 END
45   if test $auxdir = .; then
46     test_driver=test-driver
47   else
48     mkdir $auxdir
49     test_driver=$auxdir/test-driver
50   fi
51   # No 'AUTOMAKE_OPTIONS' in here -- purposely.
52   unindent > Makefile.am << END
53     SUBDIRS = tests
54     check-local: test-top
55     test-top: distdir
56         ls -l \$(distdir) \$(distdir)/* ;: For debugging.
57         test -f \$(distdir)/$test_driver
58     .PHONY: test-top
59 END
60   unindent > tests/Makefile.am << END
61     AUTOMAKE_OPTIONS = $am_opts
62     check-local: test-sub
63     test-sub:
64         echo ' ' \$(DIST_COMMON) ' ' | grep '[ /]$test_driver '
65     TESTS = foo.test
66     EXTRA_DIST = \$(TESTS)
67 END
68   unindent > tests/foo.test << 'END'
69     #!/bin/sh
70     exit 0
71 END
72   chmod a+x tests/foo.test
73   $ACLOCAL
74   $AUTOCONF
75   $AUTOMAKE -a
76   ./configure
77   $MAKE test-top
78   cd tests
79   $MAKE test-sub
80   cd ..
81   $MAKE distcheck
82   # Try code path without automatic installation of required files.
83   mv -f Makefile.in Makefile.sav
84   mv -f tests/Makefile.in tests/Makefile.sav
85   $AUTOMAKE
86   diff Makefile.in Makefile.sav
87   diff tests/Makefile.in tests/Makefile.sav
88   :
89 }
90
91 do_check ac .
92 do_check am build-aux
93
94 :