tests: Defer writing coverage report.

It's relatively rare that you want to read the coverage report
if the coverage tests pass. This allows devs to get quicker
feedback. Particularly on tricky rebases this can be a real
time saver. It takes about a minute to write the coverage
report on my box.
This commit is contained in:
Steve Howell 2023-08-10 12:19:54 +00:00 committed by Tim Abbott
parent 2db715030d
commit 27b5b0dc26
1 changed files with 11 additions and 5 deletions

View File

@ -451,10 +451,7 @@ def main() -> None:
print("Writing XML report") print("Writing XML report")
cov.xml_report(outfile="var/coverage.xml") cov.xml_report(outfile="var/coverage.xml")
print("XML report saved; see var/coverage.xml") print("XML report saved; see var/coverage.xml")
if not options.no_html_report:
print("Writing HTML report")
cov.html_report(directory="var/coverage", show_contexts=True)
print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")
if full_suite and not failures and options.coverage: if full_suite and not failures and options.coverage:
# Assert that various files have full coverage # Assert that various files have full coverage
for path in enforce_fully_covered: for path in enforce_fully_covered:
@ -481,13 +478,22 @@ def main() -> None:
ok = False ok = False
except coverage.misc.NoSource: except coverage.misc.NoSource:
continue continue
if not ok: if ok:
print("Coverage checks pass!")
else:
print() print()
print( print(
"There are one or more fully covered files that are still in not_yet_fully_covered." "There are one or more fully covered files that are still in not_yet_fully_covered."
) )
print("Remove the file(s) from not_yet_fully_covered in `tools/test-backend`.") print("Remove the file(s) from not_yet_fully_covered in `tools/test-backend`.")
failures = True failures = True
if options.coverage and not options.no_html_report:
# We do this late, because it can take quite a while.
print("Writing HTML report")
cov.html_report(directory="var/coverage", show_contexts=True)
print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")
if options.profile: if options.profile:
prof.disable() prof.disable()
with tempfile.NamedTemporaryFile(prefix="profile.data.", delete=False) as stats_file: with tempfile.NamedTemporaryFile(prefix="profile.data.", delete=False) as stats_file: