From 745be900ef6aea748ddc1a8eb8372cc0aff30baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 21 Oct 2022 21:30:15 +0000 Subject: [PATCH 1/3] Run unit tests in parallel if possible ReadResponse unit tests usually takes at least 30 seconds to run on my computer, so having the unit tests run on more than one thread makes a big difference. --- tests/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4096b74..d2533b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,12 +15,21 @@ if(GCOV_ENABLE) COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/.ctest-finished ) + include(ProcessorCount) + ProcessorCount(N) + if(N EQUAL 0) + message(WARNING "CTest: There was an issue reading the core count, tests won't be run in parallel") + else() + message(STATUS "CTest: Detected ${N} CPU threads") + set(ctest_test_args ${ctest_test_args} -j${N}) + endif() + # This step needs to always return OK but log whether it was successful or not. The thought here # is that if the tests all pass, .ctest-finished is created and we can check for its existance # after generating the report to determine if the overall build result is a pass or fail. add_custom_target( test_run_all - COMMAND ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1 ${CMAKE_CTEST_COMMAND} --timeout 30 + COMMAND ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1 ${CMAKE_CTEST_COMMAND} ${ctest_test_args} --timeout 30 COMMAND ${CMAKE_COMMAND} -E touch .ctest-finished || exit 0 BYPRODUCTS ${PROJECT_BINARY_DIR}/.ctest-finished WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" From d6029f7fd2b4069ed2efb8c03be179d83e2a767f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 21 Oct 2022 22:02:19 +0000 Subject: [PATCH 2/3] Move the other Ctest arguments into a single variable --- tests/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d2533b8..f5cb04b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,13 +15,15 @@ if(GCOV_ENABLE) COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/.ctest-finished ) + set(ctest_test_args --timeout 30 --output-on-failure) + include(ProcessorCount) ProcessorCount(N) if(N EQUAL 0) message(WARNING "CTest: There was an issue reading the core count, tests won't be run in parallel") else() message(STATUS "CTest: Detected ${N} CPU threads") - set(ctest_test_args ${ctest_test_args} -j${N}) + set(ctest_test_args -j${N} ${ctest_test_args}) endif() # This step needs to always return OK but log whether it was successful or not. The thought here @@ -29,7 +31,7 @@ if(GCOV_ENABLE) # after generating the report to determine if the overall build result is a pass or fail. add_custom_target( test_run_all - COMMAND ${CMAKE_COMMAND} -E env CTEST_OUTPUT_ON_FAILURE=1 ${CMAKE_CTEST_COMMAND} ${ctest_test_args} --timeout 30 + COMMAND ${CMAKE_CTEST_COMMAND} ${ctest_test_args} COMMAND ${CMAKE_COMMAND} -E touch .ctest-finished || exit 0 BYPRODUCTS ${PROJECT_BINARY_DIR}/.ctest-finished WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" From 8c5c84cc17f30463fc1a3b0229c5c63055de6c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Fri, 21 Oct 2022 22:03:08 +0000 Subject: [PATCH 3/3] Formatting --- tests/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f5cb04b..e66dc79 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,7 +20,9 @@ if(GCOV_ENABLE) include(ProcessorCount) ProcessorCount(N) if(N EQUAL 0) - message(WARNING "CTest: There was an issue reading the core count, tests won't be run in parallel") + message( + WARNING "CTest: There was an issue reading the core count, tests won't be run in parallel" + ) else() message(STATUS "CTest: Detected ${N} CPU threads") set(ctest_test_args -j${N} ${ctest_test_args})