Fix rehash test to give up sooner after lock file's presence

This commit is contained in:
Yamashita, Yuu 2018-04-24 00:37:29 +00:00
parent b1e3f13a85
commit 7973e59473
2 changed files with 7 additions and 5 deletions

View file

@ -34,6 +34,11 @@ release_lock() {
remove_prototype_shim
}
if [ ! -w "$SHIM_PATH" ]; then
echo "pyenv: cannot rehash: $SHIM_PATH isn't writable"
exit 1
fi
unset acquired
for _ in $(seq "${PYENV_REHASH_TIMEOUT:-60}"); do
if acquire_lock 2>/dev/null; then
@ -46,11 +51,7 @@ for _ in $(seq "${PYENV_REHASH_TIMEOUT:-60}"); do
done
if [ -z "${acquired}" ]; then
if [ -w "$SHIM_PATH" ]; then
echo "pyenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
else
echo "pyenv: cannot rehash: $SHIM_PATH isn't writable"
fi
echo "pyenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
exit 1
fi

View file

@ -25,6 +25,7 @@ create_executable() {
}
@test "rehash in progress" {
export PYENV_REHASH_TIMEOUT=1
mkdir -p "${PYENV_ROOT}/shims"
touch "${PYENV_ROOT}/shims/.pyenv-shim"
run pyenv-rehash