From 50442f9fdd0c3e24489e6db3942b11a1180d8cf2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 6 Mar 2020 15:14:59 -0800 Subject: [PATCH] Fix ansible-test handling of no Python coverage. --- changelogs/fragments/ansible-test-empty-coverage.yml | 2 ++ test/lib/ansible_test/_internal/coverage/combine.py | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ansible-test-empty-coverage.yml diff --git a/changelogs/fragments/ansible-test-empty-coverage.yml b/changelogs/fragments/ansible-test-empty-coverage.yml new file mode 100644 index 00000000000..63dda102975 --- /dev/null +++ b/changelogs/fragments/ansible-test-empty-coverage.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test no longer errors reporting coverage when no Python coverage exists. This fixes issues reporting on PowerShell only coverage from collections. diff --git a/test/lib/ansible_test/_internal/coverage/combine.py b/test/lib/ansible_test/_internal/coverage/combine.py index bb2474b1a01..28986b2354a 100644 --- a/test/lib/ansible_test/_internal/coverage/combine.py +++ b/test/lib/ansible_test/_internal/coverage/combine.py @@ -110,8 +110,11 @@ def _command_coverage_combine_python(args): if not args.explain: output_file = coverage_file + group - updated.write_file(output_file) - output_files.append(output_file) + updated.write_file(output_file) # always write files to make sure stale files do not exist + + if updated: + # only report files which are non-empty to prevent coverage from reporting errors + output_files.append(output_file) path_checker.report()