Ver código fonte

Merge commit from fork

pull/3435/merge
native-api 18 horas atrás
committed by GitHub
pai
commit
95df7dbc7b
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: B5690EEEBB952194
14 arquivos alterados com 93 adições e 0 exclusões
  1. +4
    -0
      libexec/pyenv-global
  2. +4
    -0
      libexec/pyenv-local
  3. +4
    -0
      libexec/pyenv-prefix
  4. +4
    -0
      libexec/pyenv-version
  5. +4
    -0
      libexec/pyenv-version-name
  6. +8
    -0
      libexec/pyenv-versions
  7. +4
    -0
      libexec/pyenv-which
  8. +8
    -0
      test/global.bats
  9. +7
    -0
      test/local.bats
  10. +6
    -0
      test/prefix.bats
  11. +8
    -0
      test/version-name.bats
  12. +9
    -0
      test/version.bats
  13. +12
    -0
      test/versions.bats
  14. +11
    -0
      test/which.bats

+ 4
- 0
libexec/pyenv-global Ver arquivo

@ -36,12 +36,16 @@ if [ -n "$versions" ]; then
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
else
OLDIFS="$IFS"
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
IFS=: versions=($(
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
pyenv-version-file-read "${PYENV_ROOT}/global" ||
pyenv-version-file-read "${PYENV_ROOT}/default" ||
echo system
))
set +f
IFS="$OLDIFS"
for version in "${versions[@]}"; do
echo "$version"

+ 4
- 0
libexec/pyenv-local Ver arquivo

@ -59,7 +59,11 @@ elif [ -n "$versions" ]; then
pyenv-version-file-write ${FORCE:+-f }.python-version "${versions[@]}"
else
if version_file="$(pyenv-version-file "$PWD")"; then
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
IFS=: versions=($(pyenv-version-file-read "$version_file"))
set +f
for version in "${versions[@]}"; do
echo "$version"
done

+ 4
- 0
libexec/pyenv-prefix Ver arquivo

@ -28,6 +28,9 @@ fi
PYENV_PREFIX_PATHS=()
OLDIFS="$IFS"
{ IFS=:
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
for version in ${PYENV_VERSION}; do
if [ "$version" = "system" ]; then
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python --skip-advice 2>/dev/null)" || \
@ -52,6 +55,7 @@ OLDIFS="$IFS"
exit 1
fi
done
set +f
}
IFS="$OLDIFS"

+ 4
- 0
libexec/pyenv-version Ver arquivo

@ -9,7 +9,11 @@ set -e
exitcode=0
OLDIFS="$IFS"
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
set +f
IFS="$OLDIFS"
unset bare

+ 4
- 0
libexec/pyenv-version-name Ver arquivo

@ -46,6 +46,9 @@ versions=()
OLDIFS="$IFS"
{ IFS=:
any_not_installed=0
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
for version in ${PYENV_VERSION}; do
# Remove the explicit 'python-' prefix from versions like 'python-3.12'.
normalised_version="${version#python-}"
@ -66,6 +69,7 @@ OLDIFS="$IFS"
fi
fi
done
set +f
}
IFS="$OLDIFS"

+ 8
- 0
libexec/pyenv-versions Ver arquivo

