catch circular pyenv call in integration test; fix integraton

This commit is contained in:
Ivan Pozdeev 2025-12-21 04:55:17 +03:00 committed by Ivan Pozdeev
parent 6358cbe01f
commit ce38460f12
No known key found for this signature in database
GPG key ID: FB6A628DCF06DCD7
3 changed files with 13 additions and 7 deletions

View file

@ -322,12 +322,12 @@ function pyenv {
}
if ( ("${commands[*]}" -split ' ') -contains \$command ) {
\$shell_cmds = &pyenv sh-\$command \$args
\$shell_cmds = (& (get-command -commandtype application pyenv) sh-\$command \$args)
if ( \$shell_cmds.Count -gt 0 ) {
iex (\$shell_cmds -join "\`n")
}
} else {
& \$Env:PYENV_ROOT/bin/pyenv \$command \$args
& (get-command -commandtype application pyenv) \$command \$args
}
}
EOS

View file

@ -13,7 +13,7 @@ shell="$(basename "${PYENV_SHELL:-$SHELL}")"
# then tell the shell to empty its command lookup cache.
case "$shell" in
pwsh)
echo "&pyenv rehash"
echo "& (get-command pyenv -commandtype application) rehash"
;;
*)
echo "command pyenv rehash"
@ -21,7 +21,7 @@ esac
case "$shell" in
fish | pwsh )
# no rehash support
# no executable cache
;;
* )
echo "hash -r 2>/dev/null || true"

View file

@ -131,14 +131,20 @@ hash -r 2>/dev/null || true"
@test "sh-rehash in pwsh" {
create_alt_executable_in_version "3.4" "python"
PYENV_SHELL=pwsh run pyenv-sh-rehash
assert_success "&pyenv rehash"
assert_success "& (get-command pyenv -commandtype application) rehash"
}
@test "sh-rehash in pwsh (integration)" {
command -v pwsh >/dev/null || skip "-- pwsh not installed"
assert [ ! -x "${PYENV_ROOT}/shims/python" ]
create_alt_executable_in_version "3.4" "python"
PYENV_SHELL=pwsh run pwsh -nop -c 'iex ((&pyenv-sh-rehash) -join "\`n")'
assert_success
run pwsh -nop -c -<<'!'
$ErrorActionPreference = "Stop"
$PSNativeCommandUseErrorActionPreference = $true
iex ((& pyenv init - pwsh) -join "`n")
& pyenv rehash
!
assert_success ""
assert [ -x "${PYENV_ROOT}/shims/python" ]
}