mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
Miscellaneous bug fixes for ansible-test.
- Overhauled coverage injector to fix issues with non-local tests. - Updated integration tests to work with the new coverage injector. - Fix concurrency issue by using random temp files for delegation. - Fix handling of coverage files from root user. - Fix handling of coverage files without arcs. - Make sure temp copy of injector is world readable and executable.
This commit is contained in:
parent
548cacdf6a
commit
dfd19a812f
26 changed files with 259 additions and 155 deletions
|
@ -33,8 +33,7 @@ def command_coverage_combine(args):
|
|||
|
||||
modules = dict((t.module, t.path) for t in list(walk_module_targets()))
|
||||
|
||||
coverage_files = [os.path.join(COVERAGE_DIR, f) for f in os.listdir(COVERAGE_DIR)
|
||||
if f.startswith('coverage') and f != 'coverage']
|
||||
coverage_files = [os.path.join(COVERAGE_DIR, f) for f in os.listdir(COVERAGE_DIR) if '=coverage.' in f]
|
||||
|
||||
arc_data = {}
|
||||
|
||||
|
@ -60,7 +59,12 @@ def command_coverage_combine(args):
|
|||
continue
|
||||
|
||||
for filename in original.measured_files():
|
||||
arcs = set(original.arcs(filename))
|
||||
arcs = set(original.arcs(filename) or [])
|
||||
|
||||
if not arcs:
|
||||
# This is most likely due to using an unsupported version of coverage.
|
||||
display.warning('No arcs found for "%s" in coverage file: %s' % (filename, coverage_file))
|
||||
continue
|
||||
|
||||
if '/ansible_modlib.zip/ansible/' in filename:
|
||||
new_name = re.sub('^.*/ansible_modlib.zip/ansible/', ansible_path, filename)
|
||||
|
@ -68,11 +72,14 @@ def command_coverage_combine(args):
|
|||
filename = new_name
|
||||
elif '/ansible_module_' in filename:
|
||||
module = re.sub('^.*/ansible_module_(?P<module>.*).py$', '\\g<module>', filename)
|
||||
if module not in modules:
|
||||
display.warning('Skipping coverage of unknown module: %s' % module)
|
||||
continue
|
||||
new_name = os.path.abspath(modules[module])
|
||||
display.info('%s -> %s' % (filename, new_name), verbosity=3)
|
||||
filename = new_name
|
||||
elif filename.startswith('/root/ansible/'):
|
||||
new_name = re.sub('^/.*?/ansible/', root_path, filename)
|
||||
elif re.search('^(/.*?)?/root/ansible/', filename):
|
||||
new_name = re.sub('^(/.*?)?/root/ansible/', root_path, filename)
|
||||
display.info('%s -> %s' % (filename, new_name), verbosity=3)
|
||||
filename = new_name
|
||||
|
||||
|
@ -125,7 +132,7 @@ def command_coverage_erase(args):
|
|||
initialize_coverage(args)
|
||||
|
||||
for name in os.listdir(COVERAGE_DIR):
|
||||
if not name.startswith('coverage'):
|
||||
if not name.startswith('coverage') and '=coverage.' not in name:
|
||||
continue
|
||||
|
||||
path = os.path.join(COVERAGE_DIR, name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue