ensure cleaner PATH in test environment

This commit is contained in:
Mislav Marohnić 2013-06-20 20:38:07 +02:00
parent 5130b41f5b
commit 8b043038b8

View file

@ -1,14 +1,20 @@
RBENV_TEST_DIR="${BATS_TMPDIR}/rbenv"
export RBENV_ROOT="${RBENV_TEST_DIR}/root"
export HOME="${RBENV_TEST_DIR}/home"
unset RBENV_VERSION unset RBENV_VERSION
unset RBENV_DIR unset RBENV_DIR
export PATH="${RBENV_TEST_DIR}/bin:$PATH" RBENV_TEST_DIR="${BATS_TMPDIR}/rbenv"
export PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH"
export PATH="${BATS_TEST_DIRNAME}/libexec:$PATH" # guard against executing this block twice due to bats internals
export PATH="${RBENV_ROOT}/shims:$PATH" if [ "$RBENV_ROOT" != "${RBENV_TEST_DIR}/root" ]; then
export RBENV_ROOT="${RBENV_TEST_DIR}/root"
export HOME="${RBENV_TEST_DIR}/home"
PATH=/usr/bin:/bin:/usr/sbin:/sbin
PATH="${RBENV_TEST_DIR}/bin:$PATH"
PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH"
PATH="${BATS_TEST_DIRNAME}/libexec:$PATH"
PATH="${RBENV_ROOT}/shims:$PATH"
export PATH
fi
teardown() { teardown() {
rm -rf "$RBENV_TEST_DIR" rm -rf "$RBENV_TEST_DIR"
@ -18,7 +24,7 @@ flunk() {
{ if [ "$#" -eq 0 ]; then cat - { if [ "$#" -eq 0 ]; then cat -
else echo "$@" else echo "$@"
fi fi
} | sed "s:${RBENV_TEST_DIR}:TEST_DIR:" >&2 } | sed "s:${RBENV_TEST_DIR}:TEST_DIR:g" >&2
return 1 return 1
} }