test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / cond46.sh
1 #! /bin/sh
2 # Copyright (C) 2009-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 3 of the License, or
7 # (at your option) 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 the right condition is listed after 'else' and 'endif'.
18
19 . test-init.sh
20
21 cat >> configure.ac << 'END'
22 AM_CONDITIONAL([USE_A], [test x = y])
23 AM_CONDITIONAL([USE_B], [test x = z])
24 AC_OUTPUT
25 END
26
27 notcompat="incompatible with current conditional"
28
29 $ACLOCAL
30
31 cat > Makefile.am << 'END'
32 if USE_A
33 endif !USE_A
34 END
35
36 AUTOMAKE_fails
37 grep "^Makefile\\.am:2:.*endif.*!USE_A.*$notcompat.*[^!]USE_A" stderr
38
39 cat > Makefile.am << 'END'
40 if USE_A
41 endif USE_B
42 END
43
44 AUTOMAKE_fails
45 grep "^Makefile\\.am:2:.*endif.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
46
47 cat > Makefile.am << 'END'
48 if USE_A
49 else
50 endif USE_A
51 END
52
53 AUTOMAKE_fails
54 grep "^Makefile\\.am:3:.*endif.*[^!]USE_A.*$notcompat.*USE_A" stderr
55
56 cat > Makefile.am << 'END'
57 if USE_A
58 else
59 endif !USE_A
60 END
61
62 $AUTOMAKE
63
64 cat > Makefile.am << 'END'
65 if USE_A
66 if USE_B
67 else
68 endif !USE_A
69 endif
70 END
71
72 AUTOMAKE_fails
73 grep "^Makefile\\.am:4:.*endif.*!USE_A.*$notcompat.*USE_B" stderr
74
75 cat > Makefile.am << 'END'
76 if USE_A
77 else USE_A
78 endif
79 END
80
81 AUTOMAKE_fails
82 grep "^Makefile\\.am:2:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_A" stderr
83
84 cat > Makefile.am << 'END'
85 if USE_A
86 else !USE_A
87 endif
88 END
89
90 $AUTOMAKE
91
92 cat > Makefile.am << 'END'
93 if USE_A
94 else USE_B
95 endif
96 END
97
98 AUTOMAKE_fails
99 grep "^Makefile\\.am:2:.*else.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
100
101 cat > Makefile.am << 'END'
102 if USE_A
103 if USE_B
104 else USE_A
105 endif
106 endif
107 END
108
109 AUTOMAKE_fails
110 grep "^Makefile\\.am:3:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_B" stderr
111
112 :