DebugClients/Python/coverage/html.py

changeset 6219
d6c795b5ce33
parent 5178
878ce843ca9f
diff -r bedab77d0fa3 -r d6c795b5ce33 DebugClients/Python/coverage/html.py
--- a/DebugClients/Python/coverage/html.py	Sat Apr 07 13:17:06 2018 +0200
+++ b/DebugClients/Python/coverage/html.py	Sat Apr 07 13:35:10 2018 +0200
@@ -12,7 +12,7 @@
 from coverage import env
 from coverage.backward import iitems
 from coverage.files import flat_rootname
-from coverage.misc import CoverageException, Hasher, isolate_module
+from coverage.misc import CoverageException, file_be_gone, Hasher, isolate_module
 from coverage.report import Reporter
 from coverage.results import Numbers
 from coverage.templite import Templite
@@ -78,7 +78,7 @@
     STATIC_FILES = [
         ("style.css", ""),
         ("jquery.min.js", "jquery"),
-        ("jquery.debounce.min.js", "jquery-debounce"),
+        ("jquery.ba-throttle-debounce.min.js", "jquery-throttle-debounce"),
         ("jquery.hotkeys.js", "jquery-hotkeys"),
         ("jquery.isonscreen.js", "jquery-isonscreen"),
         ("jquery.tablesorter.min.js", "jquery-tablesorter"),
@@ -105,6 +105,7 @@
         self.coverage = cov
 
         self.files = []
+        self.all_files_nums = []
         self.has_arcs = self.coverage.data.has_arcs()
         self.status = HtmlStatus()
         self.extra_css = None
@@ -137,7 +138,7 @@
         # Process all the files.
         self.report_files(self.html_file, morfs, self.config.html_dir)
 
-        if not self.files:
+        if not self.all_files_nums:
             raise CoverageException("No data to report.")
 
         # Write the index file.
@@ -171,10 +172,26 @@
 
     def html_file(self, fr, analysis):
         """Generate an HTML file for one source file."""
+        rootname = flat_rootname(fr.relative_filename())
+        html_filename = rootname + ".html"
+        html_path = os.path.join(self.directory, html_filename)
+
+        # Get the numbers for this file.
+        nums = analysis.numbers
+        self.all_files_nums.append(nums)
+
+        if self.config.skip_covered:
+            # Don't report on 100% files.
+            no_missing_lines = (nums.n_missing == 0)
+            no_missing_branches = (nums.n_partial_branches == 0)
+            if no_missing_lines and no_missing_branches:
+                # If there's an existing file, remove it.
+                file_be_gone(html_path)
+                return
+
         source = fr.source()
 
         # Find out if the file on disk is already correct.
-        rootname = flat_rootname(fr.relative_filename())
         this_hash = self.file_hash(source.encode('utf-8'), fr)
         that_hash = self.status.file_hash(rootname)
         if this_hash == that_hash:
@@ -184,9 +201,6 @@
 
         self.status.set_file_hash(rootname, this_hash)
 
-        # Get the numbers for this file.
-        nums = analysis.numbers
-
         if self.has_arcs:
             missing_branch_arcs = analysis.missing_branch_arcs()
             arcs_executed = analysis.arcs_executed()
@@ -269,8 +283,6 @@
             'time_stamp': self.time_stamp,
         })
 
-        html_filename = rootname + ".html"
-        html_path = os.path.join(self.directory, html_filename)
         write_html(html_path, html)
 
         # Save this file's information for the index file.
@@ -286,7 +298,7 @@
         """Write the index.html file for this report."""
         index_tmpl = Templite(read_data("index.html"), self.template_globals)
 
-        self.totals = sum(f['nums'] for f in self.files)
+        self.totals = sum(self.all_files_nums)
 
         html = index_tmpl.render({
             'has_arcs': self.has_arcs,
@@ -384,10 +396,10 @@
             'files': files,
         }
         with open(status_file, "w") as fout:
-            json.dump(status, fout)
+            json.dump(status, fout, separators=(',', ':'))
 
         # Older versions of ShiningPanda look for the old name, status.dat.
-        # Accomodate them if we are running under Jenkins.
+        # Accommodate them if we are running under Jenkins.
         # https://issues.jenkins-ci.org/browse/JENKINS-28428
         if "JENKINS_URL" in os.environ:
             with open(os.path.join(directory, "status.dat"), "w") as dat:

eric ide

mercurial