[stable-2.9] Fix ansible-test coverage exporting.

(cherry picked from commit b75844af45)
pull/74113/head
Matt Clay 5 years ago
parent 84e61b32f8
commit 7fa32b9b44

@ -0,0 +1,6 @@
bugfixes:
- ansible-test - The ``--export`` option for ``ansible-test coverage`` is now limited to the ``combine`` command.
It was previously available for reporting commands on which it had no effect.
- ansible-test - The ``ansible-test coverage combine`` option ``--export`` now exports relative paths.
This avoids loss of coverage data when aggregating across systems with different absolute paths.
Paths will be converted back to absolute when generating reports.

@ -505,6 +505,9 @@ def parse_args():
coverage_combine.set_defaults(func=command_coverage_combine,
config=CoverageConfig)
coverage_combine.add_argument('--export',
help='directory to export combined coverage files to')
add_extra_coverage_options(coverage_combine)
coverage_erase = coverage_subparsers.add_parser('erase',
@ -760,9 +763,6 @@ def add_extra_coverage_options(parser):
action='store_true',
help='generate empty report of all python/powershell source files')
parser.add_argument('--export',
help='directory to export combined coverage files to')
def add_httptester_options(parser, argparse):
"""

@ -138,6 +138,9 @@ def _command_coverage_combine_python(args):
if not filename:
continue
if args.export:
filename = os.path.relpath(filename) # exported paths must be relative since absolute paths may differ between systems
if group not in groups:
groups[group] = {}
@ -313,6 +316,8 @@ def _sanitise_filename(filename, modules=None, collection_search_re=None, collec
display.info('%s -> %s' % (filename, new_name), verbosity=3)
filename = new_name
filename = os.path.abspath(filename) # make sure path is absolute (will be relative if previously exported)
return filename
@ -510,6 +515,9 @@ def _command_coverage_combine_powershell(args):
if not filename:
continue
if args.export:
filename = os.path.relpath(filename) # exported paths must be relative since absolute paths may differ between systems
if isinstance(hit_info, dict) and not hit_info.get('Line'):
# Input data was previously aggregated and thus uses the standard ansible-test output format for PowerShell coverage.
# This format differs from the more verbose format of raw coverage data from the remote Windows hosts.

Loading…
Cancel
Save