From fba76444e0d8fa596f3a1fea049f892b252d271e Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 5 Jul 2017 10:24:56 -0700 Subject: [PATCH] Add `ansible-test coverage report --show-missing`. --- test/runner/lib/cover.py | 20 ++++++++++++++++++-- test/runner/test.py | 6 +++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/test/runner/lib/cover.py b/test/runner/lib/cover.py index 074ba146d8..c34a5ac3d8 100644 --- a/test/runner/lib/cover.py +++ b/test/runner/lib/cover.py @@ -137,7 +137,7 @@ def command_coverage_combine(args): def command_coverage_report(args): """ - :type args: CoverageConfig + :type args: CoverageReportConfig """ output_files = command_coverage_combine(args) @@ -145,9 +145,14 @@ def command_coverage_report(args): if args.group_by or args.stub: display.info('>>> Coverage Group: %s' % ' '.join(os.path.basename(output_file).split('=')[1:])) + options = [] + + if args.show_missing: + options.append('--show-missing') + env = common_environment() env.update(dict(COVERAGE_FILE=output_file)) - run_command(args, env=env, cmd=['coverage', 'report']) + run_command(args, env=env, cmd=['coverage', 'report'] + options) def command_coverage_html(args): @@ -252,3 +257,14 @@ class CoverageConfig(EnvironmentConfig): self.group_by = frozenset(args.group_by) if 'group_by' in args and args.group_by else set() # type: frozenset[str] self.all = args.all if 'all' in args else False # type: bool self.stub = args.stub if 'stub' in args else False # type: bool + + +class CoverageReportConfig(CoverageConfig): + """Configuration for the coverage report command.""" + def __init__(self, args): + """ + :type args: any + """ + super(CoverageReportConfig, self).__init__(args) + + self.show_missing = args.show_missing # type: bool diff --git a/test/runner/test.py b/test/runner/test.py index 13a3c485b6..e3cec222e9 100755 --- a/test/runner/test.py +++ b/test/runner/test.py @@ -363,7 +363,11 @@ def parse_args(): help='generate console coverage report') coverage_report.set_defaults(func=lib.cover.command_coverage_report, - config=lib.cover.CoverageConfig) + config=lib.cover.CoverageReportConfig) + + coverage_report.add_argument('--show-missing', + action='store_true', + help='show line numbers of statements not executed') add_extra_coverage_options(coverage_report)