add sh-rehash code and integration test

This commit is contained in:
Ivan Pozdeev 2025-12-20 20:50:00 +03:00
parent 99c8c255a6
commit 37fb8a0925
No known key found for this signature in database
GPG key ID: FB6A628DCF06DCD7
2 changed files with 16 additions and 3 deletions

View file

@ -11,7 +11,13 @@ shell="$(basename "${PYENV_SHELL:-$SHELL}")"
# When pyenv shell integration is enabled, delegate to pyenv-rehash,
# then tell the shell to empty its command lookup cache.
echo "command pyenv rehash"
case "$shell" in
pwsh)
echo "&pyenv rehash"
;;
*)
echo "command pyenv rehash"
esac
case "$shell" in
fish | pwsh )

View file

@ -128,10 +128,17 @@ hash -r 2>/dev/null || true"
assert [ -x "${PYENV_ROOT}/shims/python" ]
}
@test "sh-rehash in pwsh" {
@test "sh-rehash in powershell" {
create_executable "3.4" "python"
PYENV_SHELL=pwsh run pyenv-sh-rehash
assert_success ""
assert_success "&pyenv rehash"
}
@test "sh-rehash in powershell (integration)" {
command -v pwsh >/dev/null || skip "-- powershell not installed"
create_alt_executable_in_version "3.4" "python"
run pwsh -NoProfile -Command "iex (&pyenv-sh-rehash)"
assert_success
assert [ -x "${PYENV_ROOT}/shims/python" ]
}