mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
parent
0d1f1d09f0
commit
1fe59e41ea
2 changed files with 38 additions and 1 deletions
|
@ -17,7 +17,11 @@ mkdir -p "$SHIM_PATH"
|
||||||
set -o noclobber
|
set -o noclobber
|
||||||
{ echo > "$PROTOTYPE_SHIM_PATH"
|
{ echo > "$PROTOTYPE_SHIM_PATH"
|
||||||
} 2>/dev/null ||
|
} 2>/dev/null ||
|
||||||
{ echo "rbenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
|
{ if [ -w "$SHIM_PATH" ]; then
|
||||||
|
echo "rbenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists"
|
||||||
|
else
|
||||||
|
echo "rbenv: cannot rehash: $SHIM_PATH isn't writable"
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
} >&2
|
||||||
set +o noclobber
|
set +o noclobber
|
||||||
|
|
33
test/rehash.bats
Executable file
33
test/rehash.bats
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
export PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH"
|
||||||
|
|
||||||
|
RBENV_TEST_ROOT="${BATS_TMPDIR}/rbenv"
|
||||||
|
export RBENV_ROOT="$RBENV_TEST_ROOT"
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
rm -rf "$RBENV_TEST_ROOT"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "empty rehash" {
|
||||||
|
run rbenv-rehash
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ -d "${RBENV_TEST_ROOT}/shims" ]
|
||||||
|
rmdir "${RBENV_TEST_ROOT}/shims"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "shims directory not writable" {
|
||||||
|
mkdir -p "${RBENV_TEST_ROOT}/shims"
|
||||||
|
chmod -w "${RBENV_TEST_ROOT}/shims"
|
||||||
|
run rbenv-rehash
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[ "$output" = "rbenv: cannot rehash: ${RBENV_TEST_ROOT}/shims isn't writable" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "rehash in progress" {
|
||||||
|
mkdir -p "${RBENV_TEST_ROOT}/shims"
|
||||||
|
touch "${RBENV_TEST_ROOT}/shims/.rbenv-shim"
|
||||||
|
run rbenv-rehash
|
||||||
|
[ "$status" -eq 1 ]
|
||||||
|
[ "$output" = "rbenv: cannot rehash: ${RBENV_TEST_ROOT}/shims/.rbenv-shim exists" ]
|
||||||
|
}
|
Loading…
Reference in a new issue