mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-09 20:13:47 -05:00
Use curl stub instead of aria2c during tests (equiv to rbenv/ruby-build#965)
This commit is contained in:
@@ -9,6 +9,39 @@ if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
|
||||
export PATH
|
||||
fi
|
||||
|
||||
remove_command_from_path() {
|
||||
OLDIFS="${IFS}"
|
||||
local cmd="$1"
|
||||
local path
|
||||
local paths=()
|
||||
IFS=:
|
||||
for path in ${PATH}; do
|
||||
if [ -e "${path}/${cmd}" ]; then
|
||||
local tmp_path="$(mktemp -d "${TMP}/path.XXXXX")"
|
||||
ln -fs "${path}"/* "${tmp_path}"
|
||||
rm -f "${tmp_path}/${cmd}"
|
||||
paths["${#paths[@]}"]="${tmp_path}"
|
||||
else
|
||||
paths["${#paths[@]}"]="${path}"
|
||||
fi
|
||||
done
|
||||
export PATH="${paths[*]}"
|
||||
IFS="${OLDIFS}"
|
||||
}
|
||||
|
||||
ensure_not_found_in_path() {
|
||||
local cmd
|
||||
for cmd; do
|
||||
if command -v "${cmd}" 1>/dev/null 2>&1; then
|
||||
remove_command_from_path "${cmd}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
setup() {
|
||||
ensure_not_found_in_path aria2c
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm -fr "${TMP:?}"/*
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user