@ -99,6 +99,9 @@ else
miss_prefix=" "
OLDIFS="$IFS"
IFS=:
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
if ((${BASH_VERSINFO[0]} > 3)); then
for i in $(pyenv-version-name || true); do
current_versions["$i"]="1"
@ -106,6 +109,7 @@ else
else
current_versions=($(pyenv-version-name || true))
fi
set +f
IFS="$OLDIFS"
include_system="1"
fi
@ -161,11 +165,15 @@ versions_dir_entries=("$versions_dir"/*)
if sort --version-sort </dev/null >/dev/null 2>&1; then
# system sort supports version sorting
OLDIFS="$IFS"
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
# which is undesired
set -f
IFS=$'\n'
versions_dir_entries=($(
printf "%s\n" "${versions_dir_entries[@]}" |
sort --version-sort
))
set +f
IFS="$OLDIFS"
fi

+ 4
- 0
libexec/pyenv-which Ver arquivo

@ -63,7 +63,11 @@ if [ -z "$PYENV_COMMAND" ]; then
fi
OLDIFS="$IFS"
# Unquoted $VAR or VAR=() of unquoted value does glob expansion (against the current dir's contents)
# after IFS-splitting which is undesired
set -f
IFS=: versions=(${PYENV_VERSION:-$(pyenv-version-name -f)})
set +f
IFS="$OLDIFS"
declare -a nonexistent_versions

+ 8
- 0
test/global.bats Ver arquivo

@ -16,6 +16,14 @@ load test_helper
assert_output "1.2.3"
}
@test "version with glob characters is handled correctly" {
touch 1.1
mkdir -p "$PYENV_ROOT"
echo "[1-9].?*" > "$PYENV_ROOT/version"
run pyenv-global
assert_success "[1-9].?*"
}
@test "set PYENV_ROOT/version" {
mkdir -p "$PYENV_ROOT/versions/1.2.3"
run pyenv-global "1.2.3"

+ 7
- 0
test/local.bats Ver arquivo

@ -19,6 +19,13 @@ _setup() {
assert_success "1.2.3"
}
@test "version with glob characters is handled correctly" {
touch 1.1
echo "[1-9].?*" > .python-version
run pyenv-local
assert_success "[1-9].?*"
}
@test "discovers version file in parent directory" {
echo "1.2.3" > .python-version
mkdir -p "subdir" && cd "subdir"

+ 6
- 0
test/prefix.bats Ver arquivo

@ -16,6 +16,12 @@ load test_helper
assert_failure "pyenv: version \`1.2.3' not installed"
}
@test "version with glob characters is handled correctly" {
touch 1.1
PYENV_VERSION="[1-9].?*" run pyenv-prefix
assert_failure "pyenv: version \`[1-9].?*' not installed"
}
@test "prefix for system" {
mkdir -p "${PYENV_TEST_DIR}/bin"
touch "${PYENV_TEST_DIR}/bin/python"

+ 8
- 0
test/version-name.bats Ver arquivo

@ -22,6 +22,14 @@ _setup() {
assert_success "system"
}
@test "version with glob characters is handled correctly" {
touch 1.1
PYENV_VERSION="[1-9].?*" run pyenv-version-name
assert_failure <<'!'
pyenv: version `[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
!
}
@test "PYENV_VERSION can be overridden by hook" {
create_version "2.7.11"
create_version "3.5.1"

+ 9
- 0
test/version.bats Ver arquivo

@ -79,3 +79,12 @@ OUT
3.3.3
OUT
}
@test "version with glob characters is handled correctly" {
touch 1.1
PYENV_VERSION="[1-9].?*" run pyenv-version
assert_failure
assert_output <<OUT
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
OUT
}

+ 12
- 0
test/versions.bats Ver arquivo

@ -63,6 +63,18 @@ OUT
assert_success "3.3"
}
@test "version with glob characters is handled correctly" {
stub_system_python
create_version "[1-9].?*"
touch 1.1
run pyenv-versions
assert_success
assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
[1-9].?*
OUT
}
@test "multiple versions and envs" {
stub_system_python
create_version "2.7.6"

+ 11
- 0
test/which.bats Ver arquivo

@ -90,6 +90,17 @@ Note: See 'pyenv help global' for tips on allowing multiple
OUT
}
@test "version with glob characters is handled correctly" {
bats_require_minimum_version 1.5.0
touch 1.1
PATH="$(path_without foo)" PYENV_VERSION="[1-9].?*" run -127 pyenv-which foo
assert_failure
assert_output <<!
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
pyenv: foo: command not found
!
}
@test "no executable found" {
bats_require_minimum_version 1.5.0
create_alt_executable_in_version "2.7" "py.test"

Carregando…
Cancelar
Salvar