diff options
author | Matt Clay <mclay@redhat.com> | 2021-09-23 21:24:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 21:24:01 -0700 |
commit | 6c133da45e11fbd8d753060cbbf052d785f027be (patch) | |
tree | e4322be2aa5cb07032c390431aee6f9c9b911c27 | |
parent | 43e1cba8c137e045019794b8de6b444fab37c24a (diff) | |
download | ansible-6c133da45e11fbd8d753060cbbf052d785f027be.tar.gz |
ansible-test - Fix code coverage reporting. (#75771)
5 files changed, 12 insertions, 8 deletions
diff --git a/test/lib/ansible_test/_internal/commands/coverage/combine.py b/test/lib/ansible_test/_internal/commands/coverage/combine.py index b96e2ba05a..15334ddaec 100644 --- a/test/lib/ansible_test/_internal/commands/coverage/combine.py +++ b/test/lib/ansible_test/_internal/commands/coverage/combine.py @@ -67,10 +67,11 @@ def command_coverage_combine(args): :rtype: list[str] """ 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 isinstance(args.controller, (DockerConfig, RemoteConfig)): paths = get_all_coverage_files() diff --git a/test/lib/ansible_test/_internal/commands/coverage/html.py b/test/lib/ansible_test/_internal/commands/coverage/html.py index c4053a631a..dc520898df 100644 --- a/test/lib/ansible_test/_internal/commands/coverage/html.py +++ b/test/lib/ansible_test/_internal/commands/coverage/html.py @@ -20,7 +20,7 @@ from ...provisioning import ( ) from .combine import ( - command_coverage_combine, + combine_coverage_files, CoverageCombineConfig, ) @@ -34,7 +34,7 @@ def command_coverage_html(args): :type args: CoverageHtmlConfig """ 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: if output_file.endswith('-powershell'): diff --git a/test/lib/ansible_test/_internal/commands/coverage/report.py b/test/lib/ansible_test/_internal/commands/coverage/report.py index d5a6ecd8f9..aa62ac449e 100644 --- a/test/lib/ansible_test/_internal/commands/coverage/report.py +++ b/test/lib/ansible_test/_internal/commands/coverage/report.py @@ -20,7 +20,7 @@ from ...provisioning import ( ) from .combine import ( - command_coverage_combine, + combine_coverage_files, CoverageCombineConfig, ) @@ -34,7 +34,7 @@ def command_coverage_report(args): :type args: CoverageReportConfig """ 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: if args.group_by or args.stub: diff --git a/test/lib/ansible_test/_internal/commands/coverage/xml.py b/test/lib/ansible_test/_internal/commands/coverage/xml.py index 6938924029..1298232f89 100644 --- a/test/lib/ansible_test/_internal/commands/coverage/xml.py +++ b/test/lib/ansible_test/_internal/commands/coverage/xml.py @@ -38,7 +38,7 @@ from ...provisioning import ( ) from .combine import ( - command_coverage_combine, + combine_coverage_files, CoverageCombineConfig, ) @@ -52,7 +52,7 @@ def command_coverage_xml(args): :type args: CoverageXmlConfig """ 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: xml_name = '%s.xml' % os.path.basename(output_file) diff --git a/test/lib/ansible_test/_internal/host_profiles.py b/test/lib/ansible_test/_internal/host_profiles.py index ae33eb0749..2f6884c2c6 100644 --- a/test/lib/ansible_test/_internal/host_profiles.py +++ b/test/lib/ansible_test/_internal/host_profiles.py @@ -369,6 +369,9 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do def deprovision(self): # type: () -> None """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): docker_rm(self.args, self.container_name) |