mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-14 06:13:53 -05:00
pyenv-init | performance improvements (#3136)
* perf: replace a series of if statements with a case block. Add error handling for case where unknown option is provided. Same setup as rbenv-init for reading arguments. * perf, docs: Recommend users to specify the shell for `pyenv init -` Speeds up the startup by about 40% (in local testing, from ~50ms to ~30ms). Reflect this in `pyenv init` hint text. * style: remove unnecessary `root` variable in pyenv-init * style: remove unnecessary variable declarations at the top of file in pyenv-init. * perf: replace `cat <<` calls with `echo` The builtin `echo` is about 100x faster. In tests, saves about 2-3ms. * docs: document the `pyenv init - <shell>` performance boost in the Advanced Configuration section. * style: test_helper.bash: avoid unnecessary ".." in produced PATH * docs: fix a false statement about completions location in the Advanced Configuration section.
This commit is contained in:
committed by
GitHub
parent
38421ba6aa
commit
c6973391f3
@@ -35,12 +35,11 @@ create_executable() {
|
||||
assert_line "command pyenv rehash 2>/dev/null"
|
||||
}
|
||||
|
||||
|
||||
@test "setup shell completions" {
|
||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
exec_root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run pyenv-init - bash
|
||||
assert_success
|
||||
assert_line "source '${root}/test/../libexec/../completions/pyenv.bash'"
|
||||
assert_line "source '${exec_root}/completions/pyenv.bash'"
|
||||
}
|
||||
|
||||
@test "detect parent shell" {
|
||||
@@ -63,16 +62,16 @@ OUT
|
||||
}
|
||||
|
||||
@test "setup shell completions (fish)" {
|
||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
exec_root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||
run pyenv-init - fish
|
||||
assert_success
|
||||
assert_line "source '${root}/test/../libexec/../completions/pyenv.fish'"
|
||||
assert_line "source '${exec_root}/completions/pyenv.fish'"
|
||||
}
|
||||
|
||||
@test "fish instructions" {
|
||||
run pyenv-init fish
|
||||
assert [ "$status" -eq 1 ]
|
||||
assert_line 'pyenv init - | source'
|
||||
assert_line 'pyenv init - fish | source'
|
||||
}
|
||||
|
||||
@test "shell detection for installer" {
|
||||
|
||||
@@ -21,7 +21,7 @@ if [ -z "$PYENV_TEST_DIR" ]; then
|
||||
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
|
||||
PATH="${PYENV_TEST_DIR}/bin:$PATH"
|
||||
PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH"
|
||||
PATH="${BATS_TEST_DIRNAME%/*}/libexec:$PATH"
|
||||
PATH="${BATS_TEST_DIRNAME}/libexec:$PATH"
|
||||
PATH="${PYENV_ROOT}/shims:$PATH"
|
||||
export PATH
|
||||
|
||||
Reference in New Issue
Block a user