From b1882cb6fefbebb10c3a7862315cffaf02c4ede3 Mon Sep 17 00:00:00 2001 From: Christian Fredrik Johnsen Date: Sat, 21 Dec 2024 14:00:34 +0100 Subject: [PATCH] fix: Fix shell completions tests for pyenv-init In `test_helper.bash`: set PATH="${BATS_TEST_DIRNAME%/*}/libexec:$PATH" instead of PATH="${BATS_TEST_DIRNAME}../libexec:$PATH" it essentially enables us to expect `${exec_root}/completions/pyenv.bash` instead of something like `${exec_root}/test/../completions/pyenv.zsh --- test/init.bats | 10 ++++------ test/test_helper.bash | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/init.bats b/test/init.bats index 16314d76..c0831d40 100755 --- a/test/init.bats +++ b/test/init.bats @@ -36,11 +36,10 @@ create_executable() { } @test "setup shell completions" { - root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" - export PYENV_ROOT=$root + exec_root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" run pyenv-init - bash assert_success - assert_line "source '${root}/completions/pyenv.bash'" + assert_line "source '${exec_root}/completions/pyenv.bash'" } @test "detect parent shell" { @@ -63,11 +62,10 @@ OUT } @test "setup shell completions (fish)" { - root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" - export PYENV_ROOT=$root + exec_root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" run pyenv-init - fish assert_success - assert_line "source '${root}/completions/pyenv.fish'" + assert_line "source '${exec_root}/completions/pyenv.fish'" } @test "fish instructions" { diff --git a/test/test_helper.bash b/test/test_helper.bash index 4e32df30..51dcd83d 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -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