From be4702781d5bfe092daa2f6bfa1012c047e2161a Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 7 Dec 2017 07:14:38 -0500 Subject: [PATCH] CTest: Fix regression in test timeout compuatation Refactoring in commit 66419bc046 (CTest: convert timeouts to std::chrono::duration, 2017-11-20) accidentally changed the logic used to compute the timeout for a test when it starts. It incorrectly limits the maximum possible timeout to 2 minutes rather than 2 minutes less than the total allowed test time remaining. Update the new logic to restore the original behavior. Avoid subtracting 2 minutes from our "infinite" timeout value to avoid creating very large timeouts that are not "infinite" and may exceed integer type ranges. --- Source/CTest/cmCTestRunTest.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 830ebdfb6b..a07564990a 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -18,7 +18,6 @@ #include "cmsys/Base64.h" #include "cmsys/Process.h" #include "cmsys/RegularExpression.hxx" -#include #include #include #include @@ -686,8 +685,10 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration testTimeOut, // determine how much time we have std::chrono::duration timeout = - std::min>( - this->CTest->GetRemainingTimeAllowed(), std::chrono::minutes(2)); + this->CTest->GetRemainingTimeAllowed(); + if (timeout != std::chrono::duration::max()) { + timeout -= std::chrono::minutes(2); + } if (this->CTest->GetTimeOut() > std::chrono::duration::zero() && this->CTest->GetTimeOut() < timeout) { timeout = this->CTest->GetTimeOut();