Explorar el Código

Merge branch 'openbsd'

Closes #524
pull/360/head^2
Mislav Marohnić hace 10 años
padre
commit
14bc162ca6
Se han modificado 6 ficheros con 30 adiciones y 16 borrados
  1. +1
    -1
      libexec/rbenv-completions
  2. +2
    -1
      libexec/rbenv-init
  3. +1
    -1
      test/completions.bats
  4. +2
    -2
      test/init.bats
  5. +1
    -10
      test/prefix.bats
  6. +23
    -1
      test/test_helper.bash

+ 1
- 1
libexec/rbenv-completions Ver fichero

@ -11,7 +11,7 @@ if [ -z "$COMMAND" ]; then
fi
COMMAND_PATH="$(command -v "rbenv-$COMMAND" || command -v "rbenv-sh-$COMMAND")"
if grep -i "^\([#%]\|--\|//\) provide rbenv completions" "$COMMAND_PATH" >/dev/null; then
if grep -iE "^([#%]|--|//) provide rbenv completions" "$COMMAND_PATH" >/dev/null; then
shift
exec "$COMMAND_PATH" --complete "$@"
fi

+ 2
- 1
libexec/rbenv-init Ver fichero

@ -22,8 +22,9 @@ done
shell="$1"
if [ -z "$shell" ]; then
shell="$(ps c -p $(ps -p $$ -o 'ppid=' 2>/dev/null) -o 'comm=' 2>/dev/null || true)"
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
shell="${shell##-}"
shell="${shell%% *}"
shell="$(basename "${shell:-$SHELL}")"
fi

+ 1
- 1
test/completions.bats Ver fichero

@ -18,7 +18,7 @@ create_command() {
@test "command with completion support" {
create_command "rbenv-hello" "#!$BASH
# provide rbenv completions
# Provide rbenv completions
if [[ \$1 = --complete ]]; then
echo hello
else

+ 2
- 2
test/init.bats Ver fichero

@ -51,14 +51,14 @@ load test_helper
}
@test "adds shims to PATH" {
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin"
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run rbenv-init - bash
assert_success
assert_line 0 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"'
}
@test "adds shims to PATH (fish)" {
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin"
export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin"
run rbenv-init - fish
assert_success
assert_line 0 "setenv PATH '${RBENV_ROOT}/shims' \$PATH"

+ 1
- 10
test/prefix.bats Ver fichero

@ -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"
}

+ 23
- 1
test/test_helper.bash Ver fichero

@ -8,7 +8,7 @@ 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=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
PATH="${RBENV_TEST_DIR}/bin:$PATH"
PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH"
PATH="${BATS_TEST_DIRNAME}/libexec:$PATH"
@ -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%:}"
}

Cargando…
Cancelar
Guardar