ansible-test - Fix ansible-doc sanity test FQCN. (#78518)

pull/78521/head
Matt Clay 2 years ago committed by GitHub
parent 9eb3d6811b
commit 2b63fdd1b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- ansible-test - ansible-doc sanity test - Correctly determine the fully-qualified collection name for plugins in
subdirectories, resolving https://github.com/ansible/ansible/issues/78490.

@ -0,0 +1,4 @@
shippable/posix/group3 # runs in the distro test containers
shippable/generic/group1 # runs in the default test container
context/controller
needs/target/collection

@ -0,0 +1,28 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = """
name: lookup2
author: Ansible Core Team
short_description: hello test lookup
description:
- Hello test lookup.
options: {}
"""
EXAMPLES = """
- minimal:
"""
RETURN = """
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
return []

@ -0,0 +1,28 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = """
name: lookup1
author: Ansible Core Team
short_description: hello test lookup
description:
- Hello test lookup.
options: {}
"""
EXAMPLES = """
- minimal:
"""
RETURN = """
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
return []

@ -0,0 +1,34 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
module: module2
short_description: Hello test module
description: Hello test module.
options: {}
author:
- Ansible Core Team
'''
EXAMPLES = '''
- minimal:
'''
RETURN = ''''''
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec={},
)
module.exit_json()
if __name__ == '__main__':
main()

@ -0,0 +1,34 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
module: module1
short_description: Hello test module
description: Hello test module.
options: {}
author:
- Ansible Core Team
'''
EXAMPLES = '''
- minimal:
'''
RETURN = ''''''
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec={},
)
module.exit_json()
if __name__ == '__main__':
main()

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -eu
source ../collection/setup.sh
set -x
ansible-test sanity --test ansible-doc --color "${@}"

@ -64,7 +64,6 @@ class AnsibleDocTest(SanitySingleVersion):
paths = [target.path for target in targets.include]
doc_targets: dict[str, list[str]] = collections.defaultdict(list)
target_paths: dict[str, dict[str, str]] = collections.defaultdict(dict)
remap_types = dict(
modules='module',
@ -74,13 +73,15 @@ class AnsibleDocTest(SanitySingleVersion):
plugin_type = remap_types.get(plugin_type, plugin_type)
for plugin_file_path in [target.name for target in targets.include if is_subdir(target.path, plugin_path)]:
plugin_name = os.path.splitext(os.path.basename(plugin_file_path))[0]
plugin_parts = os.path.relpath(plugin_file_path, plugin_path).split(os.path.sep)
plugin_name = os.path.splitext(plugin_parts[-1])[0]
if plugin_name.startswith('_'):
plugin_name = plugin_name[1:]
doc_targets[plugin_type].append(data_context().content.prefix + plugin_name)
target_paths[plugin_type][data_context().content.prefix + plugin_name] = plugin_file_path
plugin_fqcn = data_context().content.prefix + '.'.join(plugin_parts[:-1] + [plugin_name])
doc_targets[plugin_type].append(plugin_fqcn)
env = ansible_environment(args, color=False)
error_messages: list[SanityMessage] = []

Loading…
Cancel
Save