automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/5] Prepend type to warning, error, and fatal messages.


From: Ralf Wildenhues
Subject: [PATCH 3/5] Prepend type to warning, error, and fatal messages.
Date: Sun, 11 Apr 2010 22:32:05 +0200
User-agent: Mutt/1.5.20 (2009-10-28)

For the first part of messages of types `error' or `fatal',
prepend `error: ' to the message.  Prepend `warning: ' to
warning messages, whatever the setting of -Werror.

* lib/Automake/Channels.pm (partial): Move up definition.
(_format_message): Emit `header' and `footer' strings only with
the first resp. last part of a set of partial messages.
* lib/Automake/ChannelDefs.pm: Add missing '1;' statement at the
end of the module.
(Automake::ChannelDefs): Setup warning channels with header
`warning: ', error and fatal messages with header `error: '.
* tests/condinc2.test, tests/ltinstloc.test: Adjust expected
error messages.
* tests/comment5.test: Likewise.  Also, include stack notes
should not start with `error:'.
* tests/location.test: Likewise.  Also, try both -Werror and
-Wno-error.
* NEWS: Update.
Report by Bruno Haible.

Signed-off-by: Ralf Wildenhues <address@hidden>
---

This is the meat of the series.  There are probably some warnings
where we can improve word wrapping afterwards.

Cheers,
Ralf

 ChangeLog                   |   20 ++++++++++++++++++++
 NEWS                        |    3 +++
 lib/Automake/ChannelDefs.pm |    6 ++++++
 lib/Automake/Channels.pm    |   21 ++++++++++++---------
 tests/comment5.test         |    9 +++++----
 tests/condinc2.test         |    6 +++---
 tests/location.test         |   21 +++++++++++++--------
 tests/ltinstloc.test        |    6 +++---
 8 files changed, 65 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6ed3c6f..65a637d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2010-04-11  Ralf Wildenhues  <address@hidden>
 
+       Prepend type to warning, error, and fatal messages.
+       For the first part of messages of types `error' or `fatal',
+       prepend `error: ' to the message.  Prepend `warning: ' to
+       warning messages, whatever the setting of -Werror.
+       * lib/Automake/Channels.pm (partial): Move up definition.
+       (_format_message): Emit `header' and `footer' strings only with
+       the first resp. last part of a set of partial messages.
+       * lib/Automake/ChannelDefs.pm: Add missing '1;' statement at the
+       end of the module.
+       (Automake::ChannelDefs): Setup warning channels with header
+       `warning: ', error and fatal messages with header `error: '.
+       * tests/condinc2.test, tests/ltinstloc.test: Adjust expected
+       error messages.
+       * tests/comment5.test: Likewise.  Also, include stack notes
+       should not start with `error:'.
+       * tests/location.test: Likewise.  Also, try both -Werror and
+       -Wno-error.
+       * NEWS: Update.
+       Report by Bruno Haible.
+
        Fix capitalization of error messages, reword one message.
        * lib/Automake/Variable.pm (define): Do not capitalize the first
        word in the error message.
diff --git a/NEWS b/NEWS
index 74887fb..5d167bb 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ 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.
+
 Bugs fixed in 1.11a:
 
   - Lots of minor bugfixes.
diff --git a/lib/Automake/ChannelDefs.pm b/lib/Automake/ChannelDefs.pm
index ce6bf29..26ef575 100644
--- a/lib/Automake/ChannelDefs.pm
+++ b/lib/Automake/ChannelDefs.pm
@@ -163,6 +163,10 @@ register_channel 'verb', type => 'debug', silent => 1, 
uniq_part => UP_NONE,
   ordered => 0;
 register_channel 'note', type => 'debug', silent => 0;
 
+setup_channel_type 'warning', header => 'warning: ';
+setup_channel_type 'error', header => 'error: ';
+setup_channel_type 'fatal', header => 'error: ';
+
 =head2 FUNCTIONS
 
 =over 4
@@ -381,6 +385,8 @@ Written by Alexandre Duret-Lutz E<lt>F<address@hidden>E<gt>.
 
 =cut
 
+1;
+
 ### Setup "GNU" style for perl-mode and cperl-mode.
 ## Local Variables:
 ## perl-indent-level: 2
diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm
index 050ba05..b08b90d 100644
--- a/lib/Automake/Channels.pm
+++ b/lib/Automake/Channels.pm
@@ -204,10 +204,14 @@ C<US_LOCAL>, and C<US_GLOBAL> constants above.
 =item C<header =E<gt> ''>
 
 A string to prepend to each message emitted through this channel.
+With partial messages, only the first part will have C<header>
+prepended.
 
 =item C<footer =E<gt> ''>
 
 A string to append to each message emitted through this channel.
+With partial messages, only the final part will have C<footer>
+appended.
 
 =item C<backtrace =E<gt> 0>
 
@@ -399,20 +403,24 @@ sub _format_sub_message ($$)
   return $leader . join ("\n" . $leader, split ("\n", $message)) . "\n";
 }
 
+# Store partial messages here. (See the 'partial' option.)
+use vars qw ($partial);
+$partial = '';
+
 # _format_message ($LOCATION, $MESSAGE, %OPTIONS)
 # -----------------------------------------------
 # Format the message.  Return a string ready to print.
 sub _format_message ($$%)
 {
   my ($location, $message, %opts) = @_;
-  my $msg = '';
+  my $msg = ($partial eq '' ? $opts{'header'} : '') . $message
+           . ($opts{'partial'} ? '' : $opts{'footer'});
   if (ref $location)
     {
       # If $LOCATION is a reference, assume it's an instance of the
       # Automake::Location class and display contexts.
       my $loc = $location->get || $me;
-      $msg = _format_sub_message ("$loc: ", $opts{'header'}
-                                 . $message . $opts{'footer'});
+      $msg = _format_sub_message ("$loc: ", $msg);
       for my $pair ($location->get_contexts)
        {
          $msg .= _format_sub_message ($pair->[0] . ":   ", $pair->[1]);
@@ -421,8 +429,7 @@ sub _format_message ($$%)
   else
     {
       $location ||= $me;
-      $msg = _format_sub_message ("$location: ", $opts{'header'}
-                                 . $message . $opts{'footer'});
+      $msg = _format_sub_message ("$location: ", $msg);
     }
   return $msg;
 }
@@ -484,10 +491,6 @@ sub _dequeue ($)
 }
 
 
-# Store partial messages here. (See the 'partial' option.)
-use vars qw ($partial);
-$partial = '';
-
 # _print_message ($LOCATION, $MESSAGE, %OPTIONS)
 # ----------------------------------------------
 # Format the message, check duplicates, and print it.
diff --git a/tests/comment5.test b/tests/comment5.test
index 21b5e87..6c66b53 100755
--- a/tests/comment5.test
+++ b/tests/comment5.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
@@ -37,7 +37,7 @@ EOF
 
 $ACLOCAL
 AUTOMAKE_fails
-grep '^Makefile.am:5: blank line following trailing backslash' stderr
+grep '^Makefile.am:5: error: blank line following trailing backslash' stderr
 
 
 ## Here is a second test because head comments are
@@ -54,7 +54,7 @@ var = foo
 EOF
 
 AUTOMAKE_fails
-grep '^Makefile.am:2: blank line following trailing backslash' stderr
+grep '^Makefile.am:2: error: blank line following trailing backslash' stderr
 
 
 ## Make sure we print an 'included' stack on errors.
@@ -66,8 +66,9 @@ cat > Makefile.inc << 'EOF'
 EOF
 
 AUTOMAKE_fails
-grep '^Makefile.inc:2: blank line following trailing backslash' stderr
+grep '^Makefile.inc:2: error: blank line following trailing backslash' stderr
 grep '^Makefile.am:1: .*included from here' stderr
+grep -v '^Makefile.am:1: .*error:' stderr
 
 
 ## Make sure backslashes are still allowed within a comment.
diff --git a/tests/condinc2.test b/tests/condinc2.test
index 69eff59..451c56f 100755
--- a/tests/condinc2.test
+++ b/tests/condinc2.test
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2003, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1999, 2001, 2002, 2003, 2009, 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
@@ -39,7 +39,7 @@ END
 
 $ACLOCAL
 AUTOMAKE_fails
-grep 'adjunct:3: too many conditionals closed' stderr
+grep 'adjunct:3: error: too many conditionals closed' stderr
 
 cat > adjunct << 'END'
 if TOBE
diff --git a/tests/location.test b/tests/location.test
index 13a2183..ced9952 100755
--- a/tests/location.test
+++ b/tests/location.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
@@ -45,29 +45,34 @@ VAR = 1 \
 END
 
 $ACLOCAL
-AUTOMAKE_fails
+AUTOMAKE_fails -Wno-error
 
 # Smash the useless difference of lib file locations.
 sed 's,^.*lib/am/\([a-z]*\.am\),\1,' stderr >observed
 cat >expected <<\EOF
-Makefile.am:12: VAR multiply defined in condition TRUE ...
+Makefile.am:12: warning: VAR multiply defined in condition TRUE ...
 Makefile.am:8: ... `VAR' previously defined here
-automake: libfoo_a_OBJECTS should not be defined
+automake: error: libfoo_a_OBJECTS should not be defined
 Makefile.am:3:   while processing library `libfoo.a'
-automake: use `libfoo_a_LDADD', not `libfoo_a_LIBADD'
+automake: error: use `libfoo_a_LDADD', not `libfoo_a_LIBADD'
 Makefile.am:3:   while processing library `libfoo.a'
-library.am: deprecated feature: target `libfoo.a' overrides `libfoo.a$(EXEEXT)'
+library.am: warning: deprecated feature: target `libfoo.a' overrides 
`libfoo.a$(EXEEXT)'
 library.am: change your target to read `libfoo.a$(EXEEXT)'
 Makefile.am:3:   while processing library `libfoo.a'
 program.am: target `libfoo.a$(EXEEXT)' was defined here
 Makefile.am:1:   while processing program `libfoo.a'
-program.am: redefinition of `libfoo.a$(EXEEXT)'...
+program.am: warning: redefinition of `libfoo.a$(EXEEXT)'...
 Makefile.am:1:   while processing program `libfoo.a'
 library.am: ... `libfoo.a' previously defined here
 Makefile.am:3:   while processing library `libfoo.a'
-tags.am: redefinition of `ctags'...
+tags.am: warning: redefinition of `ctags'...
 program.am: ... `ctags$(EXEEXT)' previously defined here
 Makefile.am:6:   while processing program `ctags'
 EOF
 
 diff expected observed || Exit 1
+
+AUTOMAKE_fails -Werror
+sed 's,^.*lib/am/\([a-z]*\.am\),\1,' stderr >observed
+diff expected observed || Exit 1
+:
diff --git a/tests/ltinstloc.test b/tests/ltinstloc.test
index bb3203a..1b7fd83 100755
--- a/tests/ltinstloc.test
+++ b/tests/ltinstloc.test
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009, 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
@@ -49,10 +49,10 @@ AUTOMAKE_fails --add-missing
 # whether automake installs config.guess and config.sub.
 
 cat >expected <<'END'
-Makefile.am:5: sub/liba2.la multiply defined in condition COND
+Makefile.am:5: error: sub/liba2.la multiply defined in condition COND
 Makefile.am:5: `sub/liba2.la' should be installed below `lib' in condition 
COND ...
 Makefile.am:2: ... and should also be installed in `lib' in condition COND.
-Makefile.am:4: liba1.la multiply defined in condition COND
+Makefile.am:4: error: liba1.la multiply defined in condition COND
 Makefile.am:4: `liba1.la' should be installed in `pkglib' in condition COND ...
 Makefile.am:2: ... and should also be installed in `lib' in condition COND.
 Makefile.am:2: Libtool libraries can be built for only one destination.
-- 
1.7.0.rc1.161.g90487





reply via email to

[Prev in Thread] Current Thread [Next in Thread]