tests: Don't always generate coverage data

We were doing this unconditionally, and on my laptop it seems to be
responsible for about 20% of the runtime... whoops!
This commit is contained in:
Cole Robinson 2018-01-08 07:03:25 -05:00
parent bc8c5b0778
commit 6009044463
2 changed files with 4 additions and 13 deletions

View File

@ -13,9 +13,6 @@ Our pylint script uses a blacklist rather than a whitelist approach,
so it could throw some false positives or useless messages. If you think
your patch exposes one of these, bring it up on the mailing list.
If `python-coverage` is installed, you can run `coverage -r` after
`python setup.py test` finished to see a code coverage report.
'test*' have a `--debug` option if you are hitting problems.
For more options, use `python setup.py test --help`.

View File

@ -419,14 +419,9 @@ class TestBaseCommand(distutils.core.Command):
return testfiles
def run(self):
try:
cov = None
if self.coverage:
import coverage
use_cov = True
except ImportError:
use_cov = False
cov = None
if use_cov:
# The latter is required to not give errors on f23, probably
# a temporary bug.
omit = ["/usr/*", "/*/tests/*", "/builddir/*"]
@ -435,7 +430,6 @@ class TestBaseCommand(distutils.core.Command):
cov.start()
import tests as testsmodule
testsmodule.cov = cov
testsmodule.utils.REGENERATE_OUTPUT = bool(self.regenerate_output)
if hasattr(unittest, "installHandler"):
@ -467,13 +461,13 @@ class TestBaseCommand(distutils.core.Command):
except KeyboardInterrupt:
sys.exit(1)
if use_cov:
if cov:
cov.stop()
cov.save()
err = int(bool(len(result.failures) > 0 or
len(result.errors) > 0))
if not err and use_cov and self.coverage:
if cov and not err:
cov.report(show_missing=False)
sys.exit(err)