mirror of https://github.com/ansible/ansible.git
ansible-test - Allow multiple documents in the YAML stream for EXAMPLES (#82355)
* Allow multiple documents in the YAML stream for EXAMPLES. * Add integration test * lintingpull/81918/head
parent
8328153121
commit
5346009d2c
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- ansible-test - sanity test allows ``EXAMPLES`` to be multi-document YAML (https://github.com/ansible/ansible/issues/82353).
|
||||||
|
- ansible-test - document block name now included in error message for YAML parsing errors (https://github.com/ansible/ansible/issues/82353).
|
@ -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,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
---
|
||||||
|
module: module2
|
||||||
|
short_description: Hello test module
|
||||||
|
description: Hello test module.
|
||||||
|
options:
|
||||||
|
plugin:
|
||||||
|
required: true
|
||||||
|
description: name of the plugin (cache_host)
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
---
|
||||||
|
|
||||||
|
first_doc:
|
||||||
|
some_key:
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
second_doc:
|
||||||
|
some_key:
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
---
|
||||||
|
---
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||||
|
|
||||||
|
|
||||||
|
class InventoryModule(BaseInventoryPlugin):
|
||||||
|
|
||||||
|
NAME = 'inventory1'
|
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
DOCUMENTATION = r"""
|
||||||
|
module: module1
|
||||||
|
short_description: Hello test module
|
||||||
|
description: Hello test module.
|
||||||
|
options: {}
|
||||||
|
author:
|
||||||
|
- Ansible Core Team
|
||||||
|
short_description: Duplicate short description
|
||||||
|
"""
|
||||||
|
|
||||||
|
EXAMPLES = r"""
|
||||||
|
- minimal:
|
||||||
|
"""
|
||||||
|
|
||||||
|
RETURN = r"""
|
||||||
|
invalid_yaml:
|
||||||
|
bad_indent:
|
||||||
|
usual_indent:
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module = AnsibleModule(
|
||||||
|
argument_spec={},
|
||||||
|
)
|
||||||
|
|
||||||
|
module.exit_json()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -0,0 +1,4 @@
|
|||||||
|
plugins/inventory/inventory1.py:34:1: multiple-yaml-documents: RETURN: expected a single document in the stream
|
||||||
|
plugins/modules/module1.py:15:1: key-duplicates: DOCUMENTATION: duplication of key "short_description" in mapping
|
||||||
|
plugins/modules/module1.py:25:3: error: RETURN: syntax error: expected <block end>, but found '<block mapping start>' (syntax)
|
||||||
|
plugins/modules/module1.py:25:3: unparsable-with-libyaml: RETURN: while parsing a block mapping - did not find expected key
|
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
source ../collection/setup.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
ansible-test sanity --test yamllint --color --lint --failure-ok "${@}" > actual.txt
|
||||||
|
|
||||||
|
diff -u "${TEST_DIR}/expected.txt" actual.txt
|
Loading…
Reference in New Issue