Fix ansible-test coverage traceback when no data.
If no coverage directory exists, ansible-test coverage would traceback. Now it silently continues just as if the directory was present but empty.
This commit is contained in:
parent
2cbfd1e350
commit
e6af2d6827
2 changed files with 12 additions and 2 deletions
2
changelogs/fragments/ansible-test-coverage-traceback.yml
Normal file
2
changelogs/fragments/ansible-test-coverage-traceback.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ansible-test - Fix traceback when generating coverage reports and no coverage directory exists.
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -123,8 +124,15 @@ def get_powershell_coverage_files(path=None): # type: (t.Optional[str]) -> t.Li
|
||||||
def get_coverage_files(language, path=None): # type: (str, t.Optional[str]) -> t.List[str]
|
def get_coverage_files(language, path=None): # type: (str, t.Optional[str]) -> t.List[str]
|
||||||
"""Return the list of coverage file paths for the given language."""
|
"""Return the list of coverage file paths for the given language."""
|
||||||
coverage_dir = path or ResultType.COVERAGE.path
|
coverage_dir = path or ResultType.COVERAGE.path
|
||||||
|
|
||||||
|
try:
|
||||||
coverage_files = [os.path.join(coverage_dir, f) for f in os.listdir(coverage_dir)
|
coverage_files = [os.path.join(coverage_dir, f) for f in os.listdir(coverage_dir)
|
||||||
if '=coverage.' in f and '=%s' % language in f]
|
if '=coverage.' in f and '=%s' % language in f]
|
||||||
|
except IOError as ex:
|
||||||
|
if ex.errno == errno.ENOENT:
|
||||||
|
return []
|
||||||
|
|
||||||
|
raise
|
||||||
|
|
||||||
return coverage_files
|
return coverage_files
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue