Compare commits

...

6 Commits

Author SHA1 Message Date
Florian Blanchet feb8f65d0d
Merge 11b615f709 into 3ff54e89bc 2024-04-27 14:37:14 +02:00
Edgar Ramírez Mondragón 3ff54e89bc
Add PyPy v7.3.16 (#2948) 2024-04-25 21:51:58 +03:00
Florian Blanchet 11b615f709 Add unit tests for pwsh 2023-07-29 03:56:08 +03:00
Florian Blanchet 99c693df39 Add PowerShell autocompletion feature 2023-07-28 22:33:37 +03:00
Florian Blanchet 2ac251faa1 Add instructions for PowerShell in README.md 2023-07-28 22:32:36 +03:00
Florian Blanchet 2df60ca4ea Add Microsoft PowerShell support 2023-07-28 22:31:11 +03:00
14 changed files with 501 additions and 6 deletions

View File

@ -359,6 +359,16 @@ See [Advanced configuration](#advanced-configuration) for details and more confi
pyenv init - | source
~~~
- For **Microsoft PowerShell**:
Add the commands to `$profile.CurrentUserAllHosts` by running the following in your terminal:
~~~ pwsh
echo '$Env:PYENV_ROOT="$HOME/.pyenv"' >> $profile.CurrentUserAllHosts
echo '$Env:PATH="$Env:PYENV_ROOT/bin:$Env:PATH"' >> $profile.CurrentUserAllHosts
echo 'iex ((pyenv init -) -join "`n")' >> $profile.CurrentUserAllHosts
~~~
**Bash warning**: There are some systems where the `BASH_ENV` variable is configured
to point to `.bashrc`. On such systems, you should almost certainly put the
`eval "$(pyenv init -)"` line into `.bash_profile`, and **not** into `.bashrc`. Otherwise, you
@ -612,7 +622,7 @@ opposed to this idea. Here's what `eval "$(pyenv init -)"` actually does:
2. **Installs autocompletion.** This is entirely optional but pretty
useful. Sourcing `$(pyenv root)/completions/pyenv.bash` will set that
up. There are also completions for Zsh and Fish.
up. There are also completions for Zsh, Fish and PowerShell.
3. **Rehashes shims.** From time to time you'll need to rebuild your
shim files. Doing this on init makes sure everything is up to

17
completions/pyenv.pwsh Normal file
View File

@ -0,0 +1,17 @@
$scriptblock = {
param($wordToComplete, $commandAst, $cursorPosition)
$words = $commandAst.ToString()
if ( $wordToComplete ) {
$matches = (($words[0..$cursorPosition] -join '') | Select-String -Pattern "\s+" -AllMatches).Matches
if ( $matches ) {
$cursorPosition = $matches[-1].Index - 1
}
}
$words = $words[0..$cursorPosition] -join '' -split "\s+"
if ( $words.Count -ge 2 ) {
pyenv completions $words[1] | where { $_ -match $wordToComplete }
} else {
pyenv commands | where { $_ -match $wordToComplete }
}
}
Register-ArgumentCompleter -Native -CommandName pyenv -ScriptBlock $scriptblock

View File

@ -15,6 +15,7 @@ if [ "$1" = "--complete" ]; then
echo bash
echo fish
echo ksh
echo pwsh
echo zsh
exit
fi
@ -105,6 +106,10 @@ function detect_profile() {
profile_explain="~/.bash_profile if it exists, otherwise ~/.profile"
rc='~/.bashrc'
;;
pwsh )
profile='~/.config/powershell/profile.ps1'
rc='~/.config/powershell/profile.ps1'
;;
zsh )
profile='~/.zprofile'
rc='~/.zshrc'
@ -153,6 +158,21 @@ function help_() {
echo 'pyenv init - | source'
echo
;;
pwsh )
echo '# Load pyenv automatically by appending'
echo -n "# the following to "
if [ "$profile" == "$rc" ]; then
echo "$profile :"
else
echo
echo "${profile_explain:-$profile} (for login shells)"
echo "and $rc (for interactive shells) :"
fi
echo
echo '$Env:PYENV_ROOT="$HOME/.pyenv"'
echo '$Env:PATH="$Env:PYENV_ROOT/bin:$Env:PATH"'
echo 'iex ((pyenv init -) -join "`n")'
;;
* )
echo '# Load pyenv automatically by appending'
echo -n "# the following to "
@ -189,6 +209,11 @@ function print_path() {
print_path_prepend_shims
echo 'end'
;;
pwsh )
echo 'if ( $Env:PATH -match "'"${PYENV_ROOT}/shims"'" ) {'
print_path_prepend_shims
echo '}'
;;
* )
echo 'if [[ ":$PATH:" != *'\':"${PYENV_ROOT}"/shims:\''* ]]; then'
print_path_prepend_shims
@ -202,6 +227,10 @@ function print_path() {
echo 'set -eg PATH[$pyenv_index]; end; set -e pyenv_index'
print_path_prepend_shims
;;
pwsh )
echo '$Env:PATH="$(($Env:PATH -split '"':'"' | where { -not ($_ -match '"'${PYENV_ROOT}/shims'"') }) -join '"':'"')"'
print_path_prepend_shims
;;
* )
# Some distros (notably Debian-based) set Bash's SSH_SOURCE_BASHRC compilation option
# that makes it source `bashrc` under SSH even when not interactive.
@ -226,6 +255,9 @@ function print_path_prepend_shims() {
fish )
echo 'set -gx PATH '\'"${PYENV_ROOT}/shims"\'' $PATH'
;;
pwsh )
echo '$Env:PATH="'"${PYENV_ROOT}"'/shims:$Env:PATH"'
;;
* )
echo 'export PATH="'"${PYENV_ROOT}"'/shims:${PATH}"'
;;
@ -237,6 +269,9 @@ function print_env() {
fish )
echo "set -gx PYENV_SHELL $shell"
;;
pwsh )
echo '$Env:PYENV_SHELL="'"$shell"'"'
;;
* )
echo "export PYENV_SHELL=$shell"
;;
@ -246,13 +281,27 @@ function print_env() {
function print_completion() {
completion="${root}/completions/pyenv.${shell}"
if [ -r "$completion" ]; then
echo "source '$completion'"
case "$shell" in
pwsh )
echo "iex (gc $completion -Raw)"
;;
* )
echo "source '$completion'"
;;
esac
fi
}
function print_rehash() {
if [ -z "$no_rehash" ]; then
echo 'command pyenv rehash 2>/dev/null'
case "$shell" in
pwsh )
echo '& pyenv rehash 2>/dev/null'
;;
* )
echo 'command pyenv rehash 2>/dev/null'
;;
esac
fi
}
@ -272,6 +321,25 @@ function pyenv
command pyenv "\$command" \$argv
end
end
EOS
;;
pwsh )
cat <<EOS
function pyenv {
\$command=""
if ( \$args.Count -gt 0 ) {
\$command, \$args = \$args
}
if ( ("${commands[*]}" -split ' ') -contains \$command ) {
\$shell_cmds = & \$Env:PYENV_ROOT/bin/pyenv sh-\$command \$args
if ( \$shell_cmds.Count -gt 0 ) {
iex (\$shell_cmds -join "\`n")
}
} else {
& \$Env:PYENV_ROOT/bin/pyenv \$command \$args
}
}
EOS
;;
ksh | ksh93 | mksh )
@ -287,8 +355,8 @@ pyenv() {
EOS
;;
esac
if [ "$shell" != "fish" ]; then
if [ "$shell" != "fish" ] && [ "$shell" != "pwsh" ]; then
IFS="|"
cat <<EOS
command="\${1:-}"

View File

@ -14,7 +14,7 @@ shell="$(basename "${PYENV_SHELL:-$SHELL}")"
pyenv-rehash
case "$shell" in
fish )
fish | pwsh )
# no rehash support
;;
* )

