Report error for coverage 5+ in ansible-test.
This commit is contained in:
parent
27fc049993
commit
d8b5c11a63
2 changed files with 28 additions and 1 deletions
|
@ -0,0 +1,3 @@
|
|||
minor_changes:
|
||||
- ansible-test now checks for the minimum and maximum supported versions when importing ``coverage``
|
||||
- ansible-test now provides a more helpful error when loading coverage files created by ``coverage`` version 5 or later
|
|
@ -12,6 +12,7 @@ from ..encoding import (
|
|||
)
|
||||
|
||||
from ..io import (
|
||||
open_binary_file,
|
||||
read_json_file,
|
||||
)
|
||||
|
||||
|
@ -79,6 +80,22 @@ def initialize_coverage(args): # type: (CoverageConfig) -> coverage_module
|
|||
if not coverage:
|
||||
raise ApplicationError('You must install the "coverage" python module to use this command.')
|
||||
|
||||
coverage_version_string = coverage.__version__
|
||||
coverage_version = tuple(int(v) for v in coverage_version_string.split('.'))
|
||||
|
||||
min_version = (4, 2)
|
||||
max_version = (5, 0)
|
||||
|
||||
supported_version = True
|
||||
recommended_version = '4.5.4'
|
||||
|
||||
if coverage_version < min_version or coverage_version >= max_version:
|
||||
supported_version = False
|
||||
|
||||
if not supported_version:
|
||||
raise ApplicationError('Version %s of "coverage" is not supported. Version %s is known to work and is recommended.' % (
|
||||
coverage_version_string, recommended_version))
|
||||
|
||||
return coverage
|
||||
|
||||
|
||||
|
@ -145,7 +162,14 @@ def enumerate_python_arcs(
|
|||
try:
|
||||
original.read_file(path)
|
||||
except Exception as ex: # pylint: disable=locally-disabled, broad-except
|
||||
display.error(u'%s' % ex)
|
||||
with open_binary_file(path) as file:
|
||||
header = file.read(6)
|
||||
|
||||
if header == b'SQLite':
|
||||
display.error('File created by "coverage" 5.0+: %s' % os.path.relpath(path))
|
||||
else:
|
||||
display.error(u'%s' % ex)
|
||||
|
||||
return
|
||||
|
||||
for filename in original.measured_files():
|
||||
|
|
Loading…
Reference in a new issue