Integration test and sanity index generation fixes. (#75731)

* Fix test usage of `which python`.

Also use `command -v` instead of `which` where needed.

* Fix testing_formatter.sh file checking.

The index is longer expected to exist when generating it.
The generation script is run with `set -eux`.
pull/75743/head
Matt Clay 3 years ago committed by GitHub
parent b281f84bc4
commit 54a795896a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,7 @@
#!/bin/sh
set -eux
FILENAME=../docsite/rst/dev_guide/testing/sanity/index.rst
cat <<- EOF >$FILENAME.new
@ -23,10 +25,10 @@ EOF
# By default use sha1sum which exists on Linux, if not present select the correct binary
# based on platform defaults
SHA_CMD="sha1sum"
if ! which ${SHA_CMD} > /dev/null 2>&1; then
if which sha1 > /dev/null 2>&1; then
if ! command -v ${SHA_CMD} > /dev/null 2>&1; then
if command -v sha1 > /dev/null 2>&1; then
SHA_CMD="sha1"
elif which shasum > /dev/null 2>&1; then
elif command -v shasum > /dev/null 2>&1; then
SHA_CMD="shasum"
else
# exit early with an error if no hashing binary can be found since it is required later
@ -35,6 +37,6 @@ if ! which ${SHA_CMD} > /dev/null 2>&1; then
fi
# Put file into place if it has changed
if [ "$(${SHA_CMD} <$FILENAME)" != "$(${SHA_CMD} <$FILENAME.new)" ]; then
if [ ! -f "${FILENAME}" ] || [ "$(${SHA_CMD} <$FILENAME)" != "$(${SHA_CMD} <$FILENAME.new)" ]; then
mv -f $FILENAME.new $FILENAME
fi

@ -3,7 +3,7 @@
set -ux
echo "Checking if sshpass is present"
which sshpass 2>&1 || exit 0
command -v sshpass 2>&1 || exit 0
echo "sshpass is present, continuing with test"
sshpass -p my_password ansible-playbook -i inventory.ini test.yml -k "$@"

@ -30,10 +30,10 @@ PING_MODULE_PATH="../../../../lib/ansible/modules/ping.py"
../../../../hacking/test-module.py -m "$PING_MODULE_PATH"
# ensure test-module.py script works well
../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="$(which python)"
../../../../hacking/test-module.py -m "$PING_MODULE_PATH" -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}"
# ensure module.ansible_version is defined when using test-module.py
../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="$(which python)" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
../../../../hacking/test-module.py -m library/test.py -I ansible_python_interpreter="${ANSIBLE_TEST_PYTHON_INTERPRETER}" <<< '{"ANSIBLE_MODULE_ARGS": {}}'
# ensure exercising module code locally works
python -m ansible.modules.file <<< '{"ANSIBLE_MODULE_ARGS": {"path": "/path/to/file", "state": "absent"}}'

Loading…
Cancel
Save