View File

@ -48,6 +48,9 @@ if [ "$versions" = "--unset" ]; then
echo 'set -gu PYENV_VERSION_OLD "$PYENV_VERSION"'
echo "set -e PYENV_VERSION"
;;
pwsh )
echo '$Env:PYENV_VERSION, $Env:PYENV_VERSION_OLD = $null, $Env:PYENV_VERSION'
;;
* )
echo 'PYENV_VERSION_OLD="${PYENV_VERSION-}"'
echo "unset PYENV_VERSION"
@ -74,6 +77,16 @@ else
echo "pyenv: PYENV_VERSION_OLD is not set" >&2
false
end
EOS
;;
pwsh )
cat <<EOS
if ( Get-Item -Path Env:\PYENV_VERSION* ) {
\$Env:PYENV_VERSION, \$Env:PYENV_VERSION_OLD = \$Env:PYENV_VERSION_OLD, \$Env:PYENV_VERSION
} else {
Write-Error "pyenv: Env:PYENV_VERSION_OLD is not set"
return \$false
}
EOS
;;
* )
@ -109,6 +122,9 @@ if pyenv-prefix "${versions[@]}" >/dev/null; then
echo 'set -gu PYENV_VERSION_OLD "$PYENV_VERSION"'
echo "set -gx PYENV_VERSION \"$version\""
;;
pwsh )
echo '$Env:PYENV_VERSION, $Env:PYENV_VERSION_OLD = "'"${version}"'", $Env:PYENV_VERSION'
;;
* )
echo 'PYENV_VERSION_OLD="${PYENV_VERSION-}"'
echo "export PYENV_VERSION=\"${version}\""

