Commit 044c2c21 authored by Stefan Behnel's avatar Stefan Behnel

fix coverage analysis in test runner after sharding changes

parent f925d315
...@@ -1456,14 +1456,16 @@ def main(): ...@@ -1456,14 +1456,16 @@ def main():
WITH_CYTHON = options.with_cython WITH_CYTHON = options.with_cython
coverage = None
if options.coverage or options.coverage_xml or options.coverage_html: if options.coverage or options.coverage_xml or options.coverage_html:
if not WITH_CYTHON: if not options.shard_count and options.shard_num < 0:
options.coverage = options.coverage_xml = options.coverage_html = False if not WITH_CYTHON:
else: options.coverage = options.coverage_xml = options.coverage_html = False
from coverage import coverage as _coverage else:
coverage = _coverage(branch=True) from coverage import coverage as _coverage
coverage.erase() coverage = _coverage(branch=True)
coverage.start() coverage.erase()
coverage.start()
if WITH_CYTHON: if WITH_CYTHON:
global CompilationOptions, pyrex_default_options, cython_compile global CompilationOptions, pyrex_default_options, cython_compile
...@@ -1496,7 +1498,7 @@ def main(): ...@@ -1496,7 +1498,7 @@ def main():
else: else:
return_code = 0 return_code = 0
else: else:
_, return_code = runtests(options, cmd_args) _, return_code = runtests(options, cmd_args, coverage)
print("ALL DONE") print("ALL DONE")
...@@ -1513,7 +1515,7 @@ def runtests_callback(args): ...@@ -1513,7 +1515,7 @@ def runtests_callback(args):
options.shard_num = shard_num options.shard_num = shard_num
return runtests(options, cmd_args) return runtests(options, cmd_args)
def runtests(options, cmd_args): def runtests(options, cmd_args, coverage=None):
WITH_CYTHON = options.with_cython WITH_CYTHON = options.with_cython
ROOTDIR = os.path.abspath(options.root_dir) ROOTDIR = os.path.abspath(options.root_dir)
...@@ -1660,7 +1662,7 @@ def runtests(options, cmd_args): ...@@ -1660,7 +1662,7 @@ def runtests(options, cmd_args):
result = test_runner.run(test_suite) result = test_runner.run(test_suite)
if options.coverage or options.coverage_xml or options.coverage_html: if coverage is not None:
coverage.stop() coverage.stop()
ignored_modules = ('Options', 'Version', 'DebugFlags', 'CmdLine') ignored_modules = ('Options', 'Version', 'DebugFlags', 'CmdLine')
modules = [ module for name, module in sys.modules.items() modules = [ module for name, module in sys.modules.items()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment