From 50558db72c4b6d3c9f1872f5d5d931f18baeeadb Mon Sep 17 00:00:00 2001 From: scivision Date: Sun, 31 Mar 2024 13:20:57 -0400 Subject: [PATCH] test: put cmake logic in folder --- CMakeLists.txt | 15 --------------- test/CMakeLists.txt | 27 ++++++++++++++++++++------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f2fc82..5dc5619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,21 +34,6 @@ target_compile_definitions(assert PRIVATE $<$>:NO_IEEE>) add_subdirectory(src) if(${PROJECT_NAME}_BUILD_TESTING) - find_package(Python COMPONENTS Interpreter) - - if(Python_FOUND AND NOT DEFINED Scipy_ok) - execute_process(COMMAND ${Python_EXECUTABLE} -c "import scipy; print('SciPy', scipy.__version__)" - ERROR_VARIABLE err - RESULT_VARIABLE ret - ) - message(VERBOSE "${ret} ${err}") - if(ret EQUAL 0) - set(Scipy_ok true CACHE BOOL "Scipy OK") - else() - set(Scipy_ok false CACHE BOOL "Scipy Not Found") - endif() - endif() - add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f93a45d..11d3648 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,19 @@ -#--- tests +find_package(Python COMPONENTS Interpreter) + +if(Python_FOUND AND NOT DEFINED Scipy_ok) + execute_process(COMMAND ${Python_EXECUTABLE} -c "import scipy; print('SciPy', scipy.__version__)" + ERROR_VARIABLE err + RESULT_VARIABLE ret + ) + message(VERBOSE "${ret} ${err}") + if(ret EQUAL 0) + set(Scipy_ok true CACHE BOOL "Scipy OK") + else() + set(Scipy_ok false CACHE BOOL "Scipy Not Found") + endif() +endif() + + add_executable(testcalc test.f90) target_link_libraries(testcalc PRIVATE assert funcs hyper reg) @@ -14,9 +29,7 @@ set_property(TEST Value PROPERTY PASS_REGULAR_EXPRESSION "308 / 29") get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) - -if(Scipy_ok) - add_test(NAME FunctionEval - COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_functions.py $ - ) -endif() +add_test(NAME FunctionEval +COMMAND Python::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test_functions.py $ +) +set_property(TEST FunctionEval PROPERTY DISABLED $>)