diff options
Diffstat (limited to 'test/lib/ansible_test/_internal/provider')
3 files changed, 25 insertions, 2 deletions
diff --git a/test/lib/ansible_test/_internal/provider/layout/__init__.py b/test/lib/ansible_test/_internal/provider/layout/__init__.py index 4eca05cedb..a0a0609be5 100644 --- a/test/lib/ansible_test/_internal/provider/layout/__init__.py +++ b/test/lib/ansible_test/_internal/provider/layout/__init__.py @@ -95,7 +95,7 @@ class ContentLayout(Layout): unit_module_path: str, unit_module_utils_path: str, unit_messages: t.Optional[LayoutMessages], - unsupported: bool = False, + unsupported: bool | list[str] = False, ) -> None: super().__init__(root, paths) diff --git a/test/lib/ansible_test/_internal/provider/layout/ansible.py b/test/lib/ansible_test/_internal/provider/layout/ansible.py index d2f8cc818a..3ee818a5b5 100644 --- a/test/lib/ansible_test/_internal/provider/layout/ansible.py +++ b/test/lib/ansible_test/_internal/provider/layout/ansible.py @@ -8,6 +8,11 @@ from . import ( LayoutProvider, ) +from ...util import ( + ANSIBLE_SOURCE_ROOT, + ANSIBLE_TEST_ROOT, +) + class AnsibleLayout(LayoutProvider): """Layout provider for Ansible source.""" @@ -26,6 +31,15 @@ class AnsibleLayout(LayoutProvider): module_utils='lib/ansible/module_utils', ) + errors: list[str] = [] + + if root != ANSIBLE_SOURCE_ROOT: + errors.extend(( + f'Cannot test "{root}" with ansible-test from "{ANSIBLE_TEST_ROOT}".', + '', + f'Did you intend to run "{root}/bin/ansible-test" instead?', + )) + return ContentLayout( root, paths, @@ -43,4 +57,5 @@ class AnsibleLayout(LayoutProvider): unit_module_path='test/units/modules', unit_module_utils_path='test/units/module_utils', unit_messages=None, + unsupported=errors, ) diff --git a/test/lib/ansible_test/_internal/provider/layout/collection.py b/test/lib/ansible_test/_internal/provider/layout/collection.py index d747f31f31..a9221be6f3 100644 --- a/test/lib/ansible_test/_internal/provider/layout/collection.py +++ b/test/lib/ansible_test/_internal/provider/layout/collection.py @@ -53,6 +53,14 @@ class CollectionLayout(LayoutProvider): integration_targets_path = self.__check_integration_path(paths, integration_messages) self.__check_unit_path(paths, unit_messages) + errors: list[str] = [] + + if not is_valid_identifier(collection_namespace): + errors.append(f'The namespace "{collection_namespace}" is an invalid identifier or a reserved keyword.') + + if not is_valid_identifier(collection_name): + errors.append(f'The name "{collection_name}" is an invalid identifier or a reserved keyword.') + return ContentLayout( root, paths, @@ -74,7 +82,7 @@ class CollectionLayout(LayoutProvider): unit_module_path='tests/unit/plugins/modules', unit_module_utils_path='tests/unit/plugins/module_utils', unit_messages=unit_messages, - unsupported=not (is_valid_identifier(collection_namespace) and is_valid_identifier(collection_name)), + unsupported=errors, ) @staticmethod |