mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-09 12:03:49 -05:00
Import changes from ruby-build v20141028
This commit is contained in:
@@ -264,6 +264,31 @@ make install
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "number of CPU cores is detected on FreeBSD" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
stub uname '-s : echo FreeBSD'
|
||||
stub sysctl '-n hw.ncpu : echo 1'
|
||||
stub_make_install
|
||||
|
||||
export -n MAKE_OPTS
|
||||
run_inline_definition <<DEF
|
||||
install_package "Python-3.2.1" "http://python.org/ftp/python/3.2.1/Python-3.2.1.tar.gz"
|
||||
DEF
|
||||
assert_success
|
||||
|
||||
unstub uname
|
||||
unstub sysctl
|
||||
unstub make
|
||||
|
||||
assert_build_log <<OUT
|
||||
Python-3.2.1: CPPFLAGS="-I${TMP}/install/include " LDFLAGS="-L${TMP}/install/lib "
|
||||
Python-3.2.1: --prefix=$INSTALL_ROOT --libdir=$INSTALL_ROOT/lib
|
||||
make -j 1
|
||||
make install
|
||||
OUT
|
||||
}
|
||||
|
||||
@test "setting PYTHON_MAKE_INSTALL_OPTS to a multi-word string" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
@@ -315,11 +340,10 @@ OUT
|
||||
assert [ -x ./here/bin/package ]
|
||||
}
|
||||
|
||||
@test "make on FreeBSD defaults to gmake" {
|
||||
@test "make on FreeBSD 9 defaults to gmake" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
stub uname "-s : echo FreeBSD"
|
||||
stub uname "-s : echo FreeBSD"
|
||||
stub uname "-s : echo FreeBSD" "-r : echo 9.1"
|
||||
MAKE=gmake stub_make_install
|
||||
|
||||
MAKE= install_fixture definitions/vanilla-python
|
||||
@@ -329,6 +353,18 @@ OUT
|
||||
unstub uname
|
||||
}
|
||||
|
||||
@test "make on FreeBSD 10" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
stub uname "-s : echo FreeBSD" "-r : echo 10.0-RELEASE"
|
||||
stub_make_install
|
||||
|
||||
MAKE= install_fixture definitions/vanilla-python
|
||||
assert_success
|
||||
|
||||
unstub uname
|
||||
}
|
||||
|
||||
@test "can use PYTHON_CONFIGURE to apply a patch" {
|
||||
cached_tarball "Python-3.2.1"
|
||||
|
||||
|
||||
85
plugins/python-build/test/compiler.bats
Normal file
85
plugins/python-build/test/compiler.bats
Normal file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
export MAKE=make
|
||||
export MAKE_OPTS='-j 2'
|
||||
export -n CFLAGS
|
||||
export -n CC
|
||||
|
||||
@test "require_gcc on OS X 10.9" {
|
||||
stub uname '-s : echo Darwin'
|
||||
stub sw_vers '-productVersion : echo 10.9'
|
||||
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=${TMP}/bin/gcc
|
||||
MACOSX_DEPLOYMENT_TARGET=no
|
||||
OUT
|
||||
}
|
||||
|
||||
@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
|
||||
assert_success
|
||||
assert_output <<OUT
|
||||
CC=${TMP}/bin/gcc
|
||||
MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
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 "${TMP}/bin/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
|
||||
CC=clang
|
||||
CFLAGS=no
|
||||
make -j 2
|
||||
make install
|
||||
OUT
|
||||
}
|
||||
112
plugins/python-build/test/definitions.bats
Normal file
112
plugins/python-build/test/definitions.bats
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
NUM_DEFINITIONS="$(ls "$BATS_TEST_DIRNAME"/../share/python-build | 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="$TMP"
|
||||
assert [ ! -e "${PYTHON_BUILD_ROOT}/share/python-build" ]
|
||||
run python-build --definitions
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@test "custom PYTHON_BUILD_ROOT: single definition" {
|
||||
export PYTHON_BUILD_ROOT="$TMP"
|
||||
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="${TMP}/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="${TMP}/definitions:${TMP}/other"
|
||||
mkdir -p "${TMP}/definitions"
|
||||
touch "${TMP}/definitions/2.7.8-test"
|
||||
mkdir -p "${TMP}/other"
|
||||
touch "${TMP}/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="${TMP}/definitions:${TMP}/other"
|
||||
mkdir -p "${TMP}/definitions"
|
||||
echo true > "${TMP}/definitions/2.7.8-test"
|
||||
mkdir -p "${TMP}/other"
|
||||
echo false > "${TMP}/other/2.7.8-test"
|
||||
run bin/python-build "2.7.8-test" "${TMP}/install"
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@test "installing nonexistent definition" {
|
||||
run python-build "nonexistent" "${TMP}/install"
|
||||
assert [ "$status" -eq 2 ]
|
||||
assert_output "python-build: definition not found: nonexistent"
|
||||
}
|
||||
|
||||
@test "sorting Python versions" {
|
||||
export PYTHON_BUILD_ROOT="$TMP"
|
||||
mkdir -p "${PYTHON_BUILD_ROOT}/share/python-build"
|
||||
expected="2.7-dev
|
||||
2.7.8-preview1
|
||||
2.7.8-rc1
|
||||
2.7.8-p0
|
||||
2.7.8-p125
|
||||
3.4.0
|
||||
3.4.0-rc1
|
||||
3.4.1
|
||||
3.4.2
|
||||
3.4-dev
|
||||
2.2.0-dev
|
||||
jython-2.5.0
|
||||
jython-2.5.1
|
||||
jython-2.5.2
|
||||
jython-2.5.3
|
||||
jython-2.5.4-rc1
|
||||
jython-2.5-dev
|
||||
jython-2.7-beta1
|
||||
jython-2.7-beta2
|
||||
jython-2.7-beta3
|
||||
jython-dev"
|
||||
for ver in "$expected"; do
|
||||
touch "${PYTHON_BUILD_ROOT}/share/python-build/$ver"
|
||||
done
|
||||
run python-build --definitions
|
||||
assert_success "$expected"
|
||||
}
|
||||
|
||||
@test "removing duplicate Python versions" {
|
||||
export PYTHON_BUILD_ROOT="$TMP"
|
||||
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
|
||||
}
|
||||
@@ -22,7 +22,7 @@ load test_helper
|
||||
PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
run $BASH -c 'ls -l usr/share/python-build | tail -2 | cut -d" " -f1'
|
||||
run $BASH -c 'ls -l usr/share/python-build | tail -2 | cut -c1-10'
|
||||
assert_output <<OUT
|
||||
-rw-r--r--
|
||||
-rw-r--r--
|
||||
|
||||
148
plugins/python-build/test/pyenv.bats
Normal file
148
plugins/python-build/test/pyenv.bats
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
export PYENV_ROOT="${TMP}/pyenv"
|
||||
|
||||
setup() {
|
||||
stub pyenv-hooks 'install : true'
|
||||
stub pyenv-rehash 'true'
|
||||
}
|
||||
|
||||
stub_python_build() {
|
||||
stub python-build "--lib : $BATS_TEST_DIRNAME/../bin/python-build --lib" "$@"
|
||||
}
|
||||
|
||||
@test "install proper" {
|
||||
stub_python_build 'echo python-build "$@"'
|
||||
|
||||
run pyenv-install 3.4.2
|
||||
assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2"
|
||||
|
||||
unstub python-build
|
||||
unstub pyenv-hooks
|
||||
unstub pyenv-rehash
|
||||
}
|
||||
|
||||
@test "install pyenv local version by default" {
|
||||
stub_python_build 'echo python-build "$1"'
|
||||
stub pyenv-local 'echo 3.4.2'
|
||||
|
||||
run pyenv-install
|
||||
assert_success "python-build 3.4.2"
|
||||
|
||||
unstub python-build
|
||||
unstub pyenv-local
|
||||
}
|
||||
|
||||
@test "list available versions" {
|
||||
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 "nonexistent version" {
|
||||
stub brew false
|
||||
stub_python_build 'echo ERROR >&2 && exit 2' \
|
||||
"--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'"
|
||||
|
||||
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 python-build:
|
||||
|
||||
cd ${BATS_TEST_DIRNAME}/.. && git pull
|
||||
OUT
|
||||
|
||||
unstub python-build
|
||||
}
|
||||
|
||||
@test "Homebrew upgrade instructions" {
|
||||
stub brew "--prefix : echo '${BATS_TEST_DIRNAME%/*}'"
|
||||
stub_python_build 'echo ERROR >&2 && exit 2' \
|
||||
"--definitions : true"
|
||||
|
||||
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 python-build:
|
||||
|
||||
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 'echo $PYTHON_BUILD_DEFINITIONS'
|
||||
|
||||
run pyenv-install 3.4.2
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@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 "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
|
||||
}
|
||||
|
||||
@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 "--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
|
||||
}
|
||||
|
||||
@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
|
||||
|
||||
${PYENV_ROOT}/plugins/bar/share/python-build
|
||||
${PYENV_ROOT}/plugins/foo/share/python-build
|
||||
OUT
|
||||
}
|
||||
39
plugins/python-build/test/version.bats
Normal file
39
plugins/python-build/test/version.bats
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
bats_bin="${BATS_TEST_DIRNAME}/../bin/python-build"
|
||||
static_version="$(grep VERSION "$bats_bin" | head -1 | 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/yyuu/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/yyuu/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' \
|
||||
"describe --tags HEAD : echo v1984-12-gSHA"
|
||||
run python-build --version
|
||||
assert_success "python-build ${static_version}"
|
||||
}
|
||||
Reference in New Issue
Block a user