setup: Skip coverage report when tests are aborted or skipped

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-27 06:16:32 -05:00
parent e784376699
commit 49d16912c3

View File

@ -503,8 +503,15 @@ class TestBaseCommand(distutils.core.Command):
err = int(bool(len(result.failures) > 0 or
len(result.errors) > 0))
if getattr(result, "shouldStop", False):
# Test was aborted with ctrl-c
err = True
if cov and not err:
cov.report(show_missing=False, skip_covered=True)
if len(result.skipped):
print("Skipping coverage report because tests were skipped.")
else:
cov.report(show_missing=False, skip_covered=True)
sys.exit(err)