2014-01-17 12:14:30 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
export PYENV_ROOT="${TMP}/pyenv"
|
|
|
|
export HOOK_PATH="${TMP}/i has hooks"
|
|
|
|
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"
|
|
|
|
|
2017-09-11 02:02:15 +00:00
|
|
|
definition="${TMP}/3.6.2"
|
2014-01-17 12:14:30 +00: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 12:14:30 +00: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 12:14:30 +00: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 12:14:30 +00:00
|
|
|
rehashed
|
2020-04-22 15:45:28 +00:00
|
|
|
pyenv: 3.6.2 uninstalled
|
2014-01-17 12:14:30 +00:00
|
|
|
after.
|
|
|
|
OUT
|
|
|
|
|
2017-09-11 02:02:15 +00:00
|
|
|
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
|
2014-01-17 12:14:30 +00:00
|
|
|
}
|