From 9da5908afba1453040b32747a6707bd373ad0ff2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 6 Aug 2019 15:13:02 -0700 Subject: [PATCH] Fix ansible-test layout path generation. --- .../_internal/provider/layout/__init__.py | 30 ++++++++++++++----- .../_internal/provider/layout/ansible.py | 10 +------ .../_internal/provider/layout/collection.py | 10 +------ 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/test/lib/ansible_test/_internal/provider/layout/__init__.py b/test/lib/ansible_test/_internal/provider/layout/__init__.py index 87f85ccc48d..3daf28e4cce 100644 --- a/test/lib/ansible_test/_internal/provider/layout/__init__.py +++ b/test/lib/ansible_test/_internal/provider/layout/__init__.py @@ -74,26 +74,18 @@ class ContentLayout(Layout): root, # type: str paths, # type: t.List[str] plugin_paths, # type: t.Dict[str, str] - provider_paths, # type: t.Dict[str, str] - code_path=None, # type: t.Optional[str] collection=None, # type: t.Optional[CollectionDetail] - util_path=None, # type: t.Optional[str] unit_path=None, # type: t.Optional[str] unit_module_path=None, # type: t.Optional[str] unit_module_utils_path=None, # type: t.Optional[str] - integration_path=None, # type: t.Optional[str] ): # type: (...) -> None super(ContentLayout, self).__init__(root, paths) self.plugin_paths = plugin_paths - self.provider_paths = provider_paths - self.code_path = code_path self.collection = collection - self.util_path = util_path self.unit_path = unit_path self.unit_module_path = unit_module_path self.unit_module_utils_path = unit_module_utils_path - self.integration_path = integration_path self.is_ansible = root == ANSIBLE_ROOT @property @@ -148,6 +140,28 @@ class CollectionDetail: class LayoutProvider(PathProvider): """Base class for layout providers.""" + PLUGIN_TYPES = ( + 'action', + 'become', + 'cache', + 'callback', + 'cliconf', + 'connection', + 'doc_fragments', + 'filter', + 'httpapi', + 'inventory', + 'lookup', + 'module_utils', + 'modules', + 'netconf', + 'shell', + 'strategy', + 'terminal', + 'test', + 'vars', + ) + @abc.abstractmethod def create(self, root, paths): # type: (str, t.List[str]) -> ContentLayout """Create a layout using the given root and paths.""" diff --git a/test/lib/ansible_test/_internal/provider/layout/ansible.py b/test/lib/ansible_test/_internal/provider/layout/ansible.py index bbf076bdfe6..4ed6e835a40 100644 --- a/test/lib/ansible_test/_internal/provider/layout/ansible.py +++ b/test/lib/ansible_test/_internal/provider/layout/ansible.py @@ -26,11 +26,7 @@ class AnsibleLayout(LayoutProvider): def create(self, root, paths): # type: (str, t.List[str]) -> ContentLayout """Create a Layout using the given root and paths.""" - plugin_types = sorted(set(p.split('/')[3] for p in paths if re.search(r'^lib/ansible/plugins/[^/]+/', p))) - provider_types = sorted(set(p.split('/')[5] for p in paths if re.search(r'^test/lib/ansible_test/_internal/provider/[^/]+/', p))) - - plugin_paths = dict((p, os.path.join('lib/ansible/plugins', p)) for p in plugin_types) - provider_paths = dict((p, os.path.join(ANSIBLE_TEST_ROOT, '_internal/provider', p)) for p in provider_types) + plugin_paths = dict((p, os.path.join('lib/ansible/plugins', p)) for p in self.PLUGIN_TYPES) plugin_paths.update(dict( modules='lib/ansible/modules', @@ -40,11 +36,7 @@ class AnsibleLayout(LayoutProvider): return ContentLayout(root, paths, plugin_paths=plugin_paths, - provider_paths=provider_paths, - code_path='lib/ansible', - util_path='test/utils', unit_path='test/units', unit_module_path='test/units/modules', unit_module_utils_path='test/units/module_utils', - integration_path='test/integration', ) diff --git a/test/lib/ansible_test/_internal/provider/layout/collection.py b/test/lib/ansible_test/_internal/provider/layout/collection.py index 2c778c07c0b..a09f0bfd031 100644 --- a/test/lib/ansible_test/_internal/provider/layout/collection.py +++ b/test/lib/ansible_test/_internal/provider/layout/collection.py @@ -29,11 +29,7 @@ class CollectionLayout(LayoutProvider): def create(self, root, paths): # type: (str, t.List[str]) -> ContentLayout """Create a Layout using the given root and paths.""" - plugin_types = sorted(set(p.split('/')[1] for p in paths if re.search(r'^plugins/[^/]+/', p))) - provider_types = sorted(set(p.split('/')[2] for p in paths if re.search(r'^test/provider/[^/]+/', p))) - - plugin_paths = dict((p, os.path.join('plugins', p)) for p in plugin_types) - provider_paths = dict((p, os.path.join('test/provider', p)) for p in provider_types) + plugin_paths = dict((p, os.path.join('plugins', p)) for p in self.PLUGIN_TYPES) collection_root = os.path.dirname(os.path.dirname(root)) collection_dir = os.path.relpath(root, collection_root) @@ -45,17 +41,13 @@ class CollectionLayout(LayoutProvider): return ContentLayout(root, paths, plugin_paths=plugin_paths, - provider_paths=provider_paths, - code_path='', collection=CollectionDetail( name=collection_name, namespace=collection_namespace, root=collection_root, prefix=collection_prefix, ), - util_path='test/util', unit_path='test/unit', unit_module_path='test/unit/plugins/modules', unit_module_utils_path='test/unit/plugins/module_utils', - integration_path='test/integration', )