mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Improve pyenv version
, if there is one missing
Display the other available ones still. Fixes https://github.com/yyuu/pyenv/issues/291
This commit is contained in:
parent
d320d74a07
commit
7f88eabd0b
3 changed files with 47 additions and 1 deletions
|
@ -21,6 +21,7 @@ version_exists() {
|
|||
versions=()
|
||||
OLDIFS="$IFS"
|
||||
{ IFS=:
|
||||
any_not_installed=0
|
||||
for version in ${PYENV_VERSION}; do
|
||||
if version_exists "$version" || [ "$version" = "system" ]; then
|
||||
versions=("${versions[@]}" "${version}")
|
||||
|
@ -31,7 +32,7 @@ OLDIFS="$IFS"
|
|||
versions=("${versions[@]}" "${version#python-}")
|
||||
else
|
||||
echo "pyenv: version \`$version' is not installed" >&2
|
||||
exit 1
|
||||
any_not_installed=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
@ -42,3 +43,7 @@ OLDIFS="$IFS"
|
|||
echo "${versions[*]}"
|
||||
}
|
||||
IFS="$OLDIFS"
|
||||
|
||||
if [ "$any_not_installed" = 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -52,6 +52,26 @@ setup() {
|
|||
assert_failure "pyenv: version \`1.2' is not installed"
|
||||
}
|
||||
|
||||
@test "one missing version (second missing)" {
|
||||
create_version "3.4.2"
|
||||
PYENV_VERSION="3.4.2:1.2" run pyenv-version-name
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
pyenv: version \`1.2' is not installed
|
||||
3.4.2
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "one missing version (first missing)" {
|
||||
create_version "3.4.2"
|
||||
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
pyenv: version \`1.2' is not installed
|
||||
3.4.2
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "version with prefix in name" {
|
||||
create_version "2.7.6"
|
||||
cat > ".python-version" <<<"python-2.7.6"
|
||||
|
|
|
@ -36,3 +36,24 @@ setup() {
|
|||
run pyenv-version
|
||||
assert_success "3.3.3 (set by ${PYENV_ROOT}/version)"
|
||||
}
|
||||
|
||||
@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_output <<OUT
|
||||
pyenv: version \`1.2' is not installed
|
||||
3.3.3 (set by PYENV_VERSION environment variable)
|
||||
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_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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue