Add support for ansible-test --coverage-check. (#53573)

This commit is contained in:
Matt Clay
2019-03-11 15:13:09 -07:00
committed by GitHub
parent 9ff25c0167
commit 887ab35656
8 changed files with 49 additions and 13 deletions

View File

@@ -209,6 +209,10 @@ def parse_args():
default='',
help='label to include in coverage output file names')
test.add_argument('--coverage-check',
action='store_true',
help='only verify code coverage can be enabled')
test.add_argument('--metadata',
help=argparse.SUPPRESS)

View File

@@ -104,6 +104,7 @@ class TestConfig(EnvironmentConfig):
self.coverage = args.coverage # type: bool
self.coverage_label = args.coverage_label # type: str
self.coverage_check = args.coverage_check # type: bool
self.include = args.include or [] # type: list [str]
self.exclude = args.exclude or [] # type: list [str]
self.require = args.require or [] # type: list [str]
@@ -124,6 +125,9 @@ class TestConfig(EnvironmentConfig):
self.metadata = Metadata.from_file(args.metadata) if args.metadata else Metadata()
self.metadata_path = None
if self.coverage_check:
self.coverage = True
class ShellConfig(EnvironmentConfig):
"""Configuration for the shell command."""

View File

@@ -211,6 +211,9 @@ def intercept_command(args, cmd, target_name, capture=False, env=None, data=None
coverage_file = os.path.abspath(os.path.join(inject_path, '..', 'output', '%s=%s=%s=%s=coverage' % (
args.command, target_name, args.coverage_label or 'local-%s' % version, 'python-%s' % version)))
if args.coverage_check:
coverage_file = ''
env['PATH'] = inject_path + os.path.pathsep + env['PATH']
env['ANSIBLE_TEST_PYTHON_VERSION'] = version
env['ANSIBLE_TEST_PYTHON_INTERPRETER'] = interpreter