Skip to content

Commit 4ad6c2a

Browse files
committed
Enable running tests in parallel using cmake's ctest.
1 parent 1c2accc commit 4ad6c2a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

testing/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
# run all tests sequentially (keep for backward compatibilty)
12
add_custom_target(tests
23
COMMENT "Running doxygen tests..."
34
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --doxygen ${PROJECT_BINARY_DIR}/bin/doxygen --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing
45
DEPENDS doxygen
56
)
6-
add_test(NAME suite
7-
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --doxygen $<TARGET_FILE:doxygen> --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing
8-
)
97

8+
# get the files in the testing directory starting with 3 digits and an underscore
9+
file(GLOB TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/[0-9][0-9][0-9]_*.*")
10+
11+
foreach(TEST_FILE ${TEST_FILES})
12+
# extract the test name from the file name (3 digit excluding trailing zeros)
13+
string(REGEX REPLACE "^.*/([0-9][0-9][0-9]*.*)\\.[^.]*$" "\\1" TEST_NAME "${TEST_FILE}")
14+
# extract the test id from the file name
15+
string(REGEX REPLACE "^.*/0?0?([1-9][0-9]*).*$" "\\1" TEST_ID "${TEST_FILE}")
16+
# add a test target for each test
17+
add_test(NAME ${TEST_NAME}
18+
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/runtests.py --id ${TEST_ID} --doxygen $<TARGET_FILE:doxygen> --inputdir ${CMAKE_SOURCE_DIR}/testing --outputdir ${PROJECT_BINARY_DIR}/testing
19+
)
20+
endforeach()

0 commit comments

Comments
 (0)