From b14f05368565bb3f9f6f01354d2403bd3d5a024b Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 11 May 2021 13:53:45 +0200
Subject: [PATCH] [ctest] Better test-specific timeouts (3 x RUNTIME).

The --timeout given to ctest is valid for each test, not full runtime.
---
 scripts/cmake/test/AddTest.cmake | 15 +++++++++++----
 scripts/cmake/test/Test.cmake    |  4 ++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/scripts/cmake/test/AddTest.cmake b/scripts/cmake/test/AddTest.cmake
index 7410ca33ceb..6c9f67af01b 100644
--- a/scripts/cmake/test/AddTest.cmake
+++ b/scripts/cmake/test/AddTest.cmake
@@ -95,7 +95,10 @@ function(AddTest)
     if(NOT DEFINED AddTest_REQUIREMENTS)
         set(AddTest_REQUIREMENTS TRUE)
     endif()
-    if(NOT DEFINED AddTest_RUNTIME)
+    set(timeout ${ogs.ctest.large_runtime})
+    if(DEFINED AddTest_RUNTIME)
+        math(EXPR timeout "${AddTest_RUNTIME} * 3")
+    else()
         set(AddTest_RUNTIME 1)
     endif()
     if(NOT DEFINED AddTest_WORKING_DIRECTORY)
@@ -410,9 +413,13 @@ Use six arguments version of AddTest with absolute and relative tolerances"
     endif()
 
     current_dir_as_list(ProcessLib DIR_LABELS)
-    set_tests_properties(
-        ${TEST_NAME} PROPERTIES COST ${AddTest_RUNTIME} DISABLED
-                                ${AddTest_DISABLED} LABELS "${DIR_LABELS}"
+
+    set_tests_properties( ${TEST_NAME}
+        PROPERTIES
+            COST ${AddTest_RUNTIME}
+            DISABLED ${AddTest_DISABLED}
+            LABELS "${DIR_LABELS}"
+            TIMEOUT ${timeout}
     )
 
     add_dependencies(ctest ${AddTest_EXECUTABLE})
diff --git a/scripts/cmake/test/Test.cmake b/scripts/cmake/test/Test.cmake
index a26a61b0f75..e8be884df48 100644
--- a/scripts/cmake/test/Test.cmake
+++ b/scripts/cmake/test/Test.cmake
@@ -63,7 +63,7 @@ add_custom_target(
     COMMAND
         ${CMAKE_CTEST_COMMAND} -T Test --force-new-ctest-process
         --output-on-failure --output-log Tests/ctest.log --exclude-regex LARGE
-        ${CONFIG_PARAMETER} --timeout 900 # 15 minutes
+        ${CONFIG_PARAMETER}
     DEPENDS ${test_dependencies} ctest-cleanup
     USES_TERMINAL
 )
@@ -77,7 +77,7 @@ add_custom_target(
     COMMAND
         ${CMAKE_CTEST_COMMAND} -T Test --force-new-ctest-process
         --output-on-failure --output-log Tests/ctest-large.log --tests-regex
-        LARGE ${CONFIG_PARAMETER} --timeout 5400 # 90 minutes
+        LARGE ${CONFIG_PARAMETER}
     DEPENDS ${test_dependencies} ctest-large-cleanup
     USES_TERMINAL
 )
-- 
GitLab