2014-01-17 21:14:30 +09:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
2025-09-08 16:47:50 +02:00
|
|
|
_setup() {
|
|
|
|
|
export PYENV_ROOT="${BATS_TEST_TMPDIR}/pyenv"
|
|
|
|
|
export HOOK_PATH="${BATS_TEST_TMPDIR}/i has hooks"
|
2014-01-17 21:14:30 +09:00
|
|
|
mkdir -p "$HOOK_PATH"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "pyenv-install hooks" {
|
|
|
|
|
cat > "${HOOK_PATH}/install.bash" <<OUT
|
|
|
|
|
before_install 'echo before: \$PREFIX'
|
|
|
|
|
after_install 'echo after: \$STATUS'
|
|
|
|
|
OUT
|
|
|
|
|
stub pyenv-hooks "install : echo '$HOOK_PATH'/install.bash"
|
|
|
|
|
stub pyenv-rehash "echo rehashed"
|
|
|
|
|
|
2025-09-08 16:47:50 +02:00
|
|
|
definition="${BATS_TEST_TMPDIR}/3.6.2"
|
2024-07-20 22:06:13 +03:00
|
|
|
stub pyenv-latest "echo $definition"
|
|
|
|
|
|
2014-01-17 21:14:30 +09:00
|
|
|
cat > "$definition" <<<"echo python-build"
|
|
|
|
|
run pyenv-install "$definition"
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_output <<-OUT
|
2017-09-11 02:02:15 +00:00
|
|
|
before: ${PYENV_ROOT}/versions/3.6.2
|
2014-01-17 21:14:30 +09:00
|
|
|
python-build
|
|
|
|
|
after: 0
|
|
|
|
|
rehashed
|
|
|
|
|
OUT
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "pyenv-uninstall hooks" {
|
|
|
|
|
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
|
|
|
|
|
before_uninstall 'echo before: \$PREFIX'
|
|
|
|
|
after_uninstall 'echo after.'
|
|
|
|
|
rm() {
|
|
|
|
|
echo "rm \$@"
|
|
|
|
|
command rm "\$@"
|
|
|
|
|
}
|
|
|
|
|
OUT
|
|
|
|
|
stub pyenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
|
|
|
|
|
stub pyenv-rehash "echo rehashed"
|
|
|
|
|
|
2017-09-11 02:02:15 +00:00
|
|
|
mkdir -p "${PYENV_ROOT}/versions/3.6.2"
|
|
|
|
|
run pyenv-uninstall -f 3.6.2
|
2014-01-17 21:14:30 +09:00
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_output <<-OUT
|
2017-09-11 02:02:15 +00:00
|
|
|
before: ${PYENV_ROOT}/versions/3.6.2
|
|
|
|
|
rm -rf ${PYENV_ROOT}/versions/3.6.2
|
2014-01-17 21:14:30 +09:00
|
|
|
rehashed
|
2020-04-22 11:45:28 -04:00
|
|
|
pyenv: 3.6.2 uninstalled
|
2014-01-17 21:14:30 +09:00
|
|
|
after.
|
|
|
|
|
OUT
|
|
|
|
|
|
2017-09-11 02:02:15 +00:00
|
|
|
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
|
2014-01-17 21:14:30 +09:00
|
|
|
}
|
2022-08-15 22:55:46 +05:30
|
|
|
|
|
|
|
|
@test "pyenv-uninstall hooks with multiple versions" {
|
|
|
|
|
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
|
|
|
|
|
before_uninstall 'echo before: \$PREFIX'
|
|
|
|
|
after_uninstall 'echo after.'
|
|
|
|
|
rm() {
|
|
|
|
|
echo "rm \$@"
|
|
|
|
|
command rm "\$@"
|
|
|
|
|
}
|
|
|
|
|
OUT
|
|
|
|
|
stub pyenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
|
|
|
|
|
stub pyenv-rehash "echo rehashed"
|
|
|
|
|
stub pyenv-rehash "echo rehashed"
|
|
|
|
|
|
|
|
|
|
mkdir -p "${PYENV_ROOT}/versions/3.6.2"
|
|
|
|
|
mkdir -p "${PYENV_ROOT}/versions/3.6.3"
|
|
|
|
|
run pyenv-uninstall -f 3.6.2 3.6.3
|
|
|
|
|
|
|
|
|
|
assert_success
|
|
|
|
|
assert_output <<-OUT
|
|
|
|
|
before: ${PYENV_ROOT}/versions/3.6.2
|
|
|
|
|
rm -rf ${PYENV_ROOT}/versions/3.6.2
|
|
|
|
|
rehashed
|
|
|
|
|
pyenv: 3.6.2 uninstalled
|
|
|
|
|
after.
|
|
|
|
|
before: ${PYENV_ROOT}/versions/3.6.3
|
|
|
|
|
rm -rf ${PYENV_ROOT}/versions/3.6.3
|
|
|
|
|
rehashed
|
|
|
|
|
pyenv: 3.6.3 uninstalled
|
|
|
|
|
after.
|
|
|
|
|
OUT
|
|
|
|
|
|
|
|
|
|
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
|
|
|
|
|
refute [ -d "${PYENV_ROOT}/versions/3.6.3" ]
|
|
|
|
|
}
|