| Server IP : 103.175.220.74 / Your IP : 216.73.216.151 Web Server : nginx/1.18.0 System : Linux p-floo-wj1-db 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : deploy ( 1003) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/deploy/.pyenv/test/ |
Upload File : |
#!/usr/bin/env bats
load test_helper
@test "prints usage help given no argument" {
run pyenv-hooks
assert_failure "Usage: pyenv hooks <command>"
}
@test "prints list of hooks" {
path1="${PYENV_TEST_DIR}/pyenv.d"
path2="${PYENV_TEST_DIR}/etc/pyenv_hooks"
PYENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
create_hook exec "ahoy.bash"
create_hook exec "invalid.sh"
create_hook which "boom.bash"
PYENV_HOOK_PATH="$path2"
create_hook exec "bueno.bash"
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
assert_success
assert_output <<OUT
${PYENV_TEST_DIR}/pyenv.d/exec/ahoy.bash
${PYENV_TEST_DIR}/pyenv.d/exec/hello.bash
${PYENV_TEST_DIR}/etc/pyenv_hooks/exec/bueno.bash
OUT
}
@test "supports hook paths with spaces" {
path1="${PYENV_TEST_DIR}/my hooks/pyenv.d"
path2="${PYENV_TEST_DIR}/etc/pyenv hooks"
PYENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
PYENV_HOOK_PATH="$path2"
create_hook exec "ahoy.bash"
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
assert_success
assert_output <<OUT
${PYENV_TEST_DIR}/my hooks/pyenv.d/exec/hello.bash
${PYENV_TEST_DIR}/etc/pyenv hooks/exec/ahoy.bash
OUT
}
@test "resolves relative paths" {
PYENV_HOOK_PATH="${PYENV_TEST_DIR}/pyenv.d"
create_hook exec "hello.bash"
mkdir -p "$HOME"
PYENV_HOOK_PATH="${HOME}/../pyenv.d" run pyenv-hooks exec
assert_success "${PYENV_TEST_DIR}/pyenv.d/exec/hello.bash"
}
@test "resolves symlinks" {
path="${PYENV_TEST_DIR}/pyenv.d"
mkdir -p "${path}/exec"
mkdir -p "$HOME"
touch "${HOME}/hola.bash"
ln -s "../../home/hola.bash" "${path}/exec/hello.bash"
touch "${path}/exec/bright.sh"
ln -s "bright.sh" "${path}/exec/world.bash"
PYENV_HOOK_PATH="$path" run pyenv-hooks exec
assert_success
assert_output <<OUT
${HOME}/hola.bash
${PYENV_TEST_DIR}/pyenv.d/exec/bright.sh
OUT
}