mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
Init RBENV_TEST_DIR properly and only once during test setup
This commit is contained in:
parent
55f692ba9c
commit
8a0555f8ef
1 changed files with 13 additions and 11 deletions
|
@ -1,18 +1,20 @@
|
|||
unset RBENV_VERSION
|
||||
unset RBENV_DIR
|
||||
|
||||
if enable -f "${BATS_TEST_DIRNAME}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then
|
||||
RBENV_TEST_DIR="$(realpath "$BATS_TMPDIR")/rbenv"
|
||||
else
|
||||
if [ -n "$RBENV_NATIVE_EXT" ]; then
|
||||
echo "rbenv: failed to load \`realpath' builtin" >&2
|
||||
exit 1
|
||||
fi
|
||||
RBENV_TEST_DIR="$(mktemp -d --tmpdir=$BATS_TMPDIR rbenv.bats.XXX)"
|
||||
fi
|
||||
|
||||
# guard against executing this block twice due to bats internals
|
||||
if [ "$RBENV_ROOT" != "${RBENV_TEST_DIR}/root" ]; then
|
||||
if [ -z "$RBENV_TEST_DIR" ]; then
|
||||
RBENV_TEST_DIR="${BATS_TMPDIR}/rbenv"
|
||||
export RBENV_TEST_DIR="$(mktemp -d "${RBENV_TEST_DIR}.XXX" 2>/dev/null || echo "$RBENV_TEST_DIR")"
|
||||
|
||||
if enable -f "${BATS_TEST_DIRNAME}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then
|
||||
export RBENV_TEST_DIR="$(realpath "$RBENV_TEST_DIR")"
|
||||
else
|
||||
if [ -n "$RBENV_NATIVE_EXT" ]; then
|
||||
echo "rbenv: failed to load \`realpath' builtin" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
export RBENV_ROOT="${RBENV_TEST_DIR}/root"
|
||||
export HOME="${RBENV_TEST_DIR}/home"
|
||||
|
||||
|
|
Loading…
Reference in a new issue