From 8612b126a84720d0e0ecbce670b843e7741e1197 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 27 Mar 2019 02:42:11 -0700 Subject: [PATCH] Fix tests which assume `virtualenv` is available. --- test/integration/targets/filters/runme.sh | 5 ++--- test/integration/targets/groupby_filter/runme.sh | 11 ++--------- .../targets/inventory_aws_conformance/runme.sh | 6 +++--- test/integration/targets/lookups/runme.sh | 5 ++--- .../targets/template_jinja2_latest/runme.sh | 11 ++--------- test/runner/injector/virtualenv.sh | 5 +++++ 6 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 test/runner/injector/virtualenv.sh diff --git a/test/integration/targets/filters/runme.sh b/test/integration/targets/filters/runme.sh index e1e1333cac..d2a38f5900 100755 --- a/test/integration/targets/filters/runme.sh +++ b/test/integration/targets/filters/runme.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -ex -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv" -source "${OUTPUT_DIR}/venv/bin/activate" set -eux +source virtualenv.sh + # Requirements have to be installed prior to running ansible-playbook # because plugins and requirements are loaded before the task runs diff --git a/test/integration/targets/groupby_filter/runme.sh b/test/integration/targets/groupby_filter/runme.sh index f65cc008f6..e5099aa1b7 100755 --- a/test/integration/targets/groupby_filter/runme.sh +++ b/test/integration/targets/groupby_filter/runme.sh @@ -1,15 +1,8 @@ #!/usr/bin/env bash -# We don't set -u here, due to pypa/virtualenv#150 -set -ex +set -eux -MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') - -trap 'rm -rf "${MYTMPDIR}"' EXIT - -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${MYTMPDIR}/jinja2" - -source "${MYTMPDIR}/jinja2/bin/activate" +source virtualenv.sh pip install -U jinja2==2.9.4 diff --git a/test/integration/targets/inventory_aws_conformance/runme.sh b/test/integration/targets/inventory_aws_conformance/runme.sh index c4208d1fdf..a57e13ec39 100755 --- a/test/integration/targets/inventory_aws_conformance/runme.sh +++ b/test/integration/targets/inventory_aws_conformance/runme.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -set -ex +set -eux + +source virtualenv.sh -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER:-python}" "${OUTPUT_DIR}/aws-ec2-inventory" -source "${OUTPUT_DIR}/aws-ec2-inventory/bin/activate" pip install "python-dateutil>=2.1,<2.7.0" jmespath "Jinja2>=2.10" PyYaml cryptography paramiko # create boto3 symlinks diff --git a/test/integration/targets/lookups/runme.sh b/test/integration/targets/lookups/runme.sh index a54fbfd4a8..77a73b9975 100755 --- a/test/integration/targets/lookups/runme.sh +++ b/test/integration/targets/lookups/runme.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -ex -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv" -source "${OUTPUT_DIR}/venv/bin/activate" set -eux +source virtualenv.sh + # Requirements have to be installed prior to running ansible-playbook # because plugins and requirements are loaded before the task runs pip install passlib diff --git a/test/integration/targets/template_jinja2_latest/runme.sh b/test/integration/targets/template_jinja2_latest/runme.sh index 88df296224..78dcf36fcd 100755 --- a/test/integration/targets/template_jinja2_latest/runme.sh +++ b/test/integration/targets/template_jinja2_latest/runme.sh @@ -1,15 +1,8 @@ #!/usr/bin/env bash -# We don't set -u here, due to pypa/virtualenv#150 -set -ex +set -eux -MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') - -trap 'rm -rf "${MYTMPDIR}"' EXIT - -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${MYTMPDIR}/jinja2" - -source "${MYTMPDIR}/jinja2/bin/activate" +source virtualenv.sh pip install -U jinja2 diff --git a/test/runner/injector/virtualenv.sh b/test/runner/injector/virtualenv.sh new file mode 100644 index 0000000000..c6633a2521 --- /dev/null +++ b/test/runner/injector/virtualenv.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Create and activate a fresh virtual environment with `source virtualenv.sh`. + +rm -rf "${OUTPUT_DIR}/venv" +"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"