pyenv/plugins/python-build/test/compiler.bats
Alex Hedges 928f69cf9a
Install ncurses from Homebrew, if available (#2813)
XCode Command Line Tools 15.0 was recently released, and it contains a
broken version of ncurses 6.0. Some uses of Python's `curses` module
will segfault when compiled with it. The solution is to switch to using
the version of ncurses from Homebrew, which is currently 6.4. Support
for ncurses 6 was added to Python 3.7 and was backported to 3.6 and 2.7,
so this change should not break any recently supported Python versions.

Tested with Python 3.12, 3.11, and 2.7, and all tests in
the `test.test_curses` module pass without issue.

See https://github.com/python/cpython/issues/109617 and
https://github.com/python/cpython/issues/69906 for more information.
2023-10-06 06:59:29 +03:00

125 lines
2.5 KiB
Bash

#!/usr/bin/env bats
load test_helper
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" {
for i in {1..3}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 10.9.5'; done
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
unstub uname
unstub sw_vers
unstub gcc
}
@test "require_gcc on OS X 10.10" {
for i in {1..3}; do stub uname '-s : echo Darwin'; done
for i in {1..2}; do stub sw_vers '-productVersion : echo 10.10'; done
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=${TMP}/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 "${TMP}/bin/gcc"
unstub gcc
}
@test "CC=clang by default on OS X 10.10" {
mkdir -p "$INSTALL_ROOT"
cd "$INSTALL_ROOT"
for i in {1..10}; do stub uname '-s : echo Darwin'; done
for i in {1..3}; do stub sw_vers '-productVersion : echo 10.10'; done
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=${TMP}/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 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:${TMP}/install/lib/micropython"' -Wno-floating-conversion
OUT
}