[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/10] Warnings win over strictness on command line.
From: |
stefano . lattarini |
Subject: |
[PATCH 03/10] Warnings win over strictness on command line. |
Date: |
Thu, 23 Dec 2010 12:27:39 +0100 |
From: Stefano Lattarini <address@hidden>
This change ensures that, on the command line at least, explicitly
defined warnings always take precedence over implicit strictness
implied warnings. Related to Automake bug#7669 a.k.a. PR/547.
* automake.in (parse_arguments): Parse warnings only after the
strictness level has been processed.
* tests/gnuwarn.test: Update, plus miscellaneous improvements.
* tests/warnings-win-over-strictness.test: New test.
* tests/Makefile.am (TESTS): Update.
---
ChangeLog | 12 +++++++
automake.in | 31 +++++++++++------
tests/Makefile.am | 1 +
tests/Makefile.in | 1 +
tests/gnuwarn.test | 18 ++++++----
tests/warnings-win-over-strictness.test | 54 +++++++++++++++++++++++++++++++
6 files changed, 99 insertions(+), 18 deletions(-)
create mode 100755 tests/warnings-win-over-strictness.test
diff --git a/ChangeLog b/ChangeLog
index 206acd7..4985428 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2010-12-20 Stefano Lattarini <address@hidden>
+ Warnings win over strictness on command line.
+ This change ensures that, on the command line at least, explicitly
+ defined warnings always take precedence over implicit strictness
+ implied warnings. Related to Automake bug#7669 a.k.a. PR/547.
+ * automake.in (parse_arguments): Parse warnings only after the
+ strictness level has been processed.
+ * tests/gnuwarn.test: Update, plus miscellaneous improvements.
+ * tests/warnings-win-over-strictness.test: New test.
+ * tests/Makefile.am (TESTS): Update.
+
+2010-12-20 Stefano Lattarini <address@hidden>
+
New test on silent-rules mode and portability warnings.
* tests/silent-rules-nowarn.test: New test.
* tests/Makefile.am (TESTS): Update.
diff --git a/automake.in b/automake.in
index 27904f0..fd00369 100644
--- a/automake.in
+++ b/automake.in
@@ -8444,26 +8444,26 @@ EOF
# Parse command line.
sub parse_arguments ()
{
- # Start off as gnu.
- set_strictness ('gnu');
+ my $strictness = 'gnu';
+ my $cygnus = 0;
+ my $ignore_deps = 0;
+ my @warnings = ();
- my $cli_where = new Automake::Location;
my %cli_options =
(
'libdir=s' => \$libdir,
- 'gnu' => sub { set_strictness ('gnu'); },
- 'gnits' => sub { set_strictness ('gnits'); },
- 'cygnus' => sub { set_global_option ('cygnus', $cli_where); },
- 'foreign' => sub { set_strictness ('foreign'); },
- 'include-deps' => sub { unset_global_option ('no-dependencies'); },
- 'i|ignore-deps' => sub { set_global_option ('no-dependencies',
- $cli_where); },
+ 'gnu' => sub { $strictness = 'gnu'; },
+ 'gnits' => sub { $strictness = 'gnits'; },
+ 'foreign' => sub { $strictness = 'foreign'; },
+ 'cygnus' => \$cygnus,
+ 'include-deps' => sub { $ignore_deps = 0; },
+ 'i|ignore-deps' => sub { $ignore_deps = 1; },
'no-force' => sub { $force_generation = 0; },
'f|force-missing' => \$force_missing,
'a|add-missing' => \$add_missing,
'c|copy' => \$copy_missing,
'v|verbose' => sub { setup_channel 'verb', silent => 0; },
- 'W|warnings=s' => \&parse_warnings,
+ 'W|warnings=s' => address@hidden,
);
use Getopt::Long;
Getopt::Long::config ("bundling", "pass_through");
@@ -8492,6 +8492,15 @@ sub parse_arguments ()
Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
or exit 1;
+ set_strictness ($strictness);
+ my $cli_where = new Automake::Location;
+ set_global_option ('cygnus', $cli_where) if $cygnus;
+ set_global_option ('no-dependencies', $cli_where) if $ignore_deps;
+ for my $warning (@warnings)
+ {
+ &parse_warnings('-W', $warning);
+ }
+
return unless @ARGV;
if ($ARGV[0] =~ /^-./)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b38738b..428011a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -928,6 +928,7 @@ vtexi2.test \
warnings-overriding.test \
warnings-precedence.test \
warnopts.test \
+warnings-win-over-strictness.test \
werror.test \
werror2.test \
werror3.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 5b881f5..c0534ef 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1191,6 +1191,7 @@ vtexi2.test \
warnings-overriding.test \
warnings-precedence.test \
warnopts.test \
+warnings-win-over-strictness.test \
werror.test \
werror2.test \
werror3.test \
diff --git a/tests/gnuwarn.test b/tests/gnuwarn.test
index 9c8aeb4..d637a8c 100755
--- a/tests/gnuwarn.test
+++ b/tests/gnuwarn.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 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
@@ -20,9 +20,11 @@
set -e
+# We need (almost) complete control over automake options.
+AUTOMAKE="$original_AUTOMAKE -Werror"
+
cat >> configure.in << 'END'
AC_PROG_CC
-AC_OUTPUT
END
# Needed by --gnu.
@@ -40,12 +42,14 @@ END
$ACLOCAL
# Don't warn in foreign mode
-$AUTOMAKE -Wnone --add-missing --foreign
+$AUTOMAKE --add-missing --foreign
# Warn in gnu mode
-AUTOMAKE_fails -Wnone --add-missing --gnu
-grep 'Makefile.am:1:.*CFLAGS' stderr
-grep 'Makefile.am:2:.*LDFLAGS' stderr
+AUTOMAKE_fails --add-missing --gnu
+grep '^Makefile\.am:1:.*CFLAGS' stderr
+grep '^Makefile\.am:2:.*LDFLAGS' stderr
# No reason to warn about CXXFLAGS since it's not used.
grep CXXFLAGS stderr && Exit 1
# Don't warn if -Wno-gnu.
-$AUTOMAKE -Wnone --gnu -Wno-gnu
+$AUTOMAKE --gnu -Wno-gnu
+
+:
diff --git a/tests/warnings-win-over-strictness.test
b/tests/warnings-win-over-strictness.test
new file mode 100755
index 0000000..977ed64
--- /dev/null
+++ b/tests/warnings-win-over-strictness.test
@@ -0,0 +1,54 @@
+#! /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/>.
+
+# Check that, on the command line, explicitly-defined warnings take
+# precedence over implicit strictness-implied warnings.
+
+. ./defs || Exit 1
+
+set -e
+
+# We want complete control over automake options.
+AUTOMAKE=$original_AUTOMAKE
+
+ok()
+{
+ AUTOMAKE_run 0 $*
+ test ! -s stderr
+}
+
+ko()
+{
+ AUTOMAKE_run 0 $*
+ grep '^Makefile\.am:.*:=.*not portable' stderr
+ test `wc -l <stderr` = 1
+}
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+cat > Makefile.am <<END
+FOO := bar
+END
+
+$ACLOCAL
+
+ko --foreign -Wportability
+ko -Wportability --foreign
+ok --gnu -Wno-portability
+ok -Wno-portability --gnu
+
+:
--
1.7.2.3
- [PATCH 0/10] Explicit warning levels must always take precedence over those implied by the strictness, stefano . lattarini, 2010/12/23
- [PATCH 02/10] New test on silent-rules mode and portability warnings., stefano . lattarini, 2010/12/23
- [PATCH 03/10] Warnings win over strictness on command line.,
stefano . lattarini <=
- [PATCH 01/10] Add new tests on strictness and warnings precedence and overriding., stefano . lattarini, 2010/12/23
- [PATCH 05/10] Remove global/local distinction for automake options., stefano . lattarini, 2010/12/23
- [PATCH 04/10] Refactoring: new $automake_remake_options global variable., stefano . lattarini, 2010/12/23
- [PATCH 06/10] Cleanup in module Automake::Options., stefano . lattarini, 2010/12/23
- [PATCH 07/10] Warnings win over strictness in AM_INIT_AUTOMAKE., stefano . lattarini, 2010/12/23
- [PATCH 08/10] Add more tests about AUTOMAKE_OPTIONS., stefano . lattarini, 2010/12/23
- [PATCH 09/10] Change signature of 'Automake::Options::process_option_list()'., stefano . lattarini, 2010/12/23
- [PATCH 10/10] Warnings win over strictness in AUTOMAKE_OPTIONS., stefano . lattarini, 2010/12/23