ansible-test - Fix code coverage reporting. (#75771)

pull/75774/head
Matt Clay 3 years ago committed by GitHub
parent 43e1cba8c1
commit 6c133da45e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -67,10 +67,11 @@ def command_coverage_combine(args):
:rtype: list[str] :rtype: list[str]
""" """
host_state = prepare_profiles(args) # coverage combine host_state = prepare_profiles(args) # coverage combine
combine_coverage_files(args, host_state)
if args.delegate:
raise Delegate(host_state)
def combine_coverage_files(args, host_state): # type: (CoverageCombineConfig, HostState) -> t.List[str]
"""Combine coverage and return a list of the resulting files."""
if args.delegate: if args.delegate:
if isinstance(args.controller, (DockerConfig, RemoteConfig)): if isinstance(args.controller, (DockerConfig, RemoteConfig)):
paths = get_all_coverage_files() paths = get_all_coverage_files()

@ -20,7 +20,7 @@ from ...provisioning import (
) )
from .combine import ( from .combine import (
command_coverage_combine, combine_coverage_files,
CoverageCombineConfig, CoverageCombineConfig,
) )
@ -34,7 +34,7 @@ def command_coverage_html(args):
:type args: CoverageHtmlConfig :type args: CoverageHtmlConfig
""" """
host_state = prepare_profiles(args) # coverage html host_state = prepare_profiles(args) # coverage html
output_files = command_coverage_combine(args) output_files = combine_coverage_files(args, host_state)
for output_file in output_files: for output_file in output_files:
if output_file.endswith('-powershell'): if output_file.endswith('-powershell'):

@ -20,7 +20,7 @@ from ...provisioning import (
) )
from .combine import ( from .combine import (
command_coverage_combine, combine_coverage_files,
CoverageCombineConfig, CoverageCombineConfig,
) )
@ -34,7 +34,7 @@ def command_coverage_report(args):
:type args: CoverageReportConfig :type args: CoverageReportConfig
""" """
host_state = prepare_profiles(args) # coverage report host_state = prepare_profiles(args) # coverage report
output_files = command_coverage_combine(args) output_files = combine_coverage_files(args, host_state)
for output_file in output_files: for output_file in output_files:
if args.group_by or args.stub: if args.group_by or args.stub:

@ -38,7 +38,7 @@ from ...provisioning import (
) )
from .combine import ( from .combine import (
command_coverage_combine, combine_coverage_files,
CoverageCombineConfig, CoverageCombineConfig,
) )
@ -52,7 +52,7 @@ def command_coverage_xml(args):
:type args: CoverageXmlConfig :type args: CoverageXmlConfig
""" """
host_state = prepare_profiles(args) # coverage xml host_state = prepare_profiles(args) # coverage xml
output_files = command_coverage_combine(args) output_files = combine_coverage_files(args, host_state)
for output_file in output_files: for output_file in output_files:
xml_name = '%s.xml' % os.path.basename(output_file) xml_name = '%s.xml' % os.path.basename(output_file)

@ -369,6 +369,9 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do
def deprovision(self): # type: () -> None def deprovision(self): # type: () -> None
"""Deprovision the host after delegation has completed.""" """Deprovision the host after delegation has completed."""
if not self.container_name:
return # provision was never called or did not succeed, so there is no container to remove
if self.args.docker_terminate == TerminateMode.ALWAYS or (self.args.docker_terminate == TerminateMode.SUCCESS and self.args.success): if self.args.docker_terminate == TerminateMode.ALWAYS or (self.args.docker_terminate == TerminateMode.SUCCESS and self.args.success):
docker_rm(self.args, self.container_name) docker_rm(self.args, self.container_name)

Loading…
Cancel
Save