tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / check3.sh
blob64a4512669b6d473cd94bc10a4c1d21d084f7e14
1 #! /bin/sh
2 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Make sure 'check:' and 'install:' honor $(BUILT_SOURCES).
18 # PR/359.
20 # For gen-testsuite-part: ==> try-with-serial-tests <==
21 . ./defs || exit 1
23 cat >> configure.ac << 'END'
24 AC_CONFIG_FILES([dir/Makefile])
25 AC_OUTPUT
26 END
28 mkdir dir
30 cat > Makefile.am << 'END'
31 BUILT_SOURCES = command1.inc
32 SUBDIRS = dir
33 TESTS = subrun.sh
34 subrun.sh:
35 (echo '#! /bin/sh'; cat command1.inc) > $@
36 chmod +x $@
37 command1.inc:
38 echo 'dir/echo.sh' > $@
39 CLEANFILES = subrun.sh command1.inc
40 END
42 cat > dir/Makefile.am << 'END'
43 BUILT_SOURCES = command2.inc
44 check_SCRIPTS = echo.sh
45 echo.sh:
46 ## The next line ensures that command1.inc has been built before
47 ## recurring into the subdir.
48 test -f ../command1.inc
49 (echo '#! /bin/sh'; cat command2.inc) > $@
50 chmod +x $@
51 command2.inc:
52 echo 'echo Hello' > $@
53 CLEANFILES = echo.sh command2.inc
54 END
56 $ACLOCAL
57 $AUTOCONF
58 $AUTOMAKE -a
59 ./configure --prefix "$(pwd)/inst"
61 $MAKE check >stdout || { cat stdout; exit 1; }
62 cat stdout
63 grep '^PASS: subrun\.sh *$' stdout
64 grep 'PASS.*echo\.sh' stdout && exit 1
66 # check should depend directly on $(BUILT_SOURCES) (similar tests
67 # are in check.test and check2.test).
68 $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
69 $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
71 $MAKE clean
72 # Sanity checks
73 test ! -e command1.inc
74 test ! -e dir/command2.inc
75 # Now make sure these two files are rebuilt during make install.
76 $MAKE install
77 test -f command1.inc
78 test -f dir/command2.inc