test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / aclocal-install-fail.sh
1 #! /bin/sh
2 # Copyright (C) 2012-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 that "aclocal --install" fails when it should.
18 # FIXME: this is a good candidate for a conversion to TAP.
19
20 am_create_testdir=empty
21 required=ro-dir
22 . test-init.sh
23
24 cat > configure.ac <<END
25 AC_INIT([$me], [1.0])
26 MY_MACRO
27 END
28
29 mkdir sys-acdir
30 cat > sys-acdir/my-defs.m4 <<END
31 AC_DEFUN([MY_MACRO], [:])
32 END
33
34 ACLOCAL="$ACLOCAL -Wnone --system-acdir=sys-acdir"
35
36 : > a-regular-file
37 mkdir unwritable-dir
38 chmod a-w unwritable-dir
39
40 $ACLOCAL -I a-regular-file --install 2>stderr \
41   && { cat stderr >&2; exit 1; }
42 cat stderr >&2
43 $EGREP '(mkdir:|directory ).*a-regular-file' stderr
44 test ! -e aclocal.m4
45
46 $ACLOCAL --install -I unwritable-dir/sub 2>stderr \
47   && { cat stderr >&2; exit 1; }
48 cat stderr >&2
49 $EGREP '(mkdir:|directory ).*unwritable-dir/sub' stderr
50 test ! -e aclocal.m4
51
52 $ACLOCAL -I unwritable-dir --install 2>stderr \
53   && { cat stderr >&2; exit 1; }
54 cat stderr >&2
55 $EGREP '(cp:|copy ).*unwritable-dir' stderr
56 test ! -e aclocal.m4
57
58 # Sanity check.
59 mkdir m4
60 $ACLOCAL -I m4 --install && test -f aclocal.m4 \
61   || fatal_ "aclocal failed also when expected to succeed"
62
63 :