@@ -370,32 +370,17 @@ endif()
370
370
string (REPLACE "test_" "${CMAKE_CURRENT_SOURCE_DIR} /test_" PYBIND11_ABS_PYTEST_FILES
371
371
"${PYBIND11_PYTEST_FILES} " )
372
372
373
- if (NOT PYBIND11_MEMCHECK)
374
- set (PYBIND11_TEST_PREFIX_COMMAND "" )
375
- else ()
376
- # cmake-format: off
377
- set (PYBIND11_TEST_PREFIX_COMMAND
378
- PYTHONMALLOC=malloc
379
- valgrind
380
- --leak-check=full
381
- --show-leak-kinds=definite,indirect
382
- --errors-for-leak-kinds=definite,indirect
383
- --error-exitcode=1
384
- --read-var-info=yes
385
- --track-origins=yes
386
- --suppressions="${CMAKE_CURRENT_SOURCE_DIR} /valgrind-python.supp"
387
- --suppressions="${CMAKE_CURRENT_SOURCE_DIR} /valgrind-numpy-scipy.supp"
388
- --gen-suppressions=all )
389
- # cmake-format: on
390
- endif ()
373
+ set (PYBIND11_TEST_PREFIX_COMMAND
374
+ ""
375
+ CACHE STRING "Put this before pytest, use for checkers and such" )
391
376
392
377
# A single command to compile and run the tests
393
378
add_custom_target (
394
379
pytest
395
380
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
396
381
${PYBIND11_ABS_PYTEST_FILES}
397
382
DEPENDS ${test_targets}
398
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
383
+ WORKING_DIRECTORY " ${CMAKE_CURRENT_BINARY_DIR} "
399
384
USES_TERMINAL )
400
385
401
386
if (PYBIND11_TEST_OVERRIDE)
@@ -406,10 +391,26 @@ if(PYBIND11_TEST_OVERRIDE)
406
391
"Note: not all tests run: -DPYBIND11_TEST_OVERRIDE is in effect" )
407
392
endif ()
408
393
394
+ # cmake-format: off
409
395
add_custom_target (
410
396
memcheck
411
- DEPENDS pytest
412
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
397
+ COMMAND
398
+ PYTHONMALLOC=malloc
399
+ valgrind
400
+ --leak-check=full
401
+ --show-leak-kinds=definite,indirect
402
+ --errors-for-leak-kinds=definite,indirect
403
+ --error-exitcode=1
404
+ --read-var-info=yes
405
+ --track-origins=yes
406
+ --suppressions="${CMAKE_CURRENT_SOURCE_DIR} /valgrind-python.supp"
407
+ --suppressions="${CMAKE_CURRENT_SOURCE_DIR} /valgrind-numpy-scipy.supp"
408
+ --gen-suppressions=all
409
+ ${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES}
410
+ DEPENDS ${test_targets}
411
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
412
+ USES_TERMINAL )
413
+ # cmake-format: on
413
414
414
415
# Add a check target to run all the tests, starting with pytest (we add dependencies to this below)
415
416
add_custom_target (check DEPENDS pytest)
0 commit comments