Skip to content

Commit

Permalink
test: put cmake logic in folder
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 31, 2024
1 parent 299c02a commit 50558db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ target_compile_definitions(assert PRIVATE $<$<NOT:$<BOOL:${f03ieee}>>: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()

Expand Down
27 changes: 20 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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 $<TARGET_FILE:rpncalc>
)
endif()
add_test(NAME FunctionEval
COMMAND Python::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test_functions.py $<TARGET_FILE:rpncalc>
)
set_property(TEST FunctionEval PROPERTY DISABLED $<NOT:$<BOOL:${Scipy_ok}>>)

0 comments on commit 50558db

Please sign in to comment.