mirror of
https://github.com/pyenv/pyenv.git
synced 2026-10-02 23:41:06 +09:00
tests: python-buid: use helpers from core (#3572)
This commit is contained in:
parent
699e27fb27
commit
2e3d62a129
@ -1,3 +1,5 @@
|
|||||||
|
source "${BATS_TEST_DIRNAME}/../../../test/test_helper.bash"
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
export PYTHON_BUILD_CURL_OPTS=
|
export PYTHON_BUILD_CURL_OPTS=
|
||||||
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
||||||
@ -69,12 +71,6 @@ install_fixture() {
|
|||||||
run python-build $args "$FIXTURE_ROOT/$name" "$destination"
|
run python-build $args "$FIXTURE_ROOT/$name" "$destination"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert() {
|
|
||||||
if ! "$@"; then
|
|
||||||
flunk "failed: $@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
refute() {
|
refute() {
|
||||||
if "$@"; then
|
if "$@"; then
|
||||||
flunk "expected to fail: $@"
|
flunk "expected to fail: $@"
|
||||||
@ -99,32 +95,6 @@ assert_success() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_failure() {
|
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
flunk "expected failed exit status"
|
|
||||||
elif [ "$#" -gt 0 ]; then
|
|
||||||
assert_output "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_equal() {
|
|
||||||
if [ "$1" != "$2" ]; then
|
|
||||||
{ echo "expected:"
|
|
||||||
echo "$1"
|
|
||||||
echo "actual:"
|
|
||||||
echo "$2"
|
|
||||||
} | flunk
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_output() {
|
|
||||||
local expected
|
|
||||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
|
||||||
else expected="$1"
|
|
||||||
fi
|
|
||||||
assert_equal "$expected" "$output"
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_output_contains() {
|
assert_output_contains() {
|
||||||
local expected="$1"
|
local expected="$1"
|
||||||
if [ -z "$expected" ]; then
|
if [ -z "$expected" ]; then
|
||||||
@ -137,46 +107,3 @@ assert_output_contains() {
|
|||||||
} | flunk
|
} | flunk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_line() {
|
|
||||||
if [ "$1" -ge 0 ] 2>/dev/null; then
|
|
||||||
assert_equal "$2" "${lines[$1]}"
|
|
||||||
else
|
|
||||||
local line
|
|
||||||
for line in "${lines[@]}"; do
|
|
||||||
if [ "$line" = "$1" ]; then return 0; fi
|
|
||||||
done
|
|
||||||
flunk "expected line \`$1'" $'\n'\
|
|
||||||
"output: $output"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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 path=":${PATH}:"
|
|
||||||
for exe; do
|
|
||||||
local found alt util
|
|
||||||
for found in $(PATH="$path" type -aP "$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 tr; do
|
|
||||||
if [ -x "${found}/$util" ]; then
|
|
||||||
ln -s "${found}/$util" "${alt}/$util"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
path="${path/:${found}:/:${alt}:}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
path="${path#:}"
|
|
||||||
path="${path%:}"
|
|
||||||
echo "$path"
|
|
||||||
}
|
|
||||||
|
|
||||||
skip_if_nonposix_security() {
|
|
||||||
true "${1:?}" "${2:?}"
|
|
||||||
test "$@" && skip "UNIX permission bits are being overridden" || true
|
|
||||||
}
|
|
||||||
|
|||||||
@ -68,6 +68,7 @@ assert_success() {
|
|||||||
if [ "$status" -ne 0 ]; then
|
if [ "$status" -ne 0 ]; then
|
||||||
flunk "command failed with exit status $status" $'\n'\
|
flunk "command failed with exit status $status" $'\n'\
|
||||||
"output: $output"
|
"output: $output"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
_assert_output_if_provided "$@"
|
_assert_output_if_provided "$@"
|
||||||
}
|
}
|
||||||
@ -76,6 +77,7 @@ assert_failure() {
|
|||||||
if [ "$status" -eq 0 ]; then
|
if [ "$status" -eq 0 ]; then
|
||||||
flunk "expected failed exit status" $'\n'\
|
flunk "expected failed exit status" $'\n'\
|
||||||
"output: $output"
|
"output: $output"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
_assert_output_if_provided "$@"
|
_assert_output_if_provided "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user