View File

@ -0,0 +1,81 @@
VERSION='7.3.16'
PYVER='2.7'
# https://www.pypy.org/checksums.html
aarch64_hash=be44e65dd8c00d2388b2580dbe2af6a5179f951a8f4979efc74360f92f3c7e96
linux32_hash=a19712d7a6bd4f6d113e352c5271803c583b5129b76a357d387b1fa85204f8e5
linux64_hash=04b2fceb712d6f811274825b8a471ee392d3d1b53afc83eb3f42439ce00d8e07
osarm64_hash=9cc13f4d6c4096820e1e0ddabb3959f853e45150ce0166a39aa23867e99f0145
osx64_hash=e8744c1cef8b9e4eb2d2b6b368ed19a1c5cde482c7ef750f2d9f0807bb77fd1c
s390x_hash=09eb70b932e6aac484cf4b5f2de5845f71589f2cbb53e5ed37a497613b43cd53
### end of manual settings - following lines same for every download
function err_no_binary {
local archmsg="${1}"
local ver="pypy${PYVER}-v${VERSION}-src"
local url="https://downloads.python.org/pypy/${ver}.tar.bz2"
{ echo
colorize 1 "ERROR"
echo ": The binary distribution of PyPy is not available for ${archmsg}."
echo "try '${url}' to build from source."
echo
} >&2
exit 1
}
function pypy_pkg_data {
# pypy architecture tag
local ARCH="${1}"
# defaults
local cmd='install_package' # use bz2
local pkg="${ARCH}" # assume matches
local ext='tar.bz2'
local hash='' # undefined
# select the hash, fix pkg if not match ARCH
case "${ARCH}" in
'linux-aarch64' )
hash="${aarch64_hash}"
pkg='aarch64'
;;
'linux' )
hash="${linux32_hash}"
pkg='linux32'
;;
'linux64' )
hash="${linux64_hash}"
;;
'osarm64' )
hash="${osarm64_hash}"
pkg='macos_arm64'
;;
'osx64' )
if require_osx_version "10.13"; then
hash="${osx64_hash}"
pkg='macos_x86_64'
else
err_no_binary "${ARCH}, OS X < 10.13"
fi
;;
's390x' )
hash="${s390x_hash}"
;;
* )
err_no_binary "${ARCH}"
;;
esac
local basever="pypy${PYVER}-v${VERSION}"
local baseurl="https://downloads.python.org/pypy/${basever}"
# result - command, package dir, url+hash
echo "${cmd}" "${basever}-${pkg}" "${baseurl}-${pkg}.${ext}#${hash}"
}
# determine command, package directory, url+hash
declare -a pd="$(pypy_pkg_data "$(pypy_architecture 2>/dev/null || true)")"
# install
${pd[0]} "${pd[1]}" "${pd[2]}" 'pypy' "verify_py${PYVER//./}" 'ensurepip_lt21'

View File

@ -0,0 +1,14 @@
VERSION='7.3.16'
PYVER='2.7'
# https://www.pypy.org/checksums.html
hash=43721cc0c397f0f3560b325c20c70b11f7c76c27910d3df09f8418cec4f9c2ad
### end of manual settings - following lines same for every download
ver="pypy${PYVER}-v${VERSION}-src"
url="https://downloads.python.org/pypy/${ver}.tar.bz2"
prefer_openssl11
install_package "openssl-1.1.1f" "https://www.openssl.org/source/openssl-1.1.1f.tar.gz#186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35" mac_openssl --if has_broken_mac_openssl
install_package "${ver}" "${url}#${hash}" 'pypy_builder' "verify_py${PYVER//./}" 'ensurepip_lt21'

View File

@ -0,0 +1,81 @@
VERSION='7.3.16'
PYVER='3.10'
# https://www.pypy.org/checksums.html
aarch64_hash=fc720999bc5050e1d3706b3b6445e695cf42bfc71ebc7c88ed6bb88828b1d385
linux32_hash=0df48aa780159e879ac89a805d143e4a6cd1b842f98046f5a3f865814bfaa2a4
linux64_hash=404e6180d6caf9258eaab0c02c72018e9aa8eb03ab9094a0ff17ee5e3b265ac1
osarm64_hash=6c003376667a95c7a228544649677b9927b8210d6444b901817aad24b8719b93
osx64_hash=490f2c6ba2489f405444f3b4ad42166da6e2eb73489a9535b206067eaaf21737
s390x_hash=af97efe498a209ba18c7bc7d084164a9907fb3736588b6864955177e19d5216a
### end of manual settings - following lines same for every download
function err_no_binary {
local archmsg="${1}"
local ver="pypy${PYVER}-v${VERSION}-src"
local url="https://downloads.python.org/pypy/${ver}.tar.bz2"
{ echo
colorize 1 "ERROR"
echo ": The binary distribution of PyPy is not available for ${archmsg}."
echo "try '${url}' to build from source."
echo
} >&2
exit 1
}
function pypy_pkg_data {
# pypy architecture tag
local ARCH="${1}"
# defaults
local cmd='install_package' # use bz2
local pkg="${ARCH}" # assume matches
local ext='tar.bz2'
local hash='' # undefined
# select the hash, fix pkg if not match ARCH
case "${ARCH}" in
'linux-aarch64' )
hash="${aarch64_hash}"
pkg='aarch64'
;;
'linux' )
hash="${linux32_hash}"
pkg='linux32'
;;
'linux64' )
hash="${linux64_hash}"
;;
'osarm64' )
hash="${osarm64_hash}"
pkg='macos_arm64'
;;
'osx64' )
if require_osx_version "10.13"; then
hash="${osx64_hash}"
pkg='macos_x86_64'
else
err_no_binary "${ARCH}, OS X < 10.13"
fi
;;
's390x' )
hash="${s390x_hash}"
;;
* )
err_no_binary "${ARCH}"
;;
esac
local basever="pypy${PYVER}-v${VERSION}"
local baseurl="https://downloads.python.org/pypy/${basever}"
# result - command, package dir, url+hash
echo "${cmd}" "${basever}-${pkg}" "${baseurl}-${pkg}.${ext}#${hash}"
}
# determine command, package directory, url+hash
declare -a pd="$(pypy_pkg_data "$(pypy_architecture 2>/dev/null || true)")"
# install
${pd[0]} "${pd[1]}" "${pd[2]}" 'pypy' "verify_py${PYVER//./}" 'ensurepip'

View File

@ -0,0 +1,14 @@
VERSION='7.3.16'
PYVER='3.10'
# https://www.pypy.org/checksums.html
hash=4a3a3177d0a1f51d59982bb981d1d485403bda3419d5437b9e077f55f59424ff
### end of manual settings - following lines same for every download
ver="pypy${PYVER}-v${VERSION}-src"
url="https://downloads.python.org/pypy/${ver}.tar.bz2"
prefer_openssl11
install_package "openssl-1.1.1f" "https://www.openssl.org/source/openssl-1.1.1f.tar.gz#186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35" mac_openssl --if has_broken_mac_openssl
install_package "${ver}" "${url}#${hash}" 'pypy_builder' "verify_py${PYVER//./}" 'ensurepip'

View File

