mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-11 13:03:52 -05:00
Exit as error on activation failures
This commit is contained in:
@@ -41,10 +41,14 @@ fi
|
|||||||
|
|
||||||
if [ "${#versions[@]}" -gt 1 ]; then
|
if [ "${#versions[@]}" -gt 1 ]; then
|
||||||
echo "pyenv-virtualenv: cannot activate multiple versions at once: ${versions[@]}" 1>&2
|
echo "pyenv-virtualenv: cannot activate multiple versions at once: ${versions[@]}" 1>&2
|
||||||
|
echo "false"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pyenv-virtualenv-prefix "${versions}" 1>/dev/null
|
if ! pyenv-virtualenv-prefix "${versions}" 1>/dev/null; then
|
||||||
|
echo "false"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
|
|||||||
@@ -137,13 +137,17 @@ EOS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "should fail if the version is not a virtualenv" {
|
@test "should fail if the version is not a virtualenv" {
|
||||||
stub pyenv-virtualenv-prefix "3.3.3 : false"
|
stub pyenv-virtualenv-prefix "3.3.3 : echo \"not a virtualenv\" 1>&2; false"
|
||||||
|
|
||||||
run pyenv-sh-activate "3.3.3"
|
run pyenv-sh-activate "3.3.3"
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
|
|
||||||
assert_failure
|
assert_failure
|
||||||
|
assert_output <<EOS
|
||||||
|
not a virtualenv
|
||||||
|
false
|
||||||
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "should fail if there are multiple versions" {
|
@test "should fail if there are multiple versions" {
|
||||||
@@ -152,6 +156,7 @@ EOS
|
|||||||
assert_failure
|
assert_failure
|
||||||
assert_output <<EOS
|
assert_output <<EOS
|
||||||
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
|
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
|
||||||
|
false
|
||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user