Commit 2d2eef70 by Yamashita, Yuu

Remove `aria2c` from PATH to use `curl` stub during test

parent e56f6cf8
......@@ -8,6 +8,7 @@ export CC=cc
export -n RUBY_CONFIGURE_OPTS
setup() {
ensure_not_found_in_path aria2c
mkdir -p "$INSTALL_ROOT"
stub md5 false
stub aria2c false
......
......@@ -6,6 +6,7 @@ export RUBY_BUILD_CACHE_PATH="$TMP/cache"
export RUBY_BUILD_ARIA2_OPTS=
setup() {
ensure_not_found_in_path aria2c
mkdir "$RUBY_BUILD_CACHE_PATH"
}
......
......@@ -5,6 +5,7 @@ export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
setup() {
ensure_not_found_in_path aria2c
export RUBY_BUILD_BUILD_PATH="${TMP}/source"
mkdir -p "${RUBY_BUILD_BUILD_PATH}"
}
......
......@@ -3,6 +3,7 @@
load test_helper
setup() {
ensure_not_found_in_path aria2c
export RBENV_ROOT="${TMP}/rbenv"
export HOOK_PATH="${TMP}/i has hooks"
mkdir -p "$HOOK_PATH"
......
......@@ -4,6 +4,7 @@ load test_helper
export RBENV_ROOT="${TMP}/rbenv"
setup() {
ensure_not_found_in_path aria2c
stub rbenv-hooks 'install : true'
stub rbenv-rehash 'true'
}
......
......@@ -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:?}"/*
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment