[gobject-introspection] scanner: Print out a message if warnings were off



commit b18c248d2fcb7accc96269341e87eca5cb3ad864
Author: Colin Walters <walters verbum org>
Date:   Thu Oct 7 16:27:00 2010 -0400

    scanner: Print out a message if warnings were off
    
    Otherwise people may not know about --warn-all.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=631644

 giscanner/message.py     |   10 +++++-----
 giscanner/scannermain.py |    6 +++++-
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/message.py b/giscanner/message.py
index ec7ace0..1b0e260 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -74,7 +74,7 @@ class MessageLogger(object):
         self._output = output
         self._namespace = namespace
         self._enable_warnings = False
-        self._warned = False
+        self._warning_count = 0
 
     @classmethod
     def get(cls, *args, **kwargs):
@@ -85,21 +85,21 @@ class MessageLogger(object):
     def enable_warnings(self, enable):
         self._enable_warnings = enable
 
-    def did_warn(self):
-        return self._warned
+    def get_warning_count(self):
+        return self._warning_count
 
     def log(self, log_type, text, positions=None, prefix=None):
         """Log a warning, using optional file positioning information.
 If the warning is related to a ast.Node type, see log_node_warning()."""
         utils.break_on_debug_flag('warning')
 
+        self._warning_count += 1
+
         if not self._enable_warnings:
             if log_type == FATAL:
                 raise SystemExit(text)
             return
 
-        self._warned = True
-
         if type(positions) == set:
             positions = list(positions)
         if isinstance(positions, Position):
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index fc52715..dd18643 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -405,9 +405,13 @@ def scanner_main(args):
     final = IntrospectablePass(transformer, blocks)
     final.validate()
 
-    if options.warn_fatal and logger.did_warn():
+    warning_count = logger.get_warning_count()
+    if options.warn_fatal and warning_count > 0:
         message.fatal("warnings configured as fatal")
         return 1
+    elif warning_count > 0:
+        print ("g-ir-scanner: %s: warning: %d warnings suppressed (use --warn-all to see them)"
+               % (transformer.namespace.name, warning_count, ))
 
     # Write out AST
     if options.packages_export:



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