Bug 1360764 - Record warnings seen during the current operation; r?froydnj draft
authorGregory Szorc <gps@mozilla.com>
Fri, 28 Apr 2017 17:13:10 -0700
changeset 570502 fec091da190b7c434ea78d54e71edb35b753aad2
parent 570501 99276eec4f66a014c540ce1e2a8f0453f4ff45bc
child 570503 1fed0bf28098d85b61c7e7b0eab33eba2658b60f
push id56506
push userbmo:gps@mozilla.com
push dateSat, 29 Apr 2017 00:24:04 +0000
reviewersfroydnj
bugs1360764
milestone55.0a1
Bug 1360764 - Record warnings seen during the current operation; r?froydnj Currently, the build monitor has a single compiler warnings database that unions warnings from previous runs with warnings from the current invocation. I want to introduce functionality that treats warnings seen during the current invocation differently from "all warnings." To facilitate this, this commit introduces a 2nd, non-persisted warnings database to record warnings just for the current invocation. MozReview-Commit-ID: FIY0GiarDmr
python/mozbuild/mozbuild/compilation/warnings.py
python/mozbuild/mozbuild/controller/building.py
--- a/python/mozbuild/mozbuild/compilation/warnings.py
+++ b/python/mozbuild/mozbuild/compilation/warnings.py
@@ -53,16 +53,22 @@ class CompilerWarning(dict):
         dict.__init__(self)
 
         self['filename'] = None
         self['line'] = None
         self['column'] = None
         self['message'] = None
         self['flag'] = None
 
+    def copy(self):
+        """Returns a copy of this compiler warning."""
+        w = CompilerWarning()
+        w.update(self)
+        return w
+
     # Since we inherit from dict, functools.total_ordering gets confused.
     # Thus, we define a key function, a generic comparison, and then
     # implement all the rich operators with those; approach is from:
     # http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/
     def _cmpkey(self):
         return (self['filename'], self['line'], self['column'])
 
     def _compare(self, other, func):
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -167,24 +167,30 @@ class BuildMonitor(MozbuildObject):
 
         self.warnings_database = WarningsDatabase()
         if os.path.exists(warnings_path):
             try:
                 self.warnings_database.load_from_file(warnings_path)
             except ValueError:
                 os.remove(warnings_path)
 
+        # Contains warnings unique to this invocation. Not populated with old
+        # warnings.
+        self.instance_warnings = WarningsDatabase()
+
         def on_warning(warning):
             filename = warning['filename']
 
             if not os.path.exists(filename):
                 raise Exception('Could not find file containing warning: %s' %
                                 filename)
 
             self.warnings_database.insert(warning)
+            # Make a copy so mutations don't impact other database.
+            self.instance_warnings.insert(warning.copy())
 
         self._warnings_collector = WarningsCollector(on_warning,
                                                      objdir=self.topobjdir)
 
         self.build_objects = []
 
     def start(self):
         """Record the start of the build."""