cmake/0004-ctest-Restore-support-for-timeout-values-higher-than.patch
2023-10-03 16:32:06 +02:00

94 lines
3.6 KiB
Diff

From d267c128a232e9beb99576f901ee1b9291ba1480 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 29 Sep 2023 09:00:30 -0400
Subject: [PATCH 4/6] ctest: Restore support for --timeout values higher than
default test timeout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since refactoring in commit 0a5aeaf302 (cmCTestRunTest: Consolidate test
timeout selection logic, 2023-05-04, v3.27.0-rc1~120^2) we accidentally
truncate `--timeout` values to ctest's default `TimeOut`. Fix the
logic to prefer the flag whenever the `TIMEOUT` property is not set.
In combination with the prior refactoring, this also fixes a bug that
caused `--timeout` values of 10000000 seconds or more to be ignored.
Fixes: #23979
Signed-off-by: Björn Esser <besser82@fedoraproject.org>
---
Help/manual/ctest.1.rst | 3 ++-
Source/CTest/cmCTestRunTest.cxx | 11 ++++++-----
.../RunCMake/CTestTimeout/FlagOverridesVar-stdout.txt | 6 ++++++
Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake | 7 +++++++
4 files changed, 21 insertions(+), 6 deletions(-)
create mode 100644 Tests/RunCMake/CTestTimeout/FlagOverridesVar-stdout.txt
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 994ae47b77..5c3889e3be 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -1230,7 +1230,8 @@ Configuration settings include:
``TimeOut``
The default timeout for each test if not specified by the
- :prop_test:`TIMEOUT` test property.
+ :prop_test:`TIMEOUT` test property or the
+ :option:`--timeout <ctest --timeout>` flag.
* `CTest Script`_ variable: :variable:`CTEST_TEST_TIMEOUT`
* :module:`CTest` module variable: ``DART_TESTING_TIMEOUT``
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 563439acda..19e505fcfe 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -768,11 +768,12 @@ bool cmCTestRunTest::ForkProcess()
timeout = this->CTest->GetGlobalTimeout();
}
- // Check CTEST_TEST_TIMEOUT.
- cmDuration ctestTestTimeout = this->CTest->GetTimeOut();
- if (ctestTestTimeout > cmDuration::zero() &&
- (!timeout || ctestTestTimeout < *timeout)) {
- timeout = ctestTestTimeout;
+ if (!timeout) {
+ // Check CTEST_TEST_TIMEOUT.
+ cmDuration ctestTestTimeout = this->CTest->GetTimeOut();
+ if (ctestTestTimeout > cmDuration::zero()) {
+ timeout = ctestTestTimeout;
+ }
}
}
diff --git a/Tests/RunCMake/CTestTimeout/FlagOverridesVar-stdout.txt b/Tests/RunCMake/CTestTimeout/FlagOverridesVar-stdout.txt
new file mode 100644
index 0000000000..f580871638
--- /dev/null
+++ b/Tests/RunCMake/CTestTimeout/FlagOverridesVar-stdout.txt
@@ -0,0 +1,6 @@
+Test project [^
+]*/Tests/RunCMake/CTestTimeout/FlagOverridesVar-build
+ Start 1: TestTimeout
+1/1 Test #1: TestTimeout ...................... Passed +[1-9][0-9.]* sec
++
+100% tests passed, 0 tests failed out of 1
diff --git a/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake
index e9ecc5f20d..470bbd890d 100644
--- a/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestTimeout/RunCMakeTest.cmake
@@ -94,3 +94,10 @@ block()
set(CASE_CMAKELISTS_SUFFIX_CODE "set_property(TEST TestTimeout PROPERTY TIMEOUT 10)\n")
run_ctest_timeout(PropertyOverridesVar)
endblock()
+
+block()
+ set(TIMEOUT 4)
+ set(CASE_TEST_PREFIX_CODE "set(CTEST_TEST_TIMEOUT 2)")
+ set(CASE_CMAKELISTS_SUFFIX_CODE "set_property(TEST TestTimeout PROPERTY TIMEOUT)\n")
+ run_ctest_timeout(FlagOverridesVar --timeout 10000001)
+endblock()
--
2.41.0