Skip to content

Commit

Permalink
add ctest as test driver
Browse files Browse the repository at this point in the history
* add `enable_testing()` in top level CMakeLists to discover tests
* add `add_test` for both unit tests as well as integration tests with
  prefixing the tests with the corresponding test type
  • Loading branch information
felixschurk committed Apr 28, 2024
1 parent 6d514ac commit 7601e88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required (VERSION 3.22)
enable_testing()

set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
10 changes: 9 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set (test_SRCS
view.t
)

add_custom_target (test ./run_all --verbose
add_custom_target (test_all ./run_all --verbose
DEPENDS ${test_SRCS} task_executable
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test)

Expand All @@ -65,6 +65,10 @@ foreach (src_FILE ${test_SRCS})
if (DARWIN)
target_link_libraries (${src_FILE} "-framework CoreFoundation -framework Security -framework SystemConfiguration")
endif (DARWIN)
add_test(NAME unittest_${src_FILE}
COMMAND ${src_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach (src_FILE)

configure_file(run_all run_all COPYONLY)
Expand Down Expand Up @@ -197,6 +201,10 @@ set (pythonTests

foreach (python_Test ${pythonTests})
configure_file(${python_Test} ${python_Test} COPYONLY)
add_test(NAME integrationtest_${python_Test}
COMMAND ${Python_EXECUTABLE} ${python_Test}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach(python_Test)

#SET(CMAKE_BUILD_TYPE gcov)
Expand Down
4 changes: 0 additions & 4 deletions test/run_all
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ class TestRunner(object):
self._outputq = Queue()

def _find_tests(self):
<<<<<<< HEAD
for test in glob.glob("*.t"):
=======
for test in glob.glob("*.t") + glob.glob("*.t.py"):
>>>>>>> e73f4b821 (update paths and globing in run_all)
if os.access(test, os.X_OK):
# Executables only
if self._is_parallelizable(test):
Expand Down

0 comments on commit 7601e88

Please sign in to comment.