[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] Print 'warnings are treated as errors' note if needed.
From: |
Ralf Wildenhues |
Subject: |
[PATCH 5/5] Print 'warnings are treated as errors' note if needed. |
Date: |
Sun, 11 Apr 2010 22:32:44 +0200 |
User-agent: |
Mutt/1.5.20 (2009-10-28) |
* 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 <address@hidden>
---
ChangeLog | 11 +++++++
NEWS | 2 +-
lib/Automake/Channels.pm | 5 +++-
tests/Makefile.am | 1 +
tests/Makefile.in | 1 +
tests/location.test | 3 +-
tests/warnopts.test | 9 +++---
tests/werror4.test | 68 ++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 93 insertions(+), 7 deletions(-)
create mode 100755 tests/werror4.test
diff --git a/ChangeLog b/ChangeLog
index f63d2a5..d7f3c23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-04-11 Ralf Wildenhues <address@hidden>
+ 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
--- 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:
diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm
index b08b90d..35897a5 100644
--- a/lib/Automake/Channels.pm
+++ b/lib/Automake/Channels.pm
@@ -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)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f51ebd7..2255af6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -763,6 +763,7 @@ warnopts.test \
werror.test \
werror2.test \
werror3.test \
+werror4.test \
whoami.test \
xsource.test \
xz.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 387af70..beb1ac9 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1003,6 +1003,7 @@ warnopts.test \
werror.test \
werror2.test \
werror3.test \
+werror4.test \
whoami.test \
xsource.test \
xz.test \
diff --git a/tests/location.test b/tests/location.test
index ced9952..21cfb4e 100755
--- a/tests/location.test
+++ b/tests/location.test
@@ -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
:
diff --git a/tests/warnopts.test b/tests/warnopts.test
index 6d96400..b472164 100755
--- a/tests/warnopts.test
+++ b/tests/warnopts.test
@@ -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
index 0000000..831d0fd
--- /dev/null
+++ b/tests/werror4.test
@@ -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
+
+:
--
1.7.0.rc1.161.g90487
- [PATCH 0/5] Prepend 'error: ' or 'warning: ' to messages., Ralf Wildenhues, 2010/04/11
- [PATCH 1/5] Fix connected warnings about obsolete exeext override., Ralf Wildenhues, 2010/04/11
- [PATCH 2/5] Fix capitalization of error messages, reword one message., Ralf Wildenhues, 2010/04/11
- [PATCH 3/5] Prepend type to warning, error, and fatal messages., Ralf Wildenhues, 2010/04/11
- [PATCH 4/5] Ensure we don't print 'warning:' or 'error:' twice., Ralf Wildenhues, 2010/04/11
- [PATCH 5/5] Print 'warnings are treated as errors' note if needed.,
Ralf Wildenhues <=
- Re: [PATCH 0/5] Prepend 'error: ' or 'warning: ' to messages., Bruno Haible, 2010/04/11