pyenv verification source
Some checks are pending
macos_build / macos_build (3.10) (push) Waiting to run
macos_build / macos_build (3.11) (push) Waiting to run
macos_build / macos_build (3.12) (push) Waiting to run
macos_build / macos_build (3.13) (push) Waiting to run
macos_build / macos_build (3.14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15-intel) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-26) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Waiting to run
ubuntu_build / ubuntu_build (3.10) (push) Waiting to run
ubuntu_build / ubuntu_build (3.11) (push) Waiting to run
ubuntu_build / ubuntu_build (3.12) (push) Waiting to run
ubuntu_build / ubuntu_build (3.13) (push) Waiting to run
ubuntu_build / ubuntu_build (3.14) (push) Waiting to run
Some checks are pending
macos_build / macos_build (3.10) (push) Waiting to run
macos_build / macos_build (3.11) (push) Waiting to run
macos_build / macos_build (3.12) (push) Waiting to run
macos_build / macos_build (3.13) (push) Waiting to run
macos_build / macos_build (3.14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-14) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-15-intel) (push) Waiting to run
pyenv_tests / pyenv_tests (macos-26) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-22.04) (push) Waiting to run
pyenv_tests / pyenv_tests (ubuntu-24.04) (push) Waiting to run
ubuntu_build / ubuntu_build (3.10) (push) Waiting to run
ubuntu_build / ubuntu_build (3.11) (push) Waiting to run
ubuntu_build / ubuntu_build (3.12) (push) Waiting to run
ubuntu_build / ubuntu_build (3.13) (push) Waiting to run
ubuntu_build / ubuntu_build (3.14) (push) Waiting to run
This commit is contained in:
23
plugins/python-build/test/arguments.bats
Normal file
23
plugins/python-build/test/arguments.bats
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
@test "not enough arguments for python-build" {
|
||||
# use empty inline definition so nothing gets built anyway
|
||||
local definition="${BATS_TEST_TMPDIR}/build-definition"
|
||||
echo '' > "$definition"
|
||||
|
||||
run python-build "$definition"
|
||||
assert_failure
|
||||
assert_output_contains 'Usage: python-build'
|
||||
}
|
||||
|
||||
@test "extra arguments for python-build" {
|
||||
# use empty inline definition so nothing gets built anyway
|
||||
local definition="${BATS_TEST_TMPDIR}/build-definition"
|
||||
echo '' > "$definition"
|
||||
|
||||
run python-build "$definition" "${BATS_TEST_TMPDIR}/install" ""
|
||||
assert_failure
|
||||
assert_output_contains 'Usage: python-build'
|
||||
}
|
||||
1305
plugins/python-build/test/build.bats
Normal file
1305
plugins/python-build/test/build.bats
Normal file
File diff suppressed because it is too large
Load Diff
88
plugins/python-build/test/cache.bats
Normal file
88
plugins/python-build/test/cache.bats
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
_setup() {
|
||||
export PYTHON_BUILD_SKIP_MIRROR=1
|
||||
export PYTHON_BUILD_CACHE_PATH="$BATS_TEST_TMPDIR/cache"
|
||||
mkdir "$PYTHON_BUILD_CACHE_PATH"
|
||||
}
|
||||
|
||||
|
||||
@test "packages are saved to download cache" {
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
}
|
||||
|
||||
|
||||
@test "cached package without checksum" {
|
||||
stub curl
|
||||
|
||||
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
}
|
||||
|
||||
|
||||
@test "cached package with valid checksum" {
|
||||
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
stub curl
|
||||
|
||||
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "cached package with invalid checksum falls back to mirror and updates cache" {
|
||||
export PYTHON_BUILD_SKIP_MIRROR=
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
|
||||
stub shasum true "echo invalid" "echo $checksum"
|
||||
stub curl "-*I* * : true" \
|
||||
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
|
||||
|
||||
touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
||||
assert diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "nonexistent cache directory is ignored" {
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
export PYTHON_BUILD_CACHE_PATH="${BATS_TEST_TMPDIR}/nonexistent"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
refute [ -d "$PYTHON_BUILD_CACHE_PATH" ]
|
||||
|
||||
unstub curl
|
||||
}
|
||||
157
plugins/python-build/test/checksum.bats
Normal file
157
plugins/python-build/test/checksum.bats
Normal file
@@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
export PYTHON_BUILD_SKIP_MIRROR=1
|
||||
export PYTHON_BUILD_CACHE_PATH=
|
||||
|
||||
|
||||
@test "package URL without checksum" {
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with valid checksum" {
|
||||
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with invalid checksum" {
|
||||
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-invalid-checksum
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with checksum but no shasum support" {
|
||||
stub shasum false
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with valid md5 checksum" {
|
||||
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-md5-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub md5
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with md5 checksum but no md5 support" {
|
||||
stub md5 false
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-md5-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub md5
|
||||
}
|
||||
|
||||
|
||||
@test "package with invalid checksum" {
|
||||
stub shasum true "echo invalid"
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
@test "existing tarball in build location is reused" {
|
||||
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
stub curl false
|
||||
stub wget false
|
||||
|
||||
export -n PYTHON_BUILD_CACHE_PATH
|
||||
export PYTHON_BUILD_BUILD_PATH="${BATS_TEST_TMPDIR}/build"
|
||||
|
||||
mkdir -p "$PYTHON_BUILD_BUILD_PATH"
|
||||
ln -s "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_BUILD_PATH"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
||||
DEF
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
@test "existing tarball in build location is discarded if not matching checksum" {
|
||||
stub shasum true \
|
||||
"echo invalid" \
|
||||
"echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
export -n PYTHON_BUILD_CACHE_PATH
|
||||
export PYTHON_BUILD_BUILD_PATH="${BATS_TEST_TMPDIR}/build"
|
||||
|
||||
mkdir -p "$PYTHON_BUILD_BUILD_PATH"
|
||||
touch "${PYTHON_BUILD_BUILD_PATH}/package-1.0.0.tar.gz"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
||||
DEF
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
@test "package URL with checksum of unexpected length" {
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy
|
||||
DEF
|
||||
|
||||
assert_failure
|
||||
refute [ -f "${INSTALL_ROOT}/bin/package" ]
|
||||
assert_output_contains "unexpected checksum length: 29 (checksum_of_unexpected_length)"
|
||||
assert_output_contains "expected 0 (no checksum), 32 (MD5), or 64 (SHA2-256)"
|
||||
}
|
||||
127
plugins/python-build/test/compiler.bats
Normal file
127
plugins/python-build/test/compiler.bats
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
_setup() {
|
||||
export MAKE=make
|
||||
export MAKE_OPTS='-j 2'
|
||||
export -n CFLAGS
|
||||
export -n CC
|
||||
export -n PYTHON_CONFIGURE_OPTS
|
||||
}
|
||||
|
||||
@test "require_gcc on OS X 10.9" {
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.9.5'
|
||||
|
||||
stub gcc '--version : echo 4.2.1'
|
||||
|
||||
run_inline_definition <<DEF
|
||||
require_gcc
|
||||
echo CC=\$CC
|
||||
echo MACOSX_DEPLOYMENT_TARGET=\${MACOSX_DEPLOYMENT_TARGET-no}
|
||||
DEF
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
CC=${BATS_TEST_TMPDIR}/bin/gcc
|
||||
MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
OUT
|
||||
|
||||
unstub uname
|
||||
unstub sw_vers
|
||||
unstub gcc
|
||||
}
|
||||
|
||||
@test "require_gcc on OS X 10.10" {
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
|
||||
stub gcc '--version : echo 4.2.1'
|
||||
|
||||
run_inline_definition <<DEF
|
||||
require_gcc
|
||||
echo CC=\$CC
|
||||
echo MACOSX_DEPLOYMENT_TARGET=\${MACOSX_DEPLOYMENT_TARGET-no}
|
||||
DEF
|
||||
|
||||
unstub uname
|
||||
unstub sw_vers
|
||||
unstub gcc
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
CC=${BATS_TEST_TMPDIR}/bin/gcc
|
||||
MACOSX_DEPLOYMENT_TARGET=10.10
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "require_gcc silences warnings" {
|
||||
stub gcc '--version : echo warning >&2; echo 4.2.1'
|
||||
|
||||
run_inline_definition <<DEF
|
||||
require_gcc
|
||||
echo \$CC
|
||||
DEF
|
||||
assert_success "${BATS_TEST_TMPDIR}/bin/gcc"
|
||||
|
||||
unstub gcc
|
||||
}
|
||||
|
||||
@test "CC=clang by default on OS X 10.10" {
|
||||
mkdir -p "$INSTALL_ROOT"
|
||||
cd "$INSTALL_ROOT"
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
|
||||
stub cc 'false'
|
||||
stub brew 'false'
|
||||
stub make \
|
||||
'echo make $@' \
|
||||
'echo make $@'
|
||||
|
||||
cat > ./configure <<CON
|
||||
#!${BASH}
|
||||
echo ./configure "\$@"
|
||||
echo CC=\$CC
|
||||
echo CFLAGS=\${CFLAGS-no}
|
||||
CON
|
||||
chmod +x ./configure
|
||||
|
||||
run_inline_definition <<DEF
|
||||
exec 4<&1
|
||||
build_package_standard python
|
||||
DEF
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
./configure --prefix=$INSTALL_ROOT --enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib
|
||||
CC=clang
|
||||
CFLAGS=no
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
||||
unstub uname
|
||||
unstub sw_vers
|
||||
|
||||
}
|
||||
|
||||
@test "passthrough CFLAGS_EXTRA to micropython compiler" {
|
||||
mkdir -p "$INSTALL_ROOT/mpy-cross"
|
||||
mkdir -p "$INSTALL_ROOT/ports/unix"
|
||||
mkdir -p "$INSTALL_ROOT/bin"
|
||||
cd "$INSTALL_ROOT"
|
||||
|
||||
stub make true '(for a in "$@"; do echo $a; done)|grep -E "^CFLAGS_EXTRA="' true
|
||||
stub ln true
|
||||
stub mkdir true
|
||||
run_inline_definition <<DEF
|
||||
exec 4<&1
|
||||
CFLAGS_EXTRA='-Wno-floating-conversion' build_package_micropython
|
||||
DEF
|
||||
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
CFLAGS_EXTRA=-DMICROPY_PY_SYS_PATH_DEFAULT='".frozen:${BATS_TEST_TMPDIR}/install/lib/micropython"' -Wno-floating-conversion
|
||||
OUT
|
||||
}
|
||||
110
plugins/python-build/test/definitions.bats
Normal file
110
plugins/python-build/test/definitions.bats
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
NUM_DEFINITIONS="$(find "$BATS_TEST_DIRNAME"/../share/python-build -maxdepth 1 -type f | wc -l)"
|
||||
|
||||
@test "list built-in definitions" {
|
||||
run python-build --definitions
|
||||
assert_success
|
||||
assert_output_contains "2.7.8"
|
||||
assert_output_contains "jython-2.5.3"
|
||||
assert [ "${#lines[*]}" -eq "$NUM_DEFINITIONS" ]
|
||||
}
|
||||
|
||||
@test "custom PYTHON_BUILD_ROOT: nonexistent" {
|
||||
export PYTHON_BUILD_ROOT="$BATS_TEST_TMPDIR"
|
||||
refute [ -e "${PYTHON_BUILD_ROOT}/share/python-build" ]
|
||||
run python-build --definitions
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@test "custom PYTHON_BUILD_ROOT: single definition" {
|
||||
export PYTHON_BUILD_ROOT="$BATS_TEST_TMPDIR"
|
||||
mkdir -p "${PYTHON_BUILD_ROOT}/share/python-build"
|
||||
touch "${PYTHON_BUILD_ROOT}/share/python-build/2.7.8-test"
|
||||
run python-build --definitions
|
||||
assert_success "2.7.8-test"
|
||||
}
|
||||
|
||||
@test "one path via PYTHON_BUILD_DEFINITIONS" {
|
||||
export PYTHON_BUILD_DEFINITIONS="${BATS_TEST_TMPDIR}/definitions"
|
||||
mkdir -p "$PYTHON_BUILD_DEFINITIONS"
|
||||
touch "${PYTHON_BUILD_DEFINITIONS}/2.7.8-test"
|
||||
run python-build --definitions
|
||||
assert_success
|
||||
assert_output_contains "2.7.8-test"
|
||||
assert [ "${#lines[*]}" -eq "$((NUM_DEFINITIONS + 1))" ]
|
||||
}
|
||||
|
||||
@test "multiple paths via PYTHON_BUILD_DEFINITIONS" {
|
||||
export PYTHON_BUILD_DEFINITIONS="${BATS_TEST_TMPDIR}/definitions:${BATS_TEST_TMPDIR}/other"
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/definitions"
|
||||
touch "${BATS_TEST_TMPDIR}/definitions/2.7.8-test"
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/other"
|
||||
touch "${BATS_TEST_TMPDIR}/other/3.4.2-test"
|
||||
run python-build --definitions
|
||||
assert_success
|
||||
assert_output_contains "2.7.8-test"
|
||||
assert_output_contains "3.4.2-test"
|
||||
assert [ "${#lines[*]}" -eq "$((NUM_DEFINITIONS + 2))" ]
|
||||
}
|
||||
|
||||
@test "installing definition from PYTHON_BUILD_DEFINITIONS by priority" {
|
||||
export PYTHON_BUILD_DEFINITIONS="${BATS_TEST_TMPDIR}/definitions:${BATS_TEST_TMPDIR}/other"
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/definitions"
|
||||
echo true > "${BATS_TEST_TMPDIR}/definitions/2.7.8-test"
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/other"
|
||||
echo false > "${BATS_TEST_TMPDIR}/other/2.7.8-test"
|
||||
run python-build "2.7.8-test" "${BATS_TEST_TMPDIR}/install"
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@test "installing nonexistent definition" {
|
||||
run python-build "nonexistent" "${BATS_TEST_TMPDIR}/install"
|
||||
assert [ "$status" -eq 2 ]
|
||||
assert_output "python-build: definition not found: nonexistent"
|
||||
}
|
||||
|
||||
@test "sorting Python versions" {
|
||||
export PYTHON_BUILD_ROOT="$BATS_TEST_TMPDIR"
|
||||
mkdir -p "${PYTHON_BUILD_ROOT}/share/python-build"
|
||||
expected="2.7-dev
|
||||
2.7
|
||||
2.7.1
|
||||
2.7.2
|
||||
2.7.3
|
||||
3.4.0
|
||||
3.4-dev
|
||||
3.4.1
|
||||
3.4.2
|
||||
jython-dev
|
||||
jython-2.5.0
|
||||
jython-2.5-dev
|
||||
jython-2.5.1
|
||||
jython-2.5.2
|
||||
jython-2.5.3
|
||||
jython-2.5.4-rc1
|
||||
jython-2.7-beta1
|
||||
jython-2.7-beta2
|
||||
jython-2.7-beta3"
|
||||
while IFS=$'\n' read -r ver; do
|
||||
touch "${PYTHON_BUILD_ROOT}/share/python-build/$ver"
|
||||
done <<<"$expected"
|
||||
run python-build --definitions
|
||||
assert_success "$expected"
|
||||
}
|
||||
|
||||
@test "removing duplicate Python versions" {
|
||||
export PYTHON_BUILD_ROOT="$BATS_TEST_TMPDIR"
|
||||
export PYTHON_BUILD_DEFINITIONS="${PYTHON_BUILD_ROOT}/share/python-build"
|
||||
mkdir -p "$PYTHON_BUILD_DEFINITIONS"
|
||||
touch "${PYTHON_BUILD_DEFINITIONS}/2.7.8"
|
||||
touch "${PYTHON_BUILD_DEFINITIONS}/3.4.2"
|
||||
|
||||
run python-build --definitions
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
2.7.8
|
||||
3.4.2
|
||||
OUT
|
||||
}
|
||||
67
plugins/python-build/test/fetch.bats
Normal file
67
plugins/python-build/test/fetch.bats
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
_setup() {
|
||||
export PYTHON_BUILD_SKIP_MIRROR=1
|
||||
export PYTHON_BUILD_CACHE_PATH=
|
||||
export PYTHON_BUILD_BUILD_PATH="${BATS_TEST_TMPDIR}/source"
|
||||
mkdir -p "${PYTHON_BUILD_BUILD_PATH}"
|
||||
}
|
||||
|
||||
@test "failed download displays error message" {
|
||||
stub curl false
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
assert_failure
|
||||
assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz"
|
||||
assert_output_contains "error: failed to download package-1.0.0.tar.gz"
|
||||
}
|
||||
|
||||
@test "using aria2c if available" {
|
||||
export PYTHON_BUILD_ARIA2_OPTS=
|
||||
export -n PYTHON_BUILD_HTTP_CLIENT
|
||||
stub aria2c "--allow-overwrite=true --no-conf=true -d * -o * http://example.com/* : cp $FIXTURE_ROOT/\${7##*/} \$6"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
Downloading package-1.0.0.tar.gz...
|
||||
-> http://example.com/packages/package-1.0.0.tar.gz
|
||||
Installing package-1.0.0...
|
||||
Installed package-1.0.0 to ${BATS_TEST_TMPDIR}/install
|
||||
OUT
|
||||
unstub aria2c
|
||||
}
|
||||
|
||||
@test "fetching from git repository" {
|
||||
stub git "clone --depth 1 --branch master http://example.com/packages/package.git package-dev : mkdir package-dev"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_git "package-dev" "http://example.com/packages/package.git" master copy
|
||||
DEF
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
Cloning http://example.com/packages/package.git...
|
||||
Installing package-dev...
|
||||
Installed package-dev to ${BATS_TEST_TMPDIR}/install
|
||||
OUT
|
||||
unstub git
|
||||
}
|
||||
|
||||
@test "updating existing git repository" {
|
||||
mkdir -p "${PYTHON_BUILD_BUILD_PATH}/package-dev"
|
||||
stub git \
|
||||
"fetch --depth 1 origin +master : true" \
|
||||
"checkout -q -B master origin/master : true"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_git "package-dev" "http://example.com/packages/package.git" master copy
|
||||
DEF
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
Cloning http://example.com/packages/package.git...
|
||||
Installing package-dev...
|
||||
Installed package-dev to ${BATS_TEST_TMPDIR}/install
|
||||
OUT
|
||||
unstub git
|
||||
}
|
||||
2
plugins/python-build/test/fixtures/definitions/needs-yaml
vendored
Normal file
2
plugins/python-build/test/fixtures/definitions/needs-yaml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
install_package "yaml-0.1.6" "http://pyyaml.org/download/libyaml/yaml-0.1.6.tar.gz" --if needs_yaml
|
||||
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
|
||||
1
plugins/python-build/test/fixtures/definitions/vanilla-python
vendored
Normal file
1
plugins/python-build/test/fixtures/definitions/vanilla-python
vendored
Normal file
@@ -0,0 +1 @@
|
||||
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
|
||||
1
plugins/python-build/test/fixtures/definitions/with-checksum
vendored
Normal file
1
plugins/python-build/test/fixtures/definitions/with-checksum
vendored
Normal file
@@ -0,0 +1 @@
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
||||
1
plugins/python-build/test/fixtures/definitions/with-invalid-checksum
vendored
Normal file
1
plugins/python-build/test/fixtures/definitions/with-invalid-checksum
vendored
Normal file
@@ -0,0 +1 @@
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#invalid_64_character_checksum_0000000000000000000000000000000000" copy
|
||||
1
plugins/python-build/test/fixtures/definitions/with-md5-checksum
vendored
Normal file
1
plugins/python-build/test/fixtures/definitions/with-md5-checksum
vendored
Normal file
@@ -0,0 +1 @@
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#83e6d7725e20166024a1eb74cde80677" copy
|
||||
1
plugins/python-build/test/fixtures/definitions/without-checksum
vendored
Normal file
1
plugins/python-build/test/fixtures/definitions/without-checksum
vendored
Normal file
@@ -0,0 +1 @@
|
||||
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz" copy
|
||||
BIN
plugins/python-build/test/fixtures/package-1.0.0.tar.gz
vendored
Normal file
BIN
plugins/python-build/test/fixtures/package-1.0.0.tar.gz
vendored
Normal file
Binary file not shown.
94
plugins/python-build/test/hooks.bats
Normal file
94
plugins/python-build/test/hooks.bats
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
_setup() {
|
||||
export PYENV_ROOT="${BATS_TEST_TMPDIR}/pyenv"
|
||||
export HOOK_PATH="${BATS_TEST_TMPDIR}/i has hooks"
|
||||
mkdir -p "$HOOK_PATH"
|
||||
}
|
||||
|
||||
@test "pyenv-install hooks" {
|
||||
cat > "${HOOK_PATH}/install.bash" <<OUT
|
||||
before_install 'echo before: \$PREFIX'
|
||||
after_install 'echo after: \$STATUS'
|
||||
OUT
|
||||
stub pyenv-hooks "install : echo '$HOOK_PATH'/install.bash"
|
||||
stub pyenv-rehash "echo rehashed"
|
||||
|
||||
definition="${BATS_TEST_TMPDIR}/3.6.2"
|
||||
stub pyenv-latest "echo $definition"
|
||||
|
||||
cat > "$definition" <<<"echo python-build"
|
||||
run pyenv-install "$definition"
|
||||
|
||||
assert_success
|
||||
assert_output <<-OUT
|
||||
before: ${PYENV_ROOT}/versions/3.6.2
|
||||
python-build
|
||||
after: 0
|
||||
rehashed
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "pyenv-uninstall hooks" {
|
||||
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
|
||||
before_uninstall 'echo before: \$PREFIX'
|
||||
after_uninstall 'echo after.'
|
||||
rm() {
|
||||
echo "rm \$@"
|
||||
command rm "\$@"
|
||||
}
|
||||
OUT
|
||||
stub pyenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
|
||||
stub pyenv-rehash "echo rehashed"
|
||||
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.6.2"
|
||||
run pyenv-uninstall -f 3.6.2
|
||||
|
||||
assert_success
|
||||
assert_output <<-OUT
|
||||
before: ${PYENV_ROOT}/versions/3.6.2
|
||||
rm -rf ${PYENV_ROOT}/versions/3.6.2
|
||||
rehashed
|
||||
pyenv: 3.6.2 uninstalled
|
||||
after.
|
||||
OUT
|
||||
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
|
||||
}
|
||||
|
||||
@test "pyenv-uninstall hooks with multiple versions" {
|
||||
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
|
||||
before_uninstall 'echo before: \$PREFIX'
|
||||
after_uninstall 'echo after.'
|
||||
rm() {
|
||||
echo "rm \$@"
|
||||
command rm "\$@"
|
||||
}
|
||||
OUT
|
||||
stub pyenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
|
||||
stub pyenv-rehash "echo rehashed"
|
||||
stub pyenv-rehash "echo rehashed"
|
||||
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.6.2"
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.6.3"
|
||||
run pyenv-uninstall -f 3.6.2 3.6.3
|
||||
|
||||
assert_success
|
||||
assert_output <<-OUT
|
||||
before: ${PYENV_ROOT}/versions/3.6.2
|
||||
rm -rf ${PYENV_ROOT}/versions/3.6.2
|
||||
rehashed
|
||||
pyenv: 3.6.2 uninstalled
|
||||
after.
|
||||
before: ${PYENV_ROOT}/versions/3.6.3
|
||||
rm -rf ${PYENV_ROOT}/versions/3.6.3
|
||||
rehashed
|
||||
pyenv: 3.6.3 uninstalled
|
||||
after.
|
||||
OUT
|
||||
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.6.3" ]
|
||||
}
|
||||
61
plugins/python-build/test/installer.bats
Normal file
61
plugins/python-build/test/installer.bats
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
@test "installs python-build into PREFIX" {
|
||||
cd "$BATS_TEST_TMPDIR"
|
||||
PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
cd usr
|
||||
|
||||
assert [ -x bin/python-build ]
|
||||
assert [ -x bin/pyenv-install ]
|
||||
assert [ -x bin/pyenv-uninstall ]
|
||||
|
||||
assert [ -e share/python-build/2.7.2 ]
|
||||
assert [ -e share/python-build/pypy-2.0 ]
|
||||
}
|
||||
|
||||
@test "build definitions don't have the executable bit" {
|
||||
cd "$BATS_TEST_TMPDIR"
|
||||
PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
run $BASH -c 'ls -l usr/share/python-build | tail -2 | cut -c1-10'
|
||||
assert_output <<OUT
|
||||
-rw-r--r--
|
||||
-rw-r--r--
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "overwrites old installation" {
|
||||
cd "$BATS_TEST_TMPDIR"
|
||||
mkdir -p bin share/python-build
|
||||
touch bin/python-build
|
||||
touch share/python-build/2.7.2
|
||||
|
||||
PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
assert [ -x bin/python-build ]
|
||||
run grep "install_package" share/python-build/2.7.2
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "unrelated files are untouched" {
|
||||
cd "$BATS_TEST_TMPDIR"
|
||||
mkdir -p bin share/bananas
|
||||
chmod g-w bin
|
||||
touch bin/bananas
|
||||
touch share/bananas/docs
|
||||
|
||||
PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
assert [ -e bin/bananas ]
|
||||
assert [ -e share/bananas/docs ]
|
||||
|
||||
run ls -ld bin
|
||||
assert_equal "-" "${output:5:1}"
|
||||
}
|
||||
150
plugins/python-build/test/mirror.bats
Normal file
150
plugins/python-build/test/mirror.bats
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
_setup() {
|
||||
export PYTHON_BUILD_SKIP_MIRROR=
|
||||
export PYTHON_BUILD_CACHE_PATH=
|
||||
export PYTHON_BUILD_MIRROR_URL=http://mirror.example.com
|
||||
}
|
||||
|
||||
@test "package URL without checksum bypasses mirror" {
|
||||
stub shasum true
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
echo "$output" >&2
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with checksum but no shasum support bypasses mirror" {
|
||||
stub shasum false
|
||||
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with checksum hits mirror first" {
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
||||
|
||||
stub shasum true "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : true" \
|
||||
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package is fetched from original URL if mirror download fails" {
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
||||
|
||||
stub shasum true "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : false" \
|
||||
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
@test "package is fetched from mirror when checksum is invalid if SKIP_CHECKSUM set" {
|
||||
export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1
|
||||
export PYTHON_BUILD_MIRROR_URL=https://custom.mirror.org
|
||||
export URL_BASE=example.com
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
|
||||
stub shasum false
|
||||
stub curl "-*I* : true" \
|
||||
"-q -o * -*S* https://custom.mirror.org/* : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
unset PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM
|
||||
}
|
||||
|
||||
|
||||
@test "package is fetched from original URL if mirror download checksum is invalid" {
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
local mirror_url="${PYTHON_BUILD_MIRROR_URL}/$checksum"
|
||||
|
||||
stub shasum true "echo invalid" "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : true" \
|
||||
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
||||
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
echo "$output" >&2
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "default mirror URL" {
|
||||
export PYTHON_BUILD_MIRROR_URL=
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
|
||||
stub shasum true "echo $checksum"
|
||||
stub curl "-*I* : true" \
|
||||
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
|
||||
|
||||
@test "package URL with ruby-lang CDN with default mirror URL will bypasses mirror" {
|
||||
export PYTHON_BUILD_MIRROR_URL=
|
||||
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
||||
|
||||
stub shasum true "echo $checksum"
|
||||
stub curl "-q -o * -*S* https://www.python.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
|
||||
|
||||
run_inline_definition <<DEF
|
||||
install_package "package-1.0.0" "https://www.python.org/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
|
||||
DEF
|
||||
|
||||
assert_success
|
||||
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
unstub curl
|
||||
unstub shasum
|
||||
}
|
||||
325
plugins/python-build/test/pyenv.bats
Normal file
325
plugins/python-build/test/pyenv.bats
Normal file
@@ -0,0 +1,325 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
_setup() {
|
||||
export PYENV_ROOT="${BATS_TEST_TMPDIR}/pyenv"
|
||||
stub pyenv-hooks 'install : true'
|
||||
stub pyenv-rehash true
|
||||
}
|
||||
|
||||
stub_python_build_lib() {
|
||||
stub python-build "--lib : $BATS_TEST_DIRNAME/../bin/python-build --lib" "$@"
|
||||
}
|
||||
|
||||
stub_python_build_no_latest() {
|
||||
stub python-build "${@:-echo python-build \"\$@\"}"
|
||||
}
|
||||
|
||||
stub_python_build() {
|
||||
stub_python_build_no_latest "$@"
|
||||
stub pyenv-latest '-f -k * : shift 2; echo "$@"'
|
||||
}
|
||||
|
||||
@test "install a single version" {
|
||||
stub_python_build_lib
|
||||
stub_python_build
|
||||
|
||||
run pyenv-install 3.4.2
|
||||
assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2"
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "install multiple versions" {
|
||||
stub_python_build_lib
|
||||
stub_python_build
|
||||
stub_python_build
|
||||
|
||||
run pyenv-install 3.4.1 3.4.2
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
python-build 3.4.1 ${BATS_TEST_TMPDIR}/pyenv/versions/3.4.1
|
||||
python-build 3.4.2 ${BATS_TEST_TMPDIR}/pyenv/versions/3.4.2
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
unstub pyenv-latest
|
||||
}
|
||||
|
||||
@test "install multiple versions, some fail" {
|
||||
stub_python_build_lib
|
||||
stub_python_build 'echo "fail: python-build" "$@"; false'
|
||||
|
||||
run pyenv-install 3.4.1 3.4.2
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
fail: python-build 3.4.1 ${BATS_TEST_TMPDIR}/pyenv/versions/3.4.1
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
|
||||
@test "install resolves a prefix" {
|
||||
stub_python_build_lib
|
||||
for i in {1..3}; do stub_python_build_no_latest; done
|
||||
stub pyenv-latest \
|
||||
'-r -k 3.4 : echo 3.4.2' \
|
||||
'-r -k 3.5.1 : false' \
|
||||
'-r -k 3.5 : echo 3.5.2'
|
||||
|
||||
run pyenv-install 3.4 3.5.1 3.5
|
||||
assert_success <<OUT
|
||||
python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2
|
||||
python-build 3.5.1 ${PYENV_ROOT}/versions/3.5.1
|
||||
python-build 3.5.2 ${PYENV_ROOT}/versions/3.5.2
|
||||
OUT
|
||||
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
|
||||
@test "install resolves :latest" {
|
||||
stub_python_build_lib
|
||||
for i in {1..2}; do stub_python_build '--definitions : echo -e 3.4.2\\n3.5.1\\n3.5.2'; done
|
||||
for i in {1..2}; do stub_python_build; done
|
||||
|
||||
pyenv-hooks install; unstub pyenv-hooks
|
||||
PYENV_INSTALL_ROOT="$BATS_TEST_DIRNAME/../../.."
|
||||
export PYENV_HOOK_PATH="$PYENV_INSTALL_ROOT/pyenv.d"
|
||||
[[ -d "$PYENV_INSTALL_ROOT/libexec" ]] || skip "python-build is installed separately from pyenv"
|
||||
export PATH="$PATH:$PYENV_INSTALL_ROOT/libexec"
|
||||
|
||||
run pyenv-install 3.4:latest 3:latest
|
||||
assert_success <<!
|
||||
python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2
|
||||
python-build 3.5.2 ${PYENV_ROOT}/versions/3.5.2
|
||||
!
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "install installs local versions by default" {
|
||||
stub_python_build_lib
|
||||
stub_python_build
|
||||
stub_python_build
|
||||
stub pyenv-local 'echo 3.4.2; echo 3.4.1'
|
||||
|
||||
run pyenv-install
|
||||
assert_success <<OUT
|
||||
python-build 3.4.2
|
||||
python-build 3.4.1
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
unstub pyenv-local
|
||||
}
|
||||
|
||||
@test "list available versions" {
|
||||
stub_python_build_lib
|
||||
stub_python_build "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'"
|
||||
|
||||
run pyenv-install --list
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
Available versions:
|
||||
2.6.9
|
||||
2.7.9-rc1
|
||||
2.7.9-rc2
|
||||
3.4.2
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "upgrade instructions given for a nonexistent version" {
|
||||
stub brew false
|
||||
stub_python_build_lib
|
||||
stub_python_build 'echo ERROR >&2 && exit 2'
|
||||
stub_python_build "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'"
|
||||
|
||||
mkdir "$BATS_TEST_TMPDIR/.git"
|
||||
#Faking the Pyenv installation prefix may break things.
|
||||
# May have to move some dependent stuff into the fake root for the code to find it
|
||||
# or introduce an overriding test variable in the code specifically for the hint.
|
||||
_PYENV_INSTALL_PREFIX="$BATS_TEST_TMPDIR" run pyenv-install 2.7.9
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
ERROR
|
||||
|
||||
The following versions contain \`2.7.9' in the name:
|
||||
2.7.9-rc1
|
||||
2.7.9-rc2
|
||||
|
||||
See all available versions with \`pyenv install --list'.
|
||||
|
||||
If the version you need is missing, try upgrading pyenv:
|
||||
|
||||
cd ${BATS_TEST_TMPDIR} && git pull && cd -
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "homebrew upgrade instructions given when pyenv is homebrew-installed" {
|
||||
stub brew "--prefix : echo '${_PYENV_INSTALL_PREFIX}'"
|
||||
stub_python_build_lib
|
||||
stub_python_build 'echo ERROR >&2 && exit 2' \
|
||||
"--definitions : true"
|
||||
|
||||
_PYENV_INSTALL_PREFIX="$BATS_TEST_TMPDIR" run pyenv-install 1.9.3
|
||||
assert_failure
|
||||
assert_output <<OUT
|
||||
ERROR
|
||||
|
||||
See all available versions with \`pyenv install --list'.
|
||||
|
||||
If the version you need is missing, try upgrading pyenv:
|
||||
|
||||
brew update && brew upgrade pyenv
|
||||
OUT
|
||||
|
||||
unstub brew
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "no build definitions from plugins" {
|
||||
assert [ ! -e "${PYENV_ROOT}/plugins" ]
|
||||
stub_python_build_lib
|
||||
stub_python_build 'echo $PYTHON_BUILD_DEFINITIONS'
|
||||
|
||||
run pyenv-install 3.4.2
|
||||
assert_success ""
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "some build definitions from plugins" {
|
||||
mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
|
||||
mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
|
||||
stub_python_build_lib
|
||||
stub_python_build "echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
|
||||
|
||||
run pyenv-install 3.4.2
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
|
||||
${PYENV_ROOT}/plugins/bar/share/python-build
|
||||
${PYENV_ROOT}/plugins/foo/share/python-build
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "list build definitions from plugins" {
|
||||
mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
|
||||
mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
|
||||
stub_python_build_lib
|
||||
stub_python_build "--definitions : echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
|
||||
|
||||
run pyenv-install --list
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
Available versions:
|
||||
|
||||
${PYENV_ROOT}/plugins/bar/share/python-build
|
||||
${PYENV_ROOT}/plugins/foo/share/python-build
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "completion results include build definitions from plugins" {
|
||||
mkdir -p "${PYENV_ROOT}/plugins/foo/share/python-build"
|
||||
mkdir -p "${PYENV_ROOT}/plugins/bar/share/python-build"
|
||||
stub_python_build "--definitions : echo \$PYTHON_BUILD_DEFINITIONS | tr ':' $'\\n'"
|
||||
|
||||
run pyenv-install --complete
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
--list
|
||||
--force
|
||||
--skip-existing
|
||||
--keep
|
||||
--patch
|
||||
--verbose
|
||||
--version
|
||||
--debug
|
||||
|
||||
${PYENV_ROOT}/plugins/bar/share/python-build
|
||||
${PYENV_ROOT}/plugins/foo/share/python-build
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "not enough arguments for pyenv-install if no local version" {
|
||||
stub_python_build_lib
|
||||
stub pyenv-help 'install : true'
|
||||
|
||||
run pyenv-install
|
||||
assert_failure
|
||||
unstub pyenv-help
|
||||
assert_output ""
|
||||
}
|
||||
|
||||
@test "show help for pyenv-install" {
|
||||
stub pyenv-help 'install : true'
|
||||
|
||||
run pyenv-install -h
|
||||
assert_success
|
||||
unstub pyenv-help
|
||||
}
|
||||
|
||||
@test "pyenv-install has usage help preface" {
|
||||
run head "$(command -v pyenv-install)"
|
||||
assert_output_contains 'Usage: pyenv install'
|
||||
}
|
||||
|
||||
@test "not enough arguments pyenv-uninstall" {
|
||||
stub pyenv-help 'uninstall : true'
|
||||
|
||||
run pyenv-uninstall
|
||||
assert_failure
|
||||
unstub pyenv-help
|
||||
}
|
||||
|
||||
@test "multiple arguments for pyenv-uninstall" {
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.4.1"
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.4.2"
|
||||
run pyenv-uninstall -f 3.4.1 3.4.2
|
||||
|
||||
assert_success
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.4.1" ]
|
||||
refute [ -d "${PYENV_ROOT}/versions/3.4.2" ]
|
||||
}
|
||||
|
||||
@test "invalid arguments for pyenv-uninstall" {
|
||||
bats_require_minimum_version 1.5.0
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.10.3"
|
||||
mkdir -p "${PYENV_ROOT}/versions/3.10.4"
|
||||
|
||||
run -127 pyenv-uninstall -f 3.10.3 --invalid-option 3.10.4
|
||||
assert_failure
|
||||
|
||||
assert [ -d "${PYENV_ROOT}/versions/3.10.3" ]
|
||||
assert [ -d "${PYENV_ROOT}/versions/3.10.4" ]
|
||||
|
||||
rmdir "${PYENV_ROOT}/versions/3.10.3"
|
||||
rmdir "${PYENV_ROOT}/versions/3.10.4"
|
||||
}
|
||||
|
||||
@test "show help for pyenv-uninstall" {
|
||||
stub pyenv-help 'uninstall : true'
|
||||
|
||||
run pyenv-uninstall -h
|
||||
assert_success
|
||||
unstub pyenv-help
|
||||
}
|
||||
|
||||
@test "pyenv-uninstall has usage help preface" {
|
||||
run head "$(command -v pyenv-uninstall)"
|
||||
assert_output_contains 'Usage: pyenv uninstall'
|
||||
}
|
||||
469
plugins/python-build/test/pyenv_ext.bats
Normal file
469
plugins/python-build/test/pyenv_ext.bats
Normal file
@@ -0,0 +1,469 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
_setup() {
|
||||
export PYTHON_BUILD_CACHE_PATH="$BATS_TEST_TMPDIR/cache"
|
||||
export MAKE=make
|
||||
export MAKE_OPTS="-j 2"
|
||||
export CC=cc
|
||||
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
||||
export TMP_FIXTURES="$BATS_TEST_TMPDIR/fixtures"
|
||||
mkdir -p "$INSTALL_ROOT"
|
||||
stub md5 false
|
||||
stub curl false
|
||||
}
|
||||
|
||||
executable() {
|
||||
local file="$1"
|
||||
mkdir -p "${file%/*}"
|
||||
cat > "$file"
|
||||
chmod +x "$file"
|
||||
}
|
||||
|
||||
cached_tarball() {
|
||||
mkdir -p "$PYTHON_BUILD_CACHE_PATH"
|
||||
pushd "$PYTHON_BUILD_CACHE_PATH" >/dev/null
|
||||
tarball "$@"
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
tarball() {
|
||||
local name="$1"
|
||||
local path="$PWD/$name"
|
||||
local configure="$path/configure"
|
||||
shift 1
|
||||
|
||||
executable "$configure" <<OUT
|
||||
#!$BASH
|
||||
echo "$name: CPPFLAGS=\\"\$CPPFLAGS\\" LDFLAGS=\\"\$LDFLAGS\\"" >> build.log
|
||||
echo "$name: \$@" \${PYTHONOPT:+PYTHONOPT=\$PYTHONOPT} >> build.log
|
||||
OUT
|
||||
|
||||
for file; do
|
||||
mkdir -p "$(dirname "${path}/${file}")"
|
||||
touch "${path}/${file}"
|
||||
done
|
||||
|
||||
tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
|
||||
}
|
||||
|
||||
stub_make_install() {
|
||||
stub "$MAKE" \
|
||||
" : echo \"$MAKE \$@\" >> build.log" \
|
||||
"install : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||
}
|
||||
|
||||
assert_build_log() {
|
||||
run cat "$INSTALL_ROOT/build.log"
|
||||
assert_output
|
||||
}
|
||||
|
||||
install_patch() {
|
||||
local name="$1"
|
||||
local patch="$2"
|
||||
[ -n "$patch" ] || patch="python.patch"
|
||||
|
||||
mkdir -p "${TMP_FIXTURES}/${name%/*}/patches/${name##*/}/${patch%/*}"
|
||||
cat > "${TMP_FIXTURES}/${name%/*}/patches/${name##*/}/${patch}"
|
||||
}
|
||||
|
||||
install_tmp_fixture() {
|
||||
local args
|
||||
|
||||
while [ "${1#-}" != "$1" ]; do
|
||||
args="$args $1"
|
||||
shift 1
|
||||
done
|
||||
|
||||
local name="$1"
|
||||
local destination="$2"
|
||||
[ -n "$destination" ] || destination="$INSTALL_ROOT"
|
||||
|
||||
# Copy fixture to temporary path
|
||||
mkdir -p "${TMP_FIXTURES}/${name%/*}"
|
||||
cp "${FIXTURE_ROOT}/${name}" "${TMP_FIXTURES}/${name}"
|
||||
|
||||
run python-build $args "$TMP_FIXTURES/$name" "$destination"
|
||||
}
|
||||
|
||||
resolve_link() {
|
||||
$(type -P greadlink readlink | head -n1) "$1"
|
||||
}
|
||||
|
||||
run_inline_definition_with_name() {
|
||||
local definition_name="build-definition"
|
||||
case "$1" in
|
||||
"--name="* )
|
||||
local definition_name="${1#--name=}"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
local definition="${BATS_TEST_TMPDIR}/${definition_name}"
|
||||
cat > "$definition"
|
||||
run python-build "$definition" "${1:-$INSTALL_ROOT}"
|
||||
}
|
||||
|
||||
@test "apply built-in python patch before building" {
|
||||
cached_tarball "Python-3.6.2"
|
||||
|
||||
stub brew false
|
||||
stub_make_install
|
||||
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
|
||||
|
||||
echo | install_patch definitions/vanilla-python "Python-3.6.2/empty.patch"
|
||||
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Linux'
|
||||
stub uname '-s : echo Linux'
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
patch -p0 --force -i $BATS_TEST_TMPDIR/python-patch.XXX
|
||||
Python-3.6.2: CPPFLAGS="-I${BATS_TEST_TMPDIR}/install/include" LDFLAGS="-L${BATS_TEST_TMPDIR}/install/lib -Wl,-rpath,${BATS_TEST_TMPDIR}/install/lib"
|
||||
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
||||
unstub make
|
||||
unstub patch
|
||||
}
|
||||
|
||||
@test "apply built-in python patches should be sorted by its name" {
|
||||
cached_tarball "Python-3.6.2"
|
||||
|
||||
for i in {1..2}; do stub brew '* : false'; done
|
||||
stub_make_install
|
||||
stub patch ' : for arg; do [[ "$arg" == "-"* ]] || sed -e "s/^/patch: /" "$arg"; done >> build.log'
|
||||
|
||||
echo "foo" | install_patch definitions/vanilla-python "Python-3.6.2/foo.patch"
|
||||
echo "bar" | install_patch definitions/vanilla-python "Python-3.6.2/bar.patch"
|
||||
echo "baz" | install_patch definitions/vanilla-python "Python-3.6.2/baz.patch"
|
||||
|
||||
stub uname '-s : echo Linux'
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
patch: bar
|
||||
patch: baz
|
||||
patch: foo
|
||||
Python-3.6.2: CPPFLAGS="-I${BATS_TEST_TMPDIR}/install/include" LDFLAGS="-L${BATS_TEST_TMPDIR}/install/lib -Wl,-rpath,${BATS_TEST_TMPDIR}/install/lib"
|
||||
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
||||
unstub make
|
||||
unstub patch
|
||||
}
|
||||
|
||||
@test "allow custom make install target" {
|
||||
cached_tarball "Python-3.6.2"
|
||||
|
||||
stub brew false
|
||||
stub "$MAKE" \
|
||||
" : echo \"$MAKE \$@\" >> build.log" \
|
||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
|
||||
PYTHON_MAKE_INSTALL_TARGET="altinstall" TMPDIR="$BATS_TEST_TMPDIR" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
Python-3.6.2: CPPFLAGS="-I${BATS_TEST_TMPDIR}/install/include" LDFLAGS="-L${BATS_TEST_TMPDIR}/install/lib -Wl,-rpath,${BATS_TEST_TMPDIR}/install/lib"
|
||||
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib
|
||||
make -j 2
|
||||
make altinstall
|
||||
OUT
|
||||
|
||||
unstub make
|
||||
}
|
||||
|
||||
@test "ensurepip without altinstall" {
|
||||
mkdir -p "${INSTALL_ROOT}/bin"
|
||||
cat <<OUT > "${INSTALL_ROOT}/bin/python"
|
||||
#!$BASH
|
||||
echo "python \$@" >> "${INSTALL_ROOT}/build.log"
|
||||
OUT
|
||||
chmod +x "${INSTALL_ROOT}/bin/python"
|
||||
|
||||
PYTHON_MAKE_INSTALL_TARGET="" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
build_package_ensurepip
|
||||
OUT
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
python -I -m ensurepip
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "ensurepip with altinstall" {
|
||||
mkdir -p "${INSTALL_ROOT}/bin"
|
||||
cat <<OUT > "${INSTALL_ROOT}/bin/python"
|
||||
#!$BASH
|
||||
echo "python \$@" >> "${INSTALL_ROOT}/build.log"
|
||||
OUT
|
||||
chmod +x "${INSTALL_ROOT}/bin/python"
|
||||
|
||||
PYTHON_MAKE_INSTALL_TARGET="altinstall" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
build_package_ensurepip
|
||||
OUT
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
python -I -m ensurepip --altinstall
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "python3-config" {
|
||||
mkdir -p "${INSTALL_ROOT}/bin"
|
||||
touch "${INSTALL_ROOT}/bin/python3"
|
||||
chmod +x "${INSTALL_ROOT}/bin/python3"
|
||||
touch "${INSTALL_ROOT}/bin/python3.4"
|
||||
chmod +x "${INSTALL_ROOT}/bin/python3.4"
|
||||
touch "${INSTALL_ROOT}/bin/python3-config"
|
||||
chmod +x "${INSTALL_ROOT}/bin/python3-config"
|
||||
touch "${INSTALL_ROOT}/bin/python3.4-config"
|
||||
chmod +x "${INSTALL_ROOT}/bin/python3.4-config"
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
verify_python python3.4
|
||||
OUT
|
||||
assert_success
|
||||
|
||||
[ -L "${INSTALL_ROOT}/bin/python" ]
|
||||
[ -L "${INSTALL_ROOT}/bin/python-config" ]
|
||||
[[ "$(resolve_link "${INSTALL_ROOT}/bin/python")" == "python3.4" ]]
|
||||
[[ "$(resolve_link "${INSTALL_ROOT}/bin/python-config")" == "python3.4-config" ]]
|
||||
}
|
||||
|
||||
@test "enable framework" {
|
||||
framework_path="${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin"
|
||||
mkdir -p "$framework_path"
|
||||
for executable in python3{,.4}{,-config}; do
|
||||
touch "$framework_path/$executable"
|
||||
chmod +x "$framework_path/$executable"
|
||||
done
|
||||
unset framework_path executable
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-framework" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
echo "PYTHON_CONFIGURE_OPTS=(\${PYTHON_CONFIGURE_OPTS})"
|
||||
echo "CONFIGURE_OPTS=(\${CONFIGURE_OPTS})"
|
||||
verify_python python3.4
|
||||
OUT
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
PYTHON_CONFIGURE_OPTS_ARRAY=(--libdir=${BATS_TEST_TMPDIR}/install/lib --enable-framework=${BATS_TEST_TMPDIR}/install/Library/Frameworks)
|
||||
PYTHON_CONFIGURE_OPTS=()
|
||||
CONFIGURE_OPTS=()
|
||||
EOS
|
||||
|
||||
[ -L "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python" ]
|
||||
[ -L "${INSTALL_ROOT}/Library/Frameworks/Python.framework/Versions/Current/bin/python-config" ]
|
||||
}
|
||||
|
||||
@test "enable universalsdk" {
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
stub arch "echo x86_64"
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
echo "PYTHON_CONFIGURE_OPTS=(\${PYTHON_CONFIGURE_OPTS})"
|
||||
echo "CONFIGURE_OPTS=(\${CONFIGURE_OPTS})"
|
||||
OUT
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
PYTHON_CONFIGURE_OPTS_ARRAY=(--enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib --enable-universalsdk=/)
|
||||
PYTHON_CONFIGURE_OPTS=()
|
||||
CONFIGURE_OPTS=()
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "enable universalsdk on Apple Silicon" {
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 11.7'
|
||||
stub arch "echo arm64"
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-universalsdk" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
echo "PYTHON_CONFIGURE_OPTS=(\${PYTHON_CONFIGURE_OPTS})"
|
||||
echo "CONFIGURE_OPTS=(\${CONFIGURE_OPTS})"
|
||||
OUT
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
PYTHON_CONFIGURE_OPTS_ARRAY=(--enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib --enable-universalsdk=/ --with-universal-archs=universal2)
|
||||
PYTHON_CONFIGURE_OPTS=()
|
||||
CONFIGURE_OPTS=()
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "enable universalsdk with explicit archs argument" {
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 11.7'
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-universalsdk --with-universal-archs=foo" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "PYTHON_CONFIGURE_OPTS_ARRAY=(\${PYTHON_CONFIGURE_OPTS_ARRAY[@]})"
|
||||
OUT
|
||||
assert_success
|
||||
assert_output <<EOS
|
||||
PYTHON_CONFIGURE_OPTS_ARRAY=(--enable-shared --libdir=${BATS_TEST_TMPDIR}/install/lib --enable-universalsdk=/)
|
||||
EOS
|
||||
}
|
||||
|
||||
@test "enable custom unicode configuration" {
|
||||
cached_tarball "Python-3.6.2"
|
||||
|
||||
for i in {1..4}; do stub brew false; done
|
||||
stub uname '-s : echo Linux'
|
||||
stub "$MAKE" \
|
||||
" : echo \"$MAKE \$@\" >> build.log" \
|
||||
" : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
|
||||
|
||||
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" TMPDIR="$BATS_TEST_TMPDIR" install_tmp_fixture definitions/vanilla-python < /dev/null
|
||||
assert_success
|
||||
|
||||
assert_build_log <<OUT
|
||||
Python-3.6.2: CPPFLAGS="-I${BATS_TEST_TMPDIR}/install/include" LDFLAGS="-L${BATS_TEST_TMPDIR}/install/lib -Wl,-rpath,${BATS_TEST_TMPDIR}/install/lib"
|
||||
Python-3.6.2: --prefix=$INSTALL_ROOT --enable-shared --libdir=$INSTALL_ROOT/lib --enable-unicode=ucs2
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
|
||||
unstub make
|
||||
unstub uname
|
||||
}
|
||||
|
||||
@test "default MACOSX_DEPLOYMENT_TARGET" {
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.10'
|
||||
|
||||
TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "\${MACOSX_DEPLOYMENT_TARGET}"
|
||||
OUT
|
||||
assert_success
|
||||
assert_output "10.10"
|
||||
}
|
||||
|
||||
@test "use custom MACOSX_DEPLOYMENT_TARGET if defined" {
|
||||
# yyuu/pyenv#257
|
||||
stub uname '-s : echo Darwin'
|
||||
|
||||
stub uname '-s : echo Darwin'
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET="10.4" TMPDIR="$BATS_TEST_TMPDIR" run_inline_definition <<OUT
|
||||
echo "\${MACOSX_DEPLOYMENT_TARGET}"
|
||||
OUT
|
||||
assert_success
|
||||
assert_output "10.4"
|
||||
}
|
||||
|
||||
@test "use the default EZ_SETUP_URL by default" {
|
||||
run_inline_definition <<OUT
|
||||
echo "\${EZ_SETUP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/ez_setup.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the default GET_PIP_URL by default" {
|
||||
run_inline_definition <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 2.6 versions" {
|
||||
run_inline_definition_with_name --name=2.6 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/2.6/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 2.7 versions" {
|
||||
run_inline_definition_with_name --name=2.7 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 3.2 versions" {
|
||||
run_inline_definition_with_name --name=3.2 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.2/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 3.3 versions" {
|
||||
run_inline_definition_with_name --name=3.3 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.3/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 3.4 versions" {
|
||||
run_inline_definition_with_name --name=3.4 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.4/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 3.5 versions" {
|
||||
run_inline_definition_with_name --name=3.5 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.5/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for 3.6 versions" {
|
||||
run_inline_definition_with_name --name=3.6 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.6/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for pypy2.7 versions" {
|
||||
run_inline_definition_with_name --name=pypy2.7-7.3.12 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/2.7/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for pypy3.5 versions" {
|
||||
run_inline_definition_with_name --name=pypy3.5-7.0.0 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.5/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "use the custom GET_PIP_URL for pypy3.6 versions" {
|
||||
run_inline_definition_with_name --name=pypy3.6-7.3.3 <<OUT
|
||||
echo "\${GET_PIP_URL}"
|
||||
OUT
|
||||
assert_output "https://bootstrap.pypa.io/pip/3.6/get-pip.py"
|
||||
assert_success
|
||||
}
|
||||
119
plugins/python-build/test/stubs/stub
Executable file
119
plugins/python-build/test/stubs/stub
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
status=0
|
||||
program="${0##*/}"
|
||||
PROGRAM="$(echo "$program" | tr a-z- A-Z_)"
|
||||
|
||||
_STUB_PLAN="${PROGRAM}_STUB_PLAN"
|
||||
_STUB_RUN="${PROGRAM}_STUB_RUN"
|
||||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||
_STUB_END="${PROGRAM}_STUB_END"
|
||||
_STUB_LOG="${PROGRAM}_STUB_LOG"
|
||||
|
||||
[ -n "${!_STUB_LOG}" ] || eval "${_STUB_LOG}"="${BATS_TEST_TMPDIR}/${program}-stub-log"
|
||||
if test -z "${!_STUB_END}"; then echo "$program" "$@" >>"${!_STUB_LOG}"; fi
|
||||
|
||||
[ -e "${!_STUB_PLAN}" ] || exit 1
|
||||
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${BATS_TEST_TMPDIR}/${program}-stub-run"
|
||||
|
||||
|
||||
# Initialize or load the stub run information.
|
||||
eval "${_STUB_INDEX}"=1
|
||||
eval "${_STUB_RESULT}"=0
|
||||
if test -e "${!_STUB_RUN}"; then source "${!_STUB_RUN}"; fi
|
||||
|
||||
|
||||
# Loop over each line in the plan.
|
||||
index=0
|
||||
while IFS= read -r line; do
|
||||
index=$(($index + 1))
|
||||
|
||||
if [ -z "${!_STUB_END}" ] && [ $index -eq "${!_STUB_INDEX}" ]; then
|
||||
# We found the plan line we're interested in.
|
||||
# Start off by assuming success.
|
||||
result=0
|
||||
|
||||
# Split the line into an array of arguments to
|
||||
# match and a command to run to produce output.
|
||||
command=" $line"
|
||||
if [ "$command" != "${command/ : }" ]; then
|
||||
patterns="${command%% : *}"
|
||||
command="${command#* : }"
|
||||
fi
|
||||
|
||||
# Naively split patterns by whitespace for now.
|
||||
# In the future, use a sed script to split while
|
||||
# respecting quoting.
|
||||
set -f
|
||||
patterns=($patterns)
|
||||
set +f
|
||||
arguments=("$@")
|
||||
|
||||
# Match the expected argument patterns to actual
|
||||
# arguments.
|
||||
for (( i=0; i<${#patterns[@]}; i++ )); do
|
||||
pattern="${patterns[$i]}"
|
||||
argument="${arguments[$i]}"
|
||||
|
||||
case "$argument" in
|
||||
$pattern ) ;;
|
||||
* ) result=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# If the arguments matched, evaluate the command
|
||||
# in a subshell. Otherwise, log the failure.
|
||||
if [ $result -eq 0 ] ; then
|
||||
set +e
|
||||
( eval "$command" )
|
||||
status="$?"
|
||||
set -e
|
||||
else
|
||||
eval "${_STUB_RESULT}"=1
|
||||
fi
|
||||
fi
|
||||
done < "${!_STUB_PLAN}"
|
||||
|
||||
|
||||
if [ -n "${!_STUB_END}" ]; then
|
||||
# If the number of lines in the plan is larger than
|
||||
# the requested index, we failed.
|
||||
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
||||
eval "${_STUB_RESULT}"=1
|
||||
fi
|
||||
if [ "${!_STUB_RESULT}" -ne 0 ]; then
|
||||
{
|
||||
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||
echo "plan:"
|
||||
cat "${!_STUB_PLAN}" || true
|
||||
echo "run:"
|
||||
cat "${!_STUB_RUN}" || true
|
||||
echo "log:"
|
||||
cat "${!_STUB_LOG}" || true
|
||||
} >&2
|
||||
fi
|
||||
|
||||
# Clean up the run file.
|
||||
rm -f "${!_STUB_RUN}"
|
||||
rm -f "${!_STUB_LOG}"
|
||||
|
||||
# Return the result.
|
||||
exit "${!_STUB_RESULT}"
|
||||
|
||||
else
|
||||
# If the requested index is larger than the number
|
||||
# of lines in the plan file, we failed.
|
||||
if [ "${!_STUB_INDEX}" -gt $index ]; then
|
||||
eval "${_STUB_RESULT}"=1
|
||||
fi
|
||||
|
||||
# Write out the run information.
|
||||
{ echo "${_STUB_INDEX}=$((${!_STUB_INDEX} + 1))"
|
||||
echo "${_STUB_RESULT}=${!_STUB_RESULT}"
|
||||
} > "${!_STUB_RUN}"
|
||||
|
||||
exit "$status"
|
||||
|
||||
fi
|
||||
164
plugins/python-build/test/test_helper.bash
Normal file
164
plugins/python-build/test/test_helper.bash
Normal file
@@ -0,0 +1,164 @@
|
||||
setup() {
|
||||
export PYTHON_BUILD_CURL_OPTS=
|
||||
export PYTHON_BUILD_HTTP_CLIENT="curl"
|
||||
|
||||
export FIXTURE_ROOT="${BATS_TEST_DIRNAME}/fixtures"
|
||||
export INSTALL_ROOT="${BATS_TEST_TMPDIR}/install"
|
||||
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
||||
PATH="${BATS_TEST_DIRNAME}/../bin:$PATH"
|
||||
PATH="${BATS_TEST_TMPDIR}/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
# If test specific setup exist, run it
|
||||
if [[ $(type -t _setup) == function ]];then
|
||||
_setup
|
||||
fi
|
||||
}
|
||||
|
||||
stub() {
|
||||
local program="$1"
|
||||
local prefix="$(echo "$program" | tr a-z- A-Z_)"
|
||||
shift
|
||||
|
||||
export "${prefix}_STUB_PLAN"="${BATS_TEST_TMPDIR}/${program}-stub-plan"
|
||||
export "${prefix}_STUB_RUN"="${BATS_TEST_TMPDIR}/${program}-stub-run"
|
||||
export "${prefix}_STUB_LOG"="${BATS_TEST_TMPDIR}/${program}-stub-log"
|
||||
export "${prefix}_STUB_END"=
|
||||
|
||||
mkdir -p "${BATS_TEST_TMPDIR}/bin"
|
||||
cp "${BATS_TEST_DIRNAME}/stubs/stub" "${BATS_TEST_TMPDIR}/bin/${program}"
|
||||
|
||||
touch "${BATS_TEST_TMPDIR}/${program}-stub-plan"
|
||||
for arg in "$@"; do printf "%s\n" "$arg" >> "${BATS_TEST_TMPDIR}/${program}-stub-plan"; done
|
||||
}
|
||||
|
||||
unstub() {
|
||||
local program="$1"
|
||||
local prefix="$(echo "$program" | tr a-z- A-Z_)"
|
||||
local path="${BATS_TEST_TMPDIR}/bin/${program}"
|
||||
|
||||
export "${prefix}_STUB_END"=1
|
||||
|
||||
local STATUS=0
|
||||
"$path" || STATUS="$?"
|
||||
|
||||
rm -f "$path"
|
||||
rm -f "${BATS_TEST_TMPDIR}/${program}-stub-plan" "${BATS_TEST_TMPDIR}/${program}-stub-run"
|
||||
return "$STATUS"
|
||||
}
|
||||
|
||||
run_inline_definition() {
|
||||
local definition="${BATS_TEST_TMPDIR}/build-definition"
|
||||
cat > "$definition"
|
||||
run python-build "$definition" "${1:-$INSTALL_ROOT}"
|
||||
}
|
||||
|
||||
install_fixture() {
|
||||
local args
|
||||
|
||||
while [ "${1#-}" != "$1" ]; do
|
||||
args="$args $1"
|
||||
shift 1
|
||||
done
|
||||
|
||||
local name="$1"
|
||||
local destination="$2"
|
||||
[ -n "$destination" ] || destination="$INSTALL_ROOT"
|
||||
|
||||
run python-build $args "$FIXTURE_ROOT/$name" "$destination"
|
||||
}
|
||||
|
||||
assert() {
|
||||
if ! "$@"; then
|
||||
flunk "failed: $@"
|
||||
fi
|
||||
}
|
||||
|
||||
refute() {
|
||||
if "$@"; then
|
||||
flunk "expected to fail: $@"
|
||||
fi
|
||||
}
|
||||
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
else echo "$@"
|
||||
fi
|
||||
} | sed "s:${BATS_TEST_TMPDIR}:\${BATS_TEST_TMPDIR}:g" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
if [ "$status" -ne 0 ]; then
|
||||
{ echo "command failed with exit status $status"
|
||||
echo "output: $output"
|
||||
} | flunk
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output "$1"
|
||||
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() {
|
||||
local expected="$1"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "assert_output_contains needs an argument" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "$output" | $(type -P ggrep grep | head -n1) -F "$expected" >/dev/null || {
|
||||
{ echo "expected output to contain $expected"
|
||||
echo "actual: $output"
|
||||
} | flunk
|
||||
}
|
||||
}
|
||||
|
||||
# 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; 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"
|
||||
}
|
||||
|
||||
38
plugins/python-build/test/version.bats
Normal file
38
plugins/python-build/test/version.bats
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
python_build_bin="${BATS_TEST_DIRNAME}/../bin/python-build"
|
||||
static_version="$(grep VERSION "$python_build_bin" | head -n1 | cut -d'"' -f 2)"
|
||||
|
||||
@test "python-build static version" {
|
||||
stub git 'echo "ASPLODE" >&2; exit 1'
|
||||
run python-build --version
|
||||
assert_success "python-build ${static_version}"
|
||||
unstub git
|
||||
}
|
||||
|
||||
@test "python-build git version" {
|
||||
stub git \
|
||||
'remote -v : echo origin https://github.com/pyenv/pyenv.git' \
|
||||
"describe --tags HEAD : echo v1984-12-gSHA"
|
||||
run python-build --version
|
||||
assert_success "python-build 1984-12-gSHA"
|
||||
unstub git
|
||||
}
|
||||
|
||||
@test "git describe fails" {
|
||||
stub git \
|
||||
'remote -v : echo origin https://github.com/pyenv/pyenv.git' \
|
||||
"describe --tags HEAD : echo ASPLODE >&2; exit 1"
|
||||
run python-build --version
|
||||
assert_success "python-build ${static_version}"
|
||||
unstub git
|
||||
}
|
||||
|
||||
@test "git remote doesn't match" {
|
||||
stub git \
|
||||
'remote -v : echo origin https://github.com/Homebrew/homebrew.git'
|
||||
run python-build --version
|
||||
assert_success "python-build ${static_version}"
|
||||
}
|
||||
Reference in New Issue
Block a user