Просмотр исходного кода

Fix emulating the scenario where system Ruby is missing on OpenBSD

On other systems, we expected to find system Ruby in `/usr/bin`, but in
OpenBSD 5.4 it will be found in `/usr/local/bin`.

This replaces the limited USRBIN_ALT hack with a more generic
`path_without` function that will ensure that the given executable is
not present in the resulting PATH even if it's found in multiple
system paths.
pull/360/head^2
Mislav Marohnić 12 лет назад
Родитель
Сommit
1e1c9cb0dc
2 измененных файлов: 23 добавлений и 10 удалений
  1. +1
    -10
      test/prefix.bats
  2. +22
    -0
      test/test_helper.bash

+ 1
- 10
test/prefix.bats Просмотреть файл

@ -25,15 +25,6 @@ load test_helper
}
@test "prefix for invalid system" {
USRBIN_ALT="${RBENV_TEST_DIR}/usr-bin-alt"
mkdir -p "$USRBIN_ALT"
for util in head readlink greadlink; do
if [ -x "/usr/bin/$util" ]; then
ln -s "/usr/bin/$util" "${USRBIN_ALT}/$util"
fi
done
PATH_WITHOUT_RUBY="${PATH/\/usr\/bin:/$USRBIN_ALT:}"
PATH="$PATH_WITHOUT_RUBY" run rbenv-prefix system
PATH="$(path_without ruby)" run rbenv-prefix system
assert_failure "rbenv: system version not found in PATH"
}

+ 22
- 0
test/test_helper.bash Просмотреть файл

@ -93,3 +93,25 @@ assert() {
flunk "failed: $@"
fi
}
# Output a modified PATH that ensures that the given executable is not present,
# but in which system utils necessary for rbenv operation are still available.
path_without() {
local exe="$1"
local path="${PATH}:"
local found alt util
for found in $(which -a "$exe"); do
found="${found%/*}"
if [ "$found" != "${RBENV_ROOT}/shims" ]; then
alt="${RBENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
mkdir -p "$alt"
for util in bash head cut readlink greadlink; do
if [ -x "${found}/$util" ]; then
ln -s "${found}/$util" "${alt}/$util"
fi
done
path="${path/${found}:/${alt}:}"
fi
done
echo "${path%:}"
}

Загрузка…
Отмена
Сохранить