test: fix 'setup shell completion' tests.

The old tests seems to have been copy-paste from some 11 year old
rubyenv setup, and included a long and windy pathname. The old setup was
extremely bad in my view, current test is much better.

Exported variables are local to the specific test, so they will not
affect other test instances.

---> Enables us to remove unnecessary `root` variable in pyenv-init.
This commit is contained in:
Christian Fredrik Johnsen 2024-12-14 10:05:29 +01:00
parent 1c985d2ed9
commit 10732c1d8a

View File

@ -35,12 +35,12 @@ create_executable() {
assert_line "command pyenv rehash 2>/dev/null" assert_line "command pyenv rehash 2>/dev/null"
} }
@test "setup shell completions" { @test "setup shell completions" {
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
export PYENV_ROOT=$root
run pyenv-init - bash run pyenv-init - bash
assert_success assert_success
assert_line "source '${root}/test/../libexec/../completions/pyenv.bash'" assert_line "source '${root}/completions/pyenv.bash'"
} }
@test "detect parent shell" { @test "detect parent shell" {
@ -64,9 +64,10 @@ OUT
@test "setup shell completions (fish)" { @test "setup shell completions (fish)" {
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
export PYENV_ROOT=$root
run pyenv-init - fish run pyenv-init - fish
assert_success assert_success
assert_line "source '${root}/test/../libexec/../completions/pyenv.fish'" assert_line "source '${root}/completions/pyenv.fish'"
} }
@test "fish instructions" { @test "fish instructions" {