From 864bd941affc1b2285711cc25785e1d2cebe1bbb Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 6 May 2019 15:46:47 -0400 Subject: [PATCH] Add support for isolated virtualenv in tests. --- test/runner/injector/virtualenv-isolated.sh | 12 ++++++++++++ test/runner/lib/executor.py | 1 + 2 files changed, 13 insertions(+) create mode 100644 test/runner/injector/virtualenv-isolated.sh diff --git a/test/runner/injector/virtualenv-isolated.sh b/test/runner/injector/virtualenv-isolated.sh new file mode 100644 index 0000000000..82f799809e --- /dev/null +++ b/test/runner/injector/virtualenv-isolated.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Create and activate a fresh virtual environment with `source virtualenv-isolated.sh`. + +rm -rf "${OUTPUT_DIR}/venv" +"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv" +set +ux +source "${OUTPUT_DIR}/venv/bin/activate" +set -ux + +if [[ "${ANSIBLE_TEST_COVERAGE}" ]]; then + pip install coverage -c ../../../runner/requirements/constraints.txt --disable-pip-version-check +fi diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index 4e6d1b440f..054b964c3b 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -1152,6 +1152,7 @@ def integration_environment(args, target, test_dir, inventory_path, ansible_conf JUNIT_OUTPUT_DIR=os.path.abspath('test/results/junit'), ANSIBLE_CALLBACK_WHITELIST=','.join(sorted(set(callback_plugins))), ANSIBLE_TEST_CI=args.metadata.ci_provider, + ANSIBLE_TEST_COVERAGE='check' if args.coverage_check else ('yes' if args.coverage else ''), OUTPUT_DIR=test_dir, INVENTORY_PATH=os.path.abspath(inventory_path), )