@ -0,0 +1,81 @@
VERSION='7.3.16'
PYVER='3.9'
# https://www.pypy.org/checksums.html
aarch64_hash=de3f2ed3581b30555ac0dd3e4df78a262ec736a36fb2e8f28259f8539b278ef4
linux32_hash=583b6d6dd4e8c07cbc04da04a7ec2bdfa6674825289c2378c5e018d5abe779ea
linux64_hash=16f9c5b808c848516e742986e826b833cdbeda09ad8764e8704595adbe791b23
osarm64_hash=88f824e7a2d676440d09bc90fc959ae0fd3557d7e2f14bfbbe53d41d159a47fe
osx64_hash=fda015431621e7e5aa16359d114f2c45a77ed936992c1efff86302e768a6b21c
s390x_hash=7a56ebb27dba3110dc1ff52d8e0449cdb37fe5c2275f7faf11432e4e164833ba
### end of manual settings - following lines same for every download
function err_no_binary {
local archmsg="${1}"
local ver="pypy${PYVER}-v${VERSION}-src"
local url="https://downloads.python.org/pypy/${ver}.tar.bz2"
{ echo
colorize 1 "ERROR"
echo ": The binary distribution of PyPy is not available for ${archmsg}."
echo "try '${url}' to build from source."
echo
} >&2
exit 1
}
function pypy_pkg_data {
# pypy architecture tag
local ARCH="${1}"
# defaults
local cmd='install_package' # use bz2
local pkg="${ARCH}" # assume matches
local ext='tar.bz2'
local hash='' # undefined
# select the hash, fix pkg if not match ARCH
case "${ARCH}" in
'linux-aarch64' )
hash="${aarch64_hash}"
pkg='aarch64'
;;
'linux' )
hash="${linux32_hash}"
pkg='linux32'
;;
'linux64' )
hash="${linux64_hash}"
;;
'osarm64' )
hash="${osarm64_hash}"
pkg='macos_arm64'
;;
'osx64' )
if require_osx_version "10.13"; then
hash="${osx64_hash}"
pkg='macos_x86_64'
else
err_no_binary "${ARCH}, OS X < 10.13"
fi
;;
's390x' )
hash="${s390x_hash}"
;;
* )
err_no_binary "${ARCH}"
;;
esac
local basever="pypy${PYVER}-v${VERSION}"
local baseurl="https://downloads.python.org/pypy/${basever}"
# result - command, package dir, url+hash
echo "${cmd}" "${basever}-${pkg}" "${baseurl}-${pkg}.${ext}#${hash}"
}
# determine command, package directory, url+hash
declare -a pd="$(pypy_pkg_data "$(pypy_architecture 2>/dev/null || true)")"
# install
${pd[0]} "${pd[1]}" "${pd[2]}" 'pypy' "verify_py${PYVER//./}" 'ensurepip'

View File

@ -0,0 +1,14 @@
VERSION='7.3.16'
PYVER='3.9'
# https://www.pypy.org/checksums.html
hash=5b75af3f8e76041e79c1ef5ce22ce63f8bd131733e9302081897d8f650e81843
### end of manual settings - following lines same for every download
ver="pypy${PYVER}-v${VERSION}-src"
url="https://downloads.python.org/pypy/${ver}.tar.bz2"
prefer_openssl11
install_package "openssl-1.1.1f" "https://www.openssl.org/source/openssl-1.1.1f.tar.gz#186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35" mac_openssl --if has_broken_mac_openssl
install_package "${ver}" "${url}#${hash}" 'pypy_builder' "verify_py${PYVER//./}" 'ensurepip'

View File

