linux: run tests in a subshell, only create env if test defined
This commit is contained in:
+15
-8
@@ -85,29 +85,36 @@ def build(project_dir, output_dir, test_command, test_requires, test_extras, bef
|
|||||||
fi
|
fi
|
||||||
delocated_wheel=(/tmp/delocated_wheel/*.whl)
|
delocated_wheel=(/tmp/delocated_wheel/*.whl)
|
||||||
|
|
||||||
|
if [ ! -z {test_command} ]; then
|
||||||
# Set up a virtual environment to install and test from, to make sure
|
# Set up a virtual environment to install and test from, to make sure
|
||||||
# there are no dependencies that were pulled in at build time.
|
# there are no dependencies that were pulled in at build time.
|
||||||
"$PYBIN/pip" install virtualenv
|
"$PYBIN/pip" install virtualenv
|
||||||
venv_dir=`mktemp -d`/venv
|
venv_dir=`mktemp -d`/venv
|
||||||
"$PYBIN/python" -m virtualenv $venv_dir
|
"$PYBIN/python" -m virtualenv "$venv_dir"
|
||||||
source $venv_dir/bin/activate
|
|
||||||
|
|
||||||
# Check that we are using the Python from the virtual environment
|
# run the tests in a subshell to keep that `activate`
|
||||||
which python
|
# script from polluting the env
|
||||||
|
(
|
||||||
|
source "$venv_dir/bin/activate"
|
||||||
|
|
||||||
|
echo "Running tests using `which python`"
|
||||||
|
|
||||||
# Install the wheel we just built
|
# Install the wheel we just built
|
||||||
"$PYBIN/pip" install "$delocated_wheel"{test_extras}
|
pip install "$delocated_wheel"{test_extras}
|
||||||
|
|
||||||
# Install any requirements to run the tests
|
# Install any requirements to run the tests
|
||||||
if [ ! -z "{test_requires}" ]; then
|
if [ ! -z "{test_requires}" ]; then
|
||||||
"$PYBIN/pip" install {test_requires}
|
pip install {test_requires}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the tests from a different directory
|
# Run the tests from a different directory
|
||||||
if [ ! -z {test_command} ]; then
|
|
||||||
pushd $HOME
|
pushd $HOME
|
||||||
PATH="$PYBIN:$PATH" sh -c {test_command}
|
sh -c {test_command}
|
||||||
popd
|
popd
|
||||||
|
)
|
||||||
|
|
||||||
|
# clean up
|
||||||
|
rm -rf "$venv_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we're all done here; move it to output
|
# we're all done here; move it to output
|
||||||
|
|||||||
Reference in New Issue
Block a user