[stable-2.10] Update ansible-test change detection for plugins.

(cherry picked from commit 09f02980a4)

Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
Matt Clay 2020-03-19 21:15:05 -07:00
parent 957f0c27fc
commit ddc78622a4
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - integration and unit test change detection now works for filter, lookup and test plugins

View file

@ -608,6 +608,12 @@ class PathMapper:
FOCUSED_TARGET: target is not None,
}
if is_subdir(path, data_context().content.plugin_paths['filter']):
return self._simple_plugin_tests('filter', name)
if is_subdir(path, data_context().content.plugin_paths['lookup']):
return self._simple_plugin_tests('lookup', name)
if (is_subdir(path, data_context().content.plugin_paths['terminal']) or
is_subdir(path, data_context().content.plugin_paths['cliconf']) or
is_subdir(path, data_context().content.plugin_paths['netconf'])):
@ -632,6 +638,9 @@ class PathMapper:
'units': 'all',
}
if is_subdir(path, data_context().content.plugin_paths['test']):
return self._simple_plugin_tests('test', name)
return None
def _classify_collection(self, path): # type: (str) -> t.Optional[t.Dict[str, str]]
@ -874,6 +883,31 @@ class PathMapper:
return None # unknown, will result in fall-back to run all tests
def _simple_plugin_tests(self, plugin_type, plugin_name): # type: (str, str) -> t.Dict[str, t.Optional[str]]
"""
Return tests for the given plugin type and plugin name.
This function is useful for plugin types which do not require special processing.
"""
if plugin_name == '__init__':
return all_tests(self.args, True)
integration_target = self.integration_targets_by_name.get('%s_%s' % (plugin_type, plugin_name))
if integration_target:
integration_name = integration_target.name
else:
integration_name = None
units_path = os.path.join(data_context().content.unit_path, 'plugins', plugin_type, 'test_%s.py' % plugin_name)
if units_path not in self.units_paths:
units_path = None
return dict(
integration=integration_name,
units=units_path,
)
def all_tests(args, force=False):
"""