@ -75,6 +75,19 @@ OUT
assert_line 'pyenv init - | source'
}
@test "setup shell completions (pwsh)" {
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
run pyenv-init - pwsh
assert_success
assert_line "iex (gc ${root}/test/../libexec/../completions/pyenv.pwsh -Raw)"
}
@test "pwsh instructions" {
run pyenv-init pwsh
assert [ "$status" -eq 1 ]
assert_line 'iex ((pyenv init -) -join "`n")'
}
@test "shell detection for installer" {
run pyenv-init --detect-shell
assert_success
@ -101,6 +114,13 @@ OUT
assert_line "set -gx PATH '${PYENV_ROOT}/shims' \$PATH"
}
@test "adds shims to PATH (pwsh)" {
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run pyenv-init - pwsh
assert_success
assert_line '$Env:PATH="'${PYENV_ROOT}'/shims:$Env:PATH"'
}
@test "removes existing shims from PATH" {
OLDPATH="$PATH"
export PATH="${BATS_TEST_DIRNAME}/nonexistent:${PYENV_ROOT}/shims:$PATH"
@ -125,6 +145,19 @@ echo "\$PATH"
assert_output "${PYENV_ROOT}/shims:${BATS_TEST_DIRNAME}/nonexistent:${OLDPATH//${PYENV_ROOT}\/shims:/}"
}
@test "removes existing shims from PATH (pwsh)" {
command -v pwsh >/dev/null || skip "-- pwsh not installed"
OLDPATH="$PATH"
export PATH="${BATS_TEST_DIRNAME}/nonexistent:${PYENV_ROOT}/shims:$PATH"
run pwsh -noni -c - <<!
\$Env:PATH="$PATH"
iex ((pyenv init -) -join "\`n")
echo "\$Env:PATH"
!
assert_success
assert_output "${PYENV_ROOT}/shims:${BATS_TEST_DIRNAME}/nonexistent:${OLDPATH//${PYENV_ROOT}\/shims:/}"
}
@test "adds shims to PATH with --no-push-path if they're not on PATH" {
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run bash -e <<!
@ -147,6 +180,18 @@ echo "\$PATH"
assert_output "${PYENV_ROOT}/shims:${PATH}"
}
@test "adds shims to PATH with --no-push-path if they're not on PATH (pwsh)" {
command -v pwsh >/dev/null || skip "-- pwsh not installed"
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run pwsh -noni -c - <<!
\$Env:PATH="$PATH"
iex ((pyenv init - --no-push-path) -join "\`n")
echo "\$Env:PATH"
!
assert_success
assert_output "${PYENV_ROOT}/shims:${PATH}"
}
@test "doesn't change PATH with --no-push-path if shims are already on PATH" {
export PATH="${BATS_TEST_DIRNAME}/../libexec:${PYENV_ROOT}/shims:/usr/bin:/bin:/usr/local/bin"
run bash -e <<!
@ -169,6 +214,18 @@ echo "\$PATH"
assert_output "${PATH}"
}
@test "doesn't change PATH with --no-push-path if shims are already on PATH (pwsh)" {
command -v pwsh >/dev/null || skip "-- pwsh not installed"
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:${PYENV_ROOT}/shims:/bin:/usr/local/bin"
run pwsh -noni -c - <<!
\$Env:PATH="$PATH"
iex ((pyenv init - --no-push-path) -join "\`n")
echo "\$Env:PATH"
!
assert_success
assert_output "${PATH}"
}
@test "outputs sh-compatible syntax" {
run pyenv-init - bash
assert_success
@ -203,3 +260,10 @@ echo
assert_line ' switch "$command"'
refute_line ' case "$command" in'
}
@test "outputs pwsh-specific syntax (pwsh)" {
run pyenv-init - pwsh
assert_success
refute_line ' switch "$command"'
refute_line ' case "$command" in'
}

View File

@ -120,3 +120,10 @@ SH
assert_success ""
assert [ -x "${PYENV_ROOT}/shims/python" ]
}
@test "sh-rehash in pwsh" {
create_executable "3.4" "python"
PYENV_SHELL=pwsh run pyenv-sh-rehash
assert_success ""
assert [ -x "${PYENV_ROOT}/shims/python" ]
}

View File

@ -31,6 +31,11 @@ load test_helper
assert_success 'echo "$PYENV_VERSION"'
}
@test "shell version (pwsh)" {
PYENV_SHELL=pwsh PYENV_VERSION="1.2.3" run pyenv-sh-shell
assert_success 'echo "$PYENV_VERSION"'
}
@test "shell revert" {
PYENV_SHELL=bash run pyenv-sh-shell -
assert_success
@ -43,6 +48,12 @@ load test_helper
assert_line 0 'if set -q PYENV_VERSION_OLD'
}
@test "shell revert (pwsh)" {
PYENV_SHELL=pwsh run pyenv-sh-shell -
assert_success
assert_line 0 'if set -q PYENV_VERSION_OLD'
}
@test "shell unset" {
PYENV_SHELL=bash run pyenv-sh-shell --unset
assert_success
@ -61,6 +72,14 @@ set -e PYENV_VERSION
OUT
}
@test "shell unset (pwsh)" {
PYENV_SHELL=pwsh run pyenv-sh-shell --unset
assert_success
assert_output <<OUT
\$Env:PYENV_VERSION, \$Env:PYENV_VERSION_OLD = \$null, \$Env:PYENV_VERSION
OUT
}
@test "shell change invalid version" {
run pyenv-sh-shell 1.2.3
assert_failure
@ -89,3 +108,12 @@ set -gu PYENV_VERSION_OLD "\$PYENV_VERSION"
set -gx PYENV_VERSION "1.2.3"
OUT
}
@test "shell change version (pwsh)" {
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
PYENV_SHELL=pwsh run pyenv-sh-shell 1.2.3
assert_success
assert_output <<OUT
\$Env:PYENV_VERSION, \$Env:PYENV_VERSION_OLD = "1.2.3", \$Env:PYENV_VERSION
OUT
}