Fix ansible-test layout path generation.

pull/60173/head
Matt Clay 5 years ago
parent 233efe0886
commit 9da5908afb

@ -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."""

@ -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',
)

@ -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',
)

Loading…
Cancel
Save