test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / distcleancheck.sh
1 #! /bin/sh
2 # Copyright (C) 2008-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 # Make sure the suggested 'distcleancheck_listfiles' in the manual works.
18 # The example Makefile.am we use is from the FAQ entry 'distcleancheck'.
19
20 required=cc
21 . test-init.sh
22
23 cat >>configure.ac << 'END'
24 AC_PROG_CC
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 # This Makefile.am is bogus.  See @node{distcleancheck} in the manual
30 # for how to fix it properly.
31 bin_PROGRAMS = foo
32 foo_SOURCES = foo.c
33 dist_man_MANS = foo.1
34
35 # We write './foo.1' inside the rule on purpose, to avoid VPATH rewriting
36 # done by some 'make' implementations.
37 foo.1: foo$(EXEEXT)
38         echo man page for foo$(EXEEXT) > ./foo.1
39
40 ## Ignore warnings about overridden variables
41 AUTOMAKE_OPTIONS = -Wno-override
42 distcleancheck_listfiles = \
43   find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \
44        sh '{}' ';'
45 END
46
47 cat >foo.c <<'END'
48 int main () { return 0; }
49 END
50
51 $ACLOCAL
52 $AUTOCONF
53 $AUTOMAKE
54
55 ./configure
56 $MAKE
57 $MAKE distcheck
58
59 # Now ensure that we really needed the override.
60 sed '/distcleancheck_listfiles/,$d' Makefile.am > t
61 mv -f t Makefile.am
62 $AUTOMAKE
63 ./configure
64 $MAKE
65 run_make -E -e FAIL distcheck
66 grep 'ERROR:.*files left in build directory after distclean' stderr
67 grep '^\./foo\.1$' stderr
68
69 :