tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / cond42.sh
1 #!/bin/sh
2 # Copyright (C) 2008-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 # Ensure an error with inconsistent state of conditionals in configure.ac.
18 # This shouldn't happen with user input, as _AM_COND_* are not documented,
19 # but better to be safe.
20
21 . ./defs || Exit 1
22
23 cat >>configure.ac <<'END'
24 AM_CONDITIONAL([COND], [:])
25 # The next line is needed so that cond-if.m4 is pulled in.
26 AM_COND_IF([COND])
27 _AM_COND_IF([COND])
28 AC_OUTPUT
29 END
30
31 edit_configure_in ()
32 {
33   sed "$@" < configure.ac >configure.int
34   mv -f configure.int configure.ac
35   rm -rf autom4te*.cache
36 }
37
38 : >Makefile.am
39
40 $ACLOCAL
41 AUTOMAKE_fails
42 grep '^configure\.ac:8:.* condition stack' stderr
43
44 edit_configure_in 's/_AM_COND_IF/_AM_COND_ELSE/'
45 AUTOMAKE_fails
46 grep '^configure\.ac:7:.* else without if' stderr
47
48 edit_configure_in 's/_AM_COND_ELSE/_AM_COND_ENDIF/'
49 AUTOMAKE_fails
50 grep '^configure\.ac:7:.* endif without if' stderr
51
52 edit_configure_in 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
53 _AM_COND_ENDIF/'
54 AUTOMAKE_fails
55 grep '^configure\.ac:7:.* not enough arguments.* _AM_COND_IF' stderr
56 grep '^configure\.ac:8:.* not enough arguments.* _AM_COND_ENDIF' stderr
57 test 2 = `grep -c 'not enough arguments' stderr`
58
59 :