Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Unified Diff: expect_tests/cover.py

Issue 2031013002: Reland of expect_tests > coverage: no data, no fail (patchset #1 id:1 of https://codereview.chromium (Closed) Base URL: https://chromium.googlesource.com/infra/testing/expect_tests.git@master
Patch Set: Fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: expect_tests/cover.py
diff --git a/expect_tests/cover.py b/expect_tests/cover.py
index dee4f16a05cc3991720c38573f112a368a33d670..44d4a35631822b151185171f8c9c4aa59bffc933 100644
--- a/expect_tests/cover.py
+++ b/expect_tests/cover.py
@@ -110,7 +110,19 @@ class CoverageContext(object):
self.cov.html_report(directory=self.html_report)
outf = StringIO()
- coverage_percent = self.cov.report(file=outf, show_missing=True)
+
+ try:
+ coverage_percent = self.cov.report(file=outf, show_missing=True)
+ except coverage.CoverageException as ce:
+ if ce.message != 'No data to report.':
+ raise
+ # If we have no data to report, this means that coverage has found no
+ # tests in the module. Earlier version of coverage used to return 100 in
+ # this case, so we simulate it to keep backward compatibility.
+ coverage_percent = 100.0
+ if verbose:
+ print 'No data to report, setting coverage to 100%'
+
fail = coverage_percent < self.expected_coverage_min
summary = outf.getvalue().replace('%- 15s' % 'Name', 'Coverage Report', 1)
if verbose:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698