summaryrefslogtreecommitdiff
path: root/test/integration/targets/test_infra
diff options
context:
space:
mode:
authorPierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>2018-10-08 01:46:49 +0200
committerMichael Scherer <mscherer@users.noreply.github.com>2018-10-18 09:45:56 +0200
commit7231f7da84e1fca40c467d4ca3dde12a1da2bf0d (patch)
treed4a8b361436cbe887a43439cb3575b46a16a08f4 /test/integration/targets/test_infra
parent5d2927c9a0b60e173826baf1609d0e69ccb6e55d (diff)
downloadansible-7231f7da84e1fca40c467d4ca3dde12a1da2bf0d.tar.gz
test-module: check availability of special attrs
Diffstat (limited to 'test/integration/targets/test_infra')
-rw-r--r--test/integration/targets/test_infra/library/test.py21
-rwxr-xr-xtest/integration/targets/test_infra/runme.sh5
2 files changed, 26 insertions, 0 deletions
diff --git a/test/integration/targets/test_infra/library/test.py b/test/integration/targets/test_infra/library/test.py
new file mode 100644
index 0000000000..9386057517
--- /dev/null
+++ b/test/integration/targets/test_infra/library/test.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(),
+ )
+ result = {
+ 'selinux_special_fs': module._selinux_special_fs,
+ 'tmpdir': module._tmpdir,
+ 'keep_remote_files': module._keep_remote_files,
+ 'version': module.ansible_version,
+ }
+ module.exit_json(**result)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/test_infra/runme.sh b/test/integration/targets/test_infra/runme.sh
index caa33fff3b..25d3f8104d 100755
--- a/test/integration/targets/test_infra/runme.sh
+++ b/test/integration/targets/test_infra/runme.sh
@@ -22,9 +22,14 @@ echo "ensure playbook output shows assert/fail works (True)"
echo "$PB_OUT" | grep -F "fail works (True)" || exit 1
echo "$PB_OUT" | grep -F "assert works (True)" || exit 1
+set -e
+
# ensure test-module script works well
PING_MODULE_PATH="$(pwd)/../../../../lib/ansible/modules/system/ping.py"
../../../../hacking/test-module -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"
+# ensure module.ansible_version is defined when using test-module
+../../../../hacking/test-module -m library/test.py -I ansible_python_interpreter="$(which python)" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
+
# ensure exercising module code locally works
python -m ansible.modules.files.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'