test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / warnings-win-over-strictness.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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, on the command line, explicitly-defined warnings take
18 # precedence over implicit strictness-implied warnings.
19
20 . test-init.sh
21
22 # We want complete control over automake options.
23 AUTOMAKE=$am_original_AUTOMAKE
24
25 ok ()
26 {
27   AUTOMAKE_run $*
28   test ! -s stderr
29 }
30
31 ko ()
32 {
33   AUTOMAKE_run $*
34   grep '^Makefile\.am:.*:=.*not portable' stderr
35   test $(wc -l <stderr) -eq 1
36 }
37
38 set_am_opts()
39 {
40   set +x
41   sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
42                 -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
43   mv -f $2-t $2
44   set -x
45   cat $2
46 }
47
48 # Files required in gnu strictness.
49 touch README INSTALL NEWS AUTHORS ChangeLog COPYING
50
51 cat > Makefile.am <<END
52 AUTOMAKE_OPTIONS =
53 FOO := bar
54 END
55
56 $ACLOCAL
57
58 ko --foreign -Wportability
59 ko -Wportability --foreign
60 ok --gnu -Wno-portability
61 ok -Wno-portability --gnu
62
63 set_am_opts '' Makefile.am
64
65 rm -rf autom4te*.cache
66 set_am_opts 'foreign -Wportability' configure.ac
67 ko
68 rm -rf autom4te*.cache
69 set_am_opts '-Wportability foreign' configure.ac
70 ko
71 rm -rf autom4te*.cache
72 set_am_opts 'gnu -Wno-portability' configure.ac
73 ok
74 rm -rf autom4te*.cache
75 set_am_opts '-Wno-portability gnu' configure.ac
76 ok
77
78 rm -rf autom4te*.cache
79 set_am_opts '' configure.ac
80
81 set_am_opts 'foreign -Wportability' Makefile.am
82 ko
83 set_am_opts '-Wportability foreign' Makefile.am
84 ko
85 set_am_opts 'gnu -Wno-portability' Makefile.am
86 ok
87 set_am_opts '-Wno-portability gnu' Makefile.am
88 ok
89
90 :