tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / dist-missing-am.sh
blob80254c49a407767530be1ff228617a16b38b5b5e
1 #! /bin/sh
2 # Copyright (C) 2011-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 # The stub rules emitted to work around the "deleted header problem"
18 # for '.am' files shouldn't prevent "make" from diagnosing a missing
19 # required '.am' file from a distribution tarball.
20 # See discussion about automake bug#9768.
22 . ./defs || exit 1
24 echo AC_OUTPUT >> configure.ac
26 cat > Makefile.am <<'END'
27 include $(srcdir)/foobar.am
28 include $(srcdir)/zardoz.am
29 END
31 : > foobar.am
32 : > zardoz.am
34 $ACLOCAL
35 $AUTOCONF
36 $AUTOMAKE
38 ./configure
40 # A faulty distribution tarball, with a required '.am' file missing.
41 # Building from it should fail, both for in-tree and VPATH builds.
42 ocwd=$(pwd) || fatal_ "cannot get current working directory"
43 for vpath in false :; do
44 $MAKE distdir
45 test -f $distdir/zardoz.am # Sanity check.
46 rm -f $distdir/zardoz.am
47 if $vpath; then
48 # We can't just build in a subdirectory of $distdir, otherwise
49 # we'll hit automake bug#10111.
50 mkdir vpath-distcheck
51 cd vpath-distcheck
52 ../$distdir/configure
53 else
54 cd $distdir
55 ./configure
57 $MAKE >output 2>&1 && { cat output; exit 1; }
58 cat output
59 # This error comes from automake, not make, so we can be stricter
60 # in our grepping of it.
61 grep 'cannot open.*zardoz\.am' output
62 grep 'foobar\.am' output && exit 1 # No spurious error, please.
63 cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
64 done