Exit as error on activation failures

This commit is contained in:
Yamashita Yuu
2014-07-04 20:23:02 +09:00
parent e2e69b3b38
commit c09a6d3d6c
2 changed files with 11 additions and 2 deletions

View File

@@ -41,10 +41,14 @@ fi
if [ "${#versions[@]}" -gt 1 ]; then
echo "pyenv-virtualenv: cannot activate multiple versions at once: ${versions[@]}" 1>&2
echo "false"
exit 1
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}")"
case "$shell" in

View File

@@ -137,13 +137,17 @@ EOS
}
@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"
unstub pyenv-virtualenv-prefix
assert_failure
assert_output <<EOS
not a virtualenv
false
EOS
}
@test "should fail if there are multiple versions" {
@@ -152,6 +156,7 @@ EOS
assert_failure
assert_output <<EOS
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
false
EOS
}