Charles Law avatar Charles Law committed 6ba7a96 Draft

Added support for coverage omit option

Comments (0)

Files changed (1)

 class CovController(object):
     """Base class for different plugin implementations."""
 
-    def __init__(self, cov_source, cov_report, cov_config, config=None, nodeid=None):
+    def __init__(self, cov_source, cov_report, cov_config, config=None,
+                 nodeid=None, cov_omit=None):
         """Get some common config used by multiple derived classes."""
 
         self.cov_source = cov_source
+        self.cov_omit = cov_omit
         self.cov_report = cov_report
         self.cov_config = cov_config
         self.config = config
         """Put info about coverage into the env so that subprocesses can activate coverage."""
 
         os.environ['COV_CORE_SOURCE'] = UNIQUE_SEP.join(self.cov_source)
+        os.environ['COV_CORE_OMIT'] = UNIQUE_SEP.join(self.cov_omit)
         os.environ['COV_CORE_DATA_FILE'] = self.cov_data_file
         os.environ['COV_CORE_CONFIG'] = self.cov_config
         multiprocessing_hook()
         """Remove coverage info from env."""
 
         del os.environ['COV_CORE_SOURCE']
+        del os.environ['COV_CORE_OMIT']
         del os.environ['COV_CORE_DATA_FILE']
         del os.environ['COV_CORE_CONFIG']
 
 
     def start(self):
         """Erase any previous coverage data and start coverage."""
-
         self.cov = coverage.coverage(source=self.cov_source,
+                                     omit=self.cov_omit,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
         # that it returns to us.
         if 'cov_slave_lines' in node.slaveoutput:
             cov = coverage.coverage(source=self.cov_source,
+                                    omit=self.cov_omit,
                                     data_file=self.cov_data_file,
                                     data_suffix=node.slaveoutput['cov_slave_node_id'],
                                     config_file=self.cov_config)
 
         # Combine all the suffix files into the data file.
         self.cov = coverage.coverage(source=self.cov_source,
+                                     omit=self.cov_omit,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
             master_topdir = self.config.slaveinput['cov_master_topdir']
             slave_topdir = self.topdir
             self.cov_source = [source.replace(master_topdir, slave_topdir) for source in self.cov_source]
+            self.cov_omit = [omit.replace(master_topdir, slave_topdir) for omit in self.cov_omit]
             self.cov_data_file = self.cov_data_file.replace(master_topdir, slave_topdir)
             self.cov_config = self.cov_config.replace(master_topdir, slave_topdir)
 
 
         # Erase any previous data and start coverage.
         self.cov = coverage.coverage(source=self.cov_source,
+                                     omit=self.cov_omit,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.