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

Bats: path_without: support multiple args

pull/2073/head
Ivan Pozdeev 4 лет назад
Родитель
Сommit
876be1bb04
3 измененных файлов: 19 добавлений и 17 удалений
  1. +1
    -1
      test/prefix.bats
  2. +17
    -15
      test/test_helper.bash
  3. +1
    -1
      test/versions.bats

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

@ -46,6 +46,6 @@ OUT
}
@test "prefix for invalid system" {
PATH="$(path_without python)" run pyenv-prefix system
PATH="$(path_without python python2 python3)" run pyenv-prefix system
assert_failure "pyenv: system version not found in PATH"
}

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

@ -111,24 +111,26 @@ assert() {
# Output a modified PATH that ensures that the given executable is not present,
# but in which system utils necessary for pyenv 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" != "${PYENV_ROOT}/shims" ]; then
alt="${PYENV_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
for exe; do
local found alt util
for found in $(PATH="$path" which -a "$exe"); do
found="${found%/*}"
if [ "$found" != "${PYENV_ROOT}/shims" ]; then
alt="${PYENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')"
mkdir -p "$alt"
for util in bash head cut readlink greadlink which; do
if [ -x "${found}/$util" ]; then
ln -s "${found}/$util" "${alt}/$util"
fi
done
path="${path/:${found}:/:${alt}:}"
fi
done
done
path="${path#:}"
echo "${path%:}"
path="${path%:}"
echo "$path"
}
create_hook() {

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

@ -25,7 +25,7 @@ stub_system_python() {
}
@test "not even system python available" {
PATH="$(path_without python)" run pyenv-versions
PATH="$(path_without python python2 python3)" run pyenv-versions
assert_failure
assert_output "Warning: no Python detected on the system"
}

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