Print 'warnings are treated as errors' note if needed.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 11 Apr 2010 20:00:09 +0000 (22:00 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 11 Apr 2010 20:00:09 +0000 (22:00 +0200)
* lib/Automake/Channels.pm: Fix typo in comment.
(_print_message): If -Werror is enabled, print a 'warnings are
treated as errors' note before the first such warning.
* tests/warnopts.test: Adjust comment to mention expected warning.
Adjust code to ignore 'warnings are treated as errors' note.
* tests/location.test: Adjust expected output with -Werror.
* tests/werror4.test: New test.
* tests/Makefile.am: Update.
* NEWS: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
NEWS
lib/Automake/Channels.pm
tests/Makefile.am
tests/Makefile.in
tests/location.test
tests/warnopts.test
tests/werror4.test [new file with mode: 0755]

index f63d2a5..d7f3c23 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-04-11  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Print 'warnings are treated as errors' note if needed.
+       * lib/Automake/Channels.pm: Fix typo in comment.
+       (_print_message): If -Werror is enabled, print a 'warnings are
+       treated as errors' note before the first such warning.
+       * tests/warnopts.test: Adjust comment to mention expected warning.
+       Adjust code to ignore 'warnings are treated as errors' note.
+       * tests/location.test: Adjust expected output with -Werror.
+       * tests/werror4.test: New test.
+       * tests/Makefile.am: Update.
+       * NEWS: Update.
+
        Ensure we don't print 'warning:' or 'error:' twice.
        * Makefile.am (sc_ensure_testsuite_has_run): New helper rule.
        (sc_tests_logs_duplicate_prefixes): New rule, to check for
diff --git a/NEWS b/NEWS
index 5d167bb..13b28c0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,7 @@ New in 1.11a:
   - "make dist" can now create lzip-compressed tarballs.
 
   - Messages of types warning or error from `automake' and `aclocal' are now
-    prefixed with the respective type.
+    prefixed with the respective type, and presence of -Werror is noted.
 
 Bugs fixed in 1.11a:
 
index b08b90d..35897a5 100644 (file)
@@ -164,7 +164,7 @@ functions.  The possible keys, with their default value are:
 The type of the channel.  One of C<'debug'>, C<'warning'>, C<'error'>, or
 C<'fatal'>.  Fatal messages abort the program when they are output.
 Error messages update the exit status.  Debug and warning messages are
-harmless, except that warnings can be treated as errors of
+harmless, except that warnings are treated as errors if
 C<$warnings_are_errors> is set.
 
 =item C<exit_code =E<gt> 1>
@@ -514,6 +514,9 @@ sub _print_message ($$%)
       $partial = '';
     }
 
+  msg ('note', '', 'warnings are treated as errors', uniq_scope => US_GLOBAL)
+    if ($opts{'type'} eq 'warning' && $warnings_are_errors);
+
   # Check for duplicate message if requested.
   my $to_filter;
   if ($opts{'uniq_part'} ne UP_NONE)
index f51ebd7..2255af6 100644 (file)
@@ -763,6 +763,7 @@ warnopts.test \
 werror.test \
 werror2.test \
 werror3.test \
+werror4.test \
 whoami.test \
 xsource.test \
 xz.test \
index 387af70..beb1ac9 100644 (file)
@@ -1003,6 +1003,7 @@ warnopts.test \
 werror.test \
 werror2.test \
 werror3.test \
+werror4.test \
 whoami.test \
 xsource.test \
 xz.test \
index ced9952..21cfb4e 100755 (executable)
@@ -74,5 +74,6 @@ diff expected observed || Exit 1
 
 AUTOMAKE_fails -Werror
 sed 's,^.*lib/am/\([a-z]*\.am\),\1,' stderr >observed
-diff expected observed || Exit 1
+( echo 'automake: warnings are treated as errors'; cat expected ) \
+  | diff - observed || Exit 1
 :
index 6d96400..b472164 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2002, 2003, 2004  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2010  Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -46,14 +46,15 @@ END
 $ACLOCAL
 AUTOMAKE_fails
 # The expected diagnostic is
-#   Makefile.am:3: unused variable: `foo_SOURCES'
-#   sub/Makefile.am:2: `INCLUDES' is the old name for `AM_CPPFLAGS'
+#   Makefile.am:3: warning: variable `foo_SOURCES' is defined but no program or
+#                           library has `foo' as canonical name (possible typo)
+#   sub/Makefile.am:2: warning: `INCLUDES' is the old name for `AM_CPPFLAGS'
 grep '^Makefile.am:.*foo_SOURCES' stderr
 grep '^sub/Makefile.am:.*INCLUDES' stderr
 grep '^sub/Makefile.am:.*foo_SOURCES' stderr && Exit 1
 grep '^Makefile.am:.*INCLUDES' stderr && Exit 1
 # Only three lines of warnings.
-test `wc -l < stderr` = 3
+test `grep -v 'warnings are treated as errors' stderr | wc -l` = 3
 
 # On fast machines the autom4te.cache created during the above run of
 # $AUTOMAKE is likely to have the same time stamp as the configure.in
diff --git a/tests/werror4.test b/tests/werror4.test
new file mode 100755 (executable)
index 0000000..831d0fd
--- /dev/null
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2010  Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# -Werror and local -Werror settings should be flagged for the user.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >>configure.in <<\END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+cat >sub/Makefile.am <<\END
+AUTOMAKE_OPTIONS = -Werror
+SUB = foo
+SUB = bar
+END
+cat >Makefile.am <<\END
+AUTOMAKE_OPTIONS = -Werror
+VAR = foo
+VAR = bar
+END
+
+$ACLOCAL
+
+AUTOMAKE_fails -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+sed '/AUTOMAKE_OPTIONS/d' sub/Makefile.am > t
+mv -f t sub/Makefile.am
+
+AUTOMAKE_fails -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+sed '/AUTOMAKE_OPTIONS/d' Makefile.am > t
+mv -f t Makefile.am
+
+AUTOMAKE_fails -Werror
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+AUTOMAKE_run 0 -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+grep 'warnings are treated as errors' stderr && Exit 1
+
+: