2014-10-29 06:35:29 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export MAKE=make
|
|
|
|
export MAKE_OPTS='-j 2'
|
|
|
|
export -n CFLAGS
|
|
|
|
export -n CC
|
2015-01-15 09:13:36 -05:00
|
|
|
export -n PYTHON_CONFIGURE_OPTS
|
2014-10-29 06:35:29 -04:00
|
|
|
|
|
|
|
@test "require_gcc on OS X 10.9" {
|
2015-01-15 09:13:36 -05:00
|
|
|
|
2023-01-18 16:21:10 -05:00
|
|
|
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'
|
2014-10-29 06:35:29 -04:00
|
|
|
|
|
|
|
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
|
2014-11-03 03:33:44 -05:00
|
|
|
MACOSX_DEPLOYMENT_TARGET=10.9
|
2014-10-29 06:35:29 -04:00
|
|
|
OUT
|
2023-01-18 16:21:10 -05:00
|
|
|
|
|
|
|
unstub uname
|
|
|
|
unstub sw_vers
|
|
|
|
unstub gcc
|
2014-10-29 06:35:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "require_gcc on OS X 10.10" {
|
2023-01-18 16:21:10 -05:00
|
|
|
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
|
2015-01-15 09:13:36 -05:00
|
|
|
|
2023-01-18 16:21:10 -05:00
|
|
|
stub gcc '--version : echo 4.2.1'
|
2014-10-29 06:35:29 -04:00
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
|
|
|
require_gcc
|
|
|
|
echo CC=\$CC
|
|
|
|
echo MACOSX_DEPLOYMENT_TARGET=\${MACOSX_DEPLOYMENT_TARGET-no}
|
|
|
|
DEF
|
2023-01-18 16:21:10 -05:00
|
|
|
|
|
|
|
unstub uname
|
|
|
|
unstub sw_vers
|
|
|
|
unstub gcc
|
|
|
|
|
2014-10-29 06:35:29 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
CC=${TMP}/bin/gcc
|
2022-12-23 02:55:13 -05:00
|
|
|
MACOSX_DEPLOYMENT_TARGET=10.10
|
2014-10-29 06:35:29 -04:00
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "require_gcc silences warnings" {
|
2023-01-18 16:21:10 -05:00
|
|
|
stub gcc '--version : echo warning >&2; echo 4.2.1'
|
2014-10-29 06:35:29 -04:00
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
|
|
|
require_gcc
|
|
|
|
echo \$CC
|
|
|
|
DEF
|
|
|
|
assert_success "${TMP}/bin/gcc"
|
2023-01-18 16:21:10 -05:00
|
|
|
|
|
|
|
unstub gcc
|
2014-10-29 06:35:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "CC=clang by default on OS X 10.10" {
|
|
|
|
mkdir -p "$INSTALL_ROOT"
|
|
|
|
cd "$INSTALL_ROOT"
|
|
|
|
|
2023-10-05 23:59:29 -04:00
|
|
|
for i in {1..10}; do stub uname '-s : echo Darwin'; done
|
2022-02-09 10:55:23 -05:00
|
|
|
for i in {1..3}; do stub sw_vers '-productVersion : echo 10.10'; done
|
2014-11-03 03:33:44 -05:00
|
|
|
|
2014-10-29 06:35:29 -04:00
|
|
|
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
|
2022-12-23 02:55:13 -05:00
|
|
|
./configure --prefix=$INSTALL_ROOT --enable-shared --libdir=${TMP}/install/lib
|
2014-10-29 06:35:29 -04:00
|
|
|
CC=clang
|
|
|
|
CFLAGS=no
|
|
|
|
make -j 2
|
|
|
|
make install
|
|
|
|
OUT
|
2023-01-18 16:21:10 -05:00
|
|
|
|
|
|
|
unstub uname
|
|
|
|
unstub sw_vers
|
|
|
|
|
2014-10-29 06:35:29 -04:00
|
|
|
}
|
2022-05-31 12:47:06 -04:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
2023-01-18 16:21:10 -05:00
|
|
|
assert_success
|
2022-05-31 12:47:06 -04:00
|
|
|
assert_output <<OUT
|
2022-09-01 06:48:26 -04:00
|
|
|
CFLAGS_EXTRA=-DMICROPY_PY_SYS_PATH_DEFAULT='".frozen:${TMP}/install/lib/micropython"' -Wno-floating-conversion
|
2022-05-31 12:47:06 -04:00
|
|
|
OUT
|
|
|
|
}
|