Skip to content

Commit

Permalink
cmake: Add Python tests only when building with Python support
Browse files Browse the repository at this point in the history
  • Loading branch information
afh committed Jan 16, 2024
1 parent 6372a7b commit 7a018d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ endif()

########################################################################

find_package(Python COMPONENTS Interpreter) # Used for running tests

if (USE_PYTHON)
if (NOT BUILD_LIBRARY)
message(ERROR "Building the python module requires BUILD_LIBRARY=ON.")
Expand Down
7 changes: 6 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
include(ProcessorCount)
ProcessorCount(PROCESSORS)

find_package(Python COMPONENTS Interpreter) # Used for running tests
if (NOT Python_FOUND)
message(WARNING "Could not find Python. Tests will not be run.")
endif()

if (NOT PROCESSORS EQUAL 0)
math(EXPR JOBS "${PROCESSORS} * 2")
set(CTEST_BUILD_FLAGS -j${JOBS})
Expand All @@ -19,7 +24,7 @@ macro(add_ledger_harness_tests _class)
file(GLOB ${_class}_TESTS *.test)
foreach(TestFile ${${_class}_TESTS})
get_filename_component(TestFile_Name ${TestFile} NAME_WE)
string(FIND ${TestFile_Name} "_py.test" TestFile_IsPythonTest)
string(FIND ${TestFile} "_py.test" TestFile_IsPythonTest)
if ((TestFile_IsPythonTest EQUAL -1) OR HAVE_BOOST_PYTHON)
add_test(NAME ${_class}Test_${TestFile_Name}
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/test/RegressTests.py
Expand Down

0 comments on commit 7a018d3

Please sign in to comment.