mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-14 22:33:52 -05:00
Import rbenv changes at 7e0e85bdda
This commit is contained in:
@@ -21,7 +21,7 @@ load test_helper
|
||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run pyenv-init - bash
|
||||
assert_success
|
||||
assert_line "source '${root}/libexec/../completions/pyenv.bash'"
|
||||
assert_line "source '${root}/test/../libexec/../completions/pyenv.bash'"
|
||||
}
|
||||
|
||||
@test "detect parent shell" {
|
||||
@@ -35,7 +35,7 @@ load test_helper
|
||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run pyenv-init - fish
|
||||
assert_success
|
||||
assert_line ". '${root}/libexec/../completions/pyenv.fish'"
|
||||
assert_line ". '${root}/test/../libexec/../completions/pyenv.fish'"
|
||||
}
|
||||
|
||||
@test "fish instructions" {
|
||||
@@ -68,7 +68,7 @@ load test_helper
|
||||
export PATH="${PYENV_ROOT}/shims:$PATH"
|
||||
run pyenv-init - bash
|
||||
assert_success
|
||||
refute_line 'export PATH="'${PYENV_ROOT}'/shims:${PATH}"'
|
||||
assert_line 0 'export PATH="'${PYENV_ROOT}'/shims:${PATH}"'
|
||||
}
|
||||
|
||||
@test "doesn't add shims to PATH more than once (fish)" {
|
||||
@@ -77,3 +77,20 @@ load test_helper
|
||||
assert_success
|
||||
refute_line 'setenv PATH "'${PYENV_ROOT}'/shims" $PATH ;'
|
||||
}
|
||||
|
||||
@test "outputs sh-compatible syntax" {
|
||||
run pyenv-init - bash
|
||||
assert_success
|
||||
assert_line ' case "$command" in'
|
||||
|
||||
run pyenv-init - zsh
|
||||
assert_success
|
||||
assert_line ' case "$command" in'
|
||||
}
|
||||
|
||||
@test "outputs fish-specific syntax (fish)" {
|
||||
run pyenv-init - fish
|
||||
assert_success
|
||||
assert_line ' switch "$command"'
|
||||
refute_line ' case "$command" in'
|
||||
}
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
eval "echo \$$1"
|
||||
# Usage: pyenv echo [-F<char>] VAR
|
||||
|
||||
if [[ $1 == -F* ]]; then
|
||||
sep="${1:2}"
|
||||
echo "${!2}" | tr "${sep:-:}" $'\n'
|
||||
else
|
||||
echo "${!1}"
|
||||
fi
|
||||
|
||||
@@ -45,3 +45,31 @@ load test_helper
|
||||
assert_failure
|
||||
assert_output "pyenv: cannot change working directory to \`$dir'"
|
||||
}
|
||||
|
||||
@test "adds its own libexec to PATH" {
|
||||
run pyenv echo "PATH"
|
||||
assert_success "${BATS_TEST_DIRNAME%/*}/libexec:$PATH"
|
||||
}
|
||||
|
||||
@test "adds plugin bin dirs to PATH" {
|
||||
mkdir -p "$PYENV_ROOT"/plugins/python-build/bin
|
||||
mkdir -p "$PYENV_ROOT"/plugins/pyenv-each/bin
|
||||
run pyenv echo -F: "PATH"
|
||||
assert_success
|
||||
assert_line 0 "${BATS_TEST_DIRNAME%/*}/libexec"
|
||||
assert_line 1 "${PYENV_ROOT}/plugins/python-build/bin"
|
||||
assert_line 2 "${PYENV_ROOT}/plugins/pyenv-each/bin"
|
||||
}
|
||||
|
||||
@test "PYENV_HOOK_PATH preserves value from environment" {
|
||||
PYENV_HOOK_PATH=/my/hook/path:/other/hooks run pyenv echo -F: "PYENV_HOOK_PATH"
|
||||
assert_success
|
||||
assert_line 0 "/my/hook/path"
|
||||
assert_line 1 "/other/hooks"
|
||||
assert_line 2 "${PYENV_ROOT}/pyenv.d"
|
||||
}
|
||||
|
||||
@test "PYENV_HOOK_PATH includes pyenv built-in plugins" {
|
||||
run pyenv echo "PYENV_HOOK_PATH"
|
||||
assert_success ":${PYENV_ROOT}/pyenv.d:${BATS_TEST_DIRNAME%/*}/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks"
|
||||
}
|
||||
|
||||
9
test/run
Executable file
9
test/run
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ -n "$PYENV_NATIVE_EXT" ]; then
|
||||
src/configure
|
||||
make -C src
|
||||
fi
|
||||
|
||||
exec bats ${CI:+--tap} test
|
||||
@@ -1,7 +1,15 @@
|
||||
unset PYENV_VERSION
|
||||
unset PYENV_DIR
|
||||
|
||||
PYENV_TEST_DIR="${BATS_TMPDIR}/pyenv"
|
||||
if enable -f "${BATS_TEST_DIRNAME}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
|
||||
PYENV_TEST_DIR="$(realpath "$BATS_TMPDIR")/pyenv"
|
||||
else
|
||||
if [ -n "$PYENV_NATIVE_EXT" ]; then
|
||||
echo "pyenv: failed to load \`realpath' builtin" >&2
|
||||
exit 1
|
||||
fi
|
||||
PYENV_TEST_DIR="${BATS_TMPDIR}/pyenv"
|
||||
fi
|
||||
|
||||
# guard against executing this block twice due to bats internals
|
||||
if [ "$PYENV_ROOT" != "${PYENV_TEST_DIR}/root" ]; then
|
||||
|
||||
Reference in New Issue
Block a user