File: test_runtime.patch

package info (click to toggle)
netgen 6.2.2601%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 13,076 kB
  • sloc: cpp: 166,627; tcl: 6,310; python: 2,868; sh: 522; makefile: 90
file content (63 lines) | stat: -rw-r--r-- 2,390 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Index: netgen/tests/CMakeLists.txt
===================================================================
--- netgen.orig/tests/CMakeLists.txt	2023-11-10 20:25:04.570790027 +0100
+++ netgen/tests/CMakeLists.txt	2023-11-10 20:27:11.153988595 +0100
@@ -1,3 +1,14 @@
+if(ENABLE_RUNTIME_UNIT_TESTS)
+  cmake_minimum_required(VERSION 3.27)
+  project(netgen_runtime_tests)
+  set(ENABLE_UNIT_TESTS 1)
+  enable_testing()
+  include(CTest)
+
+  find_package(Netgen)
+  set(Python3_EXECUTABLE ${NETGEN_PYTHON_EXECUTABLE})
+endif(ENABLE_RUNTIME_UNIT_TESTS)
+
 add_subdirectory(catch)
 add_subdirectory(pytest)
 
Index: netgen/tests/catch/CMakeLists.txt
===================================================================
--- netgen.orig/tests/catch/CMakeLists.txt	2023-11-10 20:25:04.570790027 +0100
+++ netgen/tests/catch/CMakeLists.txt	2023-11-10 20:25:04.570790027 +0100
@@ -5,6 +5,9 @@
 # Build catch_main test object
 find_package(Catch2 REQUIRED)
 include_directories(${CATCH_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../libsrc/include ${SPDLOG_INCLUDE_DIR})
+if(ENABLE_RUNTIME_UNIT_TESTS)
+  include_directories(${NETGEN_PYTHON_INCLUDE_DIRS})
+endif()
 add_library(catch_main STATIC main.cpp)
 set_target_properties(catch_main PROPERTIES CXX_STANDARD 17)
 add_dependencies(unit_tests catch_main)
@@ -17,11 +20,16 @@
 endif()
 
 # ensure the test targets are built before testing
+if(NOT ENABLE_RUNTIME_UNIT_TESTS)
 add_test(NAME unit_tests_built COMMAND ${CMAKE_COMMAND} --build . --target unit_tests --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../.. )
+endif()
 
 macro(add_unit_test name sources)
   add_executable(test_${name} ${sources} )
   target_link_libraries(test_${name} ngcore catch_main nglib)
+  if(ENABLE_RUNTIME_UNIT_TESTS)
+    target_link_libraries(test_${name} ${NETGEN_PYTHON_LIBRARIES} )
+  endif()
 
   add_dependencies(unit_tests test_${name})
   add_test(NAME unit_${name} COMMAND test_${name})
@@ -34,7 +42,11 @@
 
 add_unit_test(archive archive.cpp)
 # RegisterForArchive needs Python.h if built with Python
-target_link_libraries(test_archive netgen_python)
+if(ENABLE_RUNTIME_UNIT_TESTS)
+  target_link_libraries(test_archive ${NETGEN_PYTHON_LIBRARIES})
+else()
+  target_link_libraries(test_archive netgen_python)
+endif()
 add_unit_test(array array.cpp)
 add_unit_test(ranges ranges.cpp)
 add_unit_test(symboltable symboltable.cpp)