mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
Use exitcode from pyenv-version-name in pyenv-version, do not halt
This commit is contained in:
parent
7f88eabd0b
commit
e8433cfeb3
3 changed files with 32 additions and 3 deletions
|
@ -8,10 +8,13 @@
|
|||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
|
||||
exitcode=0
|
||||
OLDIFS="$IFS"
|
||||
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
|
||||
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
|
||||
IFS="$OLDIFS"
|
||||
|
||||
for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do
|
||||
echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))"
|
||||
done
|
||||
|
||||
exit $exitcode
|
||||
|
|
|
@ -72,6 +72,19 @@ pyenv: version \`1.2' is not installed
|
|||
OUT
|
||||
}
|
||||
|
||||
pyenv-version-name-without-stderr() {
|
||||
pyenv-version-name 2>/dev/null
|
||||
}
|
||||
|
||||
@test "one missing version (without stderr)" {
|
||||
create_version "3.4.2"
|
||||
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name-without-stderr
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
3.4.2
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "version with prefix in name" {
|
||||
create_version "2.7.6"
|
||||
cat > ".python-version" <<<"python-2.7.6"
|
||||
|
|
|
@ -40,7 +40,7 @@ setup() {
|
|||
@test "set by PYENV_VERSION, one missing" {
|
||||
create_version "3.3.3"
|
||||
PYENV_VERSION=3.3.3:1.2 run pyenv-version
|
||||
assert_success
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
pyenv: version \`1.2' is not installed
|
||||
3.3.3 (set by PYENV_VERSION environment variable)
|
||||
|
@ -50,10 +50,23 @@ OUT
|
|||
@test "set by PYENV_VERSION, two missing" {
|
||||
create_version "3.3.3"
|
||||
PYENV_VERSION=3.4.2:3.3.3:1.2 run pyenv-version
|
||||
assert_success
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
pyenv: version \`3.4.2' is not installed
|
||||
pyenv: version \`1.2' is not installed
|
||||
3.3.3 (set by PYENV_VERSION environment variable)
|
||||
OUT
|
||||
}
|
||||
|
||||
pyenv-version-without-stderr() {
|
||||
pyenv-version 2>/dev/null
|
||||
}
|
||||
|
||||
@test "set by PYENV_VERSION, one missing (stderr filtered)" {
|
||||
create_version "3.3.3"
|
||||
PYENV_VERSION=3.4.2:3.3.3 run pyenv-version-without-stderr
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
3.3.3 (set by PYENV_VERSION environment variable)
|
||||
OUT
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue