1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/test_infra/runme.sh
Karolis Tamutis 54384e7a12 Make test-module use default value for interpreter (#54053)
* Make test-module use default value for interpreter

* Changing from static interpreter path to sys.executable as per #54053

* A little ntegration test for #54053
2019-04-10 09:04:49 -05:00

39 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -ux
# ensure fail/assert work locally and can stop execution with non-zero exit code
PB_OUT=$(ansible-playbook -i inventory.local test_test_infra.yml)
APB_RC=$?
echo "$PB_OUT"
echo "rc was $APB_RC (must be non-zero)"
[ ${APB_RC} -ne 0 ]
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
# ensure we work using all specified test args, overridden inventory, etc
PB_OUT=$(ansible-playbook -i ../../inventory test_test_infra.yml "$@")
APB_RC=$?
echo "$PB_OUT"
echo "rc was $APB_RC (must be non-zero)"
[ ${APB_RC} -ne 0 ]
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
PING_MODULE_PATH="../../../../lib/ansible/modules/system/ping.py"
# ensure test-module script works without passing Python interpreter path
../../../../hacking/test-module -m "$PING_MODULE_PATH"
# ensure test-module script works well
../../../../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"}}'