fixed: do not enable tensorflow test without tensorflow on the system

tensorflow is too heavy to drag in as a dependency for everyone
This commit is contained in:
Arne Morten Kvarving committed 2025-10-09 15:03:24 +02:00
1 parent 92cf91082b
commit 6049c07c3c
1 file changed
+27 -20
+27 -20
View File
@@ -1,22 +1,29 @@
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/integration/HybridNewton) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/tests/integration/HybridNewton)
execute_process(
add_test(NAME COMMAND "${Python3_EXECUTABLE}" -c "import tensorflow"
HybridNewton RESULT_VARIABLE PYTHON_HAS_TENSORFLOW
COMMAND OUTPUT_QUIET
${Python3_EXECUTABLE} ERROR_QUIET
-m unittest discover )
${PROJECT_SOURCE_DIR}/python/integration_tests/ml/hybrid_newton if(PYTHON_HAS_TENSORFLOW EQUAL 0)
WORKING_DIRECTORY add_test(NAME
${PROJECT_BINARY_DIR}/tests/integration/HybridNewton HybridNewton
) COMMAND
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) ${Python3_EXECUTABLE}
set(modifications -m unittest discover
"PYTHONPATH=path_list_append:${opm-common_DIR}/python" ${PROJECT_SOURCE_DIR}/python/integration_tests/ml/hybrid_newton
"PYTHONPATH=path_list_append:${CMAKE_CURRENT_BINARY_DIR}/python" WORKING_DIRECTORY
"FLOW_BINARY=set:$<TARGET_FILE:flow>" ${PROJECT_BINARY_DIR}/tests/integration/HybridNewton
) )
set_tests_properties(HybridNewton PROPERTIES if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
ENVIRONMENT_MODIFICATION set(modifications
"${modifications}" "PYTHONPATH=path_list_append:${opm-common_DIR}/python"
) "PYTHONPATH=path_list_append:${CMAKE_CURRENT_BINARY_DIR}/python"
"FLOW_BINARY=set:$<TARGET_FILE:flow>"
)
set_tests_properties(HybridNewton PROPERTIES
ENVIRONMENT_MODIFICATION
"${modifications}"
)
endif()
endif() endif()