From 620a808ad062f6ee20f0799b7c20cb4b54da262f Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Mon, 27 Feb 2017 15:42:51 +0100 Subject: [PATCH] Test with debug build of Python when DEBUG=1 on Travis --- .travis.yml | 6 +++++- tests/CMakeLists.txt | 2 +- tests/test_cmake_build/installed_target/CMakeLists.txt | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e7005ff1..2359dec0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -147,9 +147,13 @@ install: - | # Install dependencies if [ -n "$DOCKER" ]; then + if [ -n "$DEBUG" ]; then + PY_DEBUG="python$PY-dbg python$PY-scipy-dbg" + export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm" + fi docker exec --tty "$containerid" sh -c "for s in 0 15; do sleep \$s; \ apt-get -qy --no-install-recommends $APT_GET_EXTRA install \ - python$PY-dev python$PY-pytest python$PY-scipy \ + $PY_DEBUG python$PY-dev python$PY-pytest python$PY-scipy \ libeigen3-dev cmake make ${COMPILER_PACKAGES} && break; done" else pip install numpy scipy pytest diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2f2d3cd91..cb2b0afc1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -159,7 +159,7 @@ if(NOT PYBIND11_PYTEST_FOUND) endif() # A single command to compile and run the tests -add_custom_target(pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest -rws ${PYBIND11_PYTEST_FILES} +add_custom_target(pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest -rws --capture=sys ${PYBIND11_PYTEST_FILES} DEPENDS pybind11_tests WORKING_DIRECTORY ${testdir}) if(PYBIND11_TEST_OVERRIDE) diff --git a/tests/test_cmake_build/installed_target/CMakeLists.txt b/tests/test_cmake_build/installed_target/CMakeLists.txt index dd206592f..cd3ae6f7d 100644 --- a/tests/test_cmake_build/installed_target/CMakeLists.txt +++ b/tests/test_cmake_build/installed_target/CMakeLists.txt @@ -14,5 +14,9 @@ target_link_libraries(test_cmake_build PRIVATE pybind11::module) set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" SUFFIX "${PYTHON_MODULE_EXTENSION}") +# Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module). +# This may be needed to resolve header conflicts, e.g. between Python release and debug headers. +set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) + add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME})