1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-12 05:23:47 -05:00

Merge remote-tracking branch 'rbenv/master'

Conflicts:
	README.md
	libexec/pyenv---version
	libexec/pyenv-init
	libexec/rbenv
	libexec/rbenv-sh-shell
	libexec/rbenv-which
	test/init.bats
	test/shell.bats
This commit is contained in:
Daniel Hahler
2017-06-05 15:02:24 +02:00
7 changed files with 108 additions and 26 deletions

6
test/init.bats Normal file → Executable file
View File

@@ -47,7 +47,7 @@ OUT
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
run pyenv-init - fish
assert_success
assert_line ". '${root}/test/../libexec/../completions/pyenv.fish'"
assert_line "source '${root}/test/../libexec/../completions/pyenv.fish'"
}
@test "fish instructions" {
@@ -73,7 +73,7 @@ OUT
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run pyenv-init - fish
assert_success
assert_line 0 "setenv PATH '${PYENV_ROOT}/shims' \$PATH"
assert_line 0 "set -gx PATH '${PYENV_ROOT}/shims' \$PATH"
}
@test "can add shims to PATH more than once" {
@@ -87,7 +87,7 @@ OUT
export PATH="${PYENV_ROOT}/shims:$PATH"
run pyenv-init - fish
assert_success
assert_line 0 "setenv PATH '${PYENV_ROOT}/shims' \$PATH"
assert_line 0 "set -gx PATH '${PYENV_ROOT}/shims' \$PATH"
}
@test "outputs sh-compatible syntax" {

View File

@@ -20,14 +20,34 @@ load test_helper
assert_success 'echo "$PYENV_VERSION"'
}
@test "shell revert" {
PYENV_SHELL=bash run pyenv-sh-shell -
assert_success
assert_line 0 'if [ -n "${PYENV_VERSION_OLD+x}" ]; then'
}
@test "shell revert (fish)" {
PYENV_SHELL=fish 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 "unset PYENV_VERSION"
assert_success
assert_output <<OUT
PYENV_VERSION_OLD="\$PYENV_VERSION"
unset PYENV_VERSION
OUT
}
@test "shell unset (fish)" {
PYENV_SHELL=fish run pyenv-sh-shell --unset
assert_success "set -e PYENV_VERSION"
assert_success
assert_output <<OUT
set -gu PYENV_VERSION_OLD "\$PYENV_VERSION"
set -e PYENV_VERSION
OUT
}
@test "shell change invalid version" {
@@ -42,11 +62,19 @@ SH
@test "shell change version" {
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
PYENV_SHELL=bash run pyenv-sh-shell 1.2.3
assert_success 'export PYENV_VERSION="1.2.3"'
assert_success
assert_output <<OUT
PYENV_VERSION_OLD="\$PYENV_VERSION"
export PYENV_VERSION="1.2.3"
OUT
}
@test "shell change version (fish)" {
mkdir -p "${PYENV_ROOT}/versions/1.2.3"
PYENV_SHELL=fish run pyenv-sh-shell 1.2.3
assert_success 'setenv PYENV_VERSION "1.2.3"'
assert_success
assert_output <<OUT
set -gu PYENV_VERSION_OLD "\$PYENV_VERSION"
set -gx PYENV_VERSION "1.2.3"
OUT
}