aboutsummaryrefslogtreecommitdiffstats
path: root/tests/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/CMakeLists.txt')
-rw-r--r--tests/CMakeLists.txt30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index dae8b5a..cf1a984 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -370,12 +370,17 @@ endif()
string(REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR}/test_" PYBIND11_ABS_PYTEST_FILES
"${PYBIND11_PYTEST_FILES}")
+set(PYBIND11_TEST_PREFIX_COMMAND
+ ""
+ CACHE STRING "Put this before pytest, use for checkers and such")
+
# A single command to compile and run the tests
add_custom_target(
pytest
- COMMAND ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES}
+ COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
+ ${PYBIND11_ABS_PYTEST_FILES}
DEPENDS ${test_targets}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
USES_TERMINAL)
if(PYBIND11_TEST_OVERRIDE)
@@ -386,6 +391,27 @@ if(PYBIND11_TEST_OVERRIDE)
"Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect")
endif()
+# cmake-format: off
+add_custom_target(
+ memcheck
+ COMMAND
+ PYTHONMALLOC=malloc
+ valgrind
+ --leak-check=full
+ --show-leak-kinds=definite,indirect
+ --errors-for-leak-kinds=definite,indirect
+ --error-exitcode=1
+ --read-var-info=yes
+ --track-origins=yes
+ --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp"
+ --suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp"
+ --gen-suppressions=all
+ ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES}
+ DEPENDS ${test_targets}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ USES_TERMINAL)
+# cmake-format: on
+
# Add a check target to run all the tests, starting with pytest (we add dependencies to this below)
add_custom_target(check DEPENDS pytest)