From de0035fdcccb4c8acc92bf1db0a76b3c1f18003f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 8 Dec 2017 08:07:26 -0500 Subject: cmCTestBuildAndTestHandler: Convert timeout to std::chrono::duration --- Source/CTest/cmCTestBuildAndTestHandler.cxx | 19 +++++++++---------- Source/CTest/cmCTestBuildAndTestHandler.h | 3 ++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 672087d..85d98d0 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -11,6 +11,7 @@ #include "cmsys/Process.h" #include +#include #include cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -18,7 +19,7 @@ cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() this->BuildTwoConfig = false; this->BuildNoClean = false; this->BuildNoCMake = false; - this->Timeout = 0; + this->Timeout = std::chrono::duration::zero(); } void cmCTestBuildAndTestHandler::Initialize() @@ -224,10 +225,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) } for (std::string const& tar : this->BuildTargets) { std::chrono::duration remainingTime = std::chrono::seconds(0); - if (this->Timeout > 0) { - remainingTime = std::chrono::duration(this->Timeout) - - std::chrono::duration_cast( - std::chrono::steady_clock::now() - clock_start); + if (this->Timeout > std::chrono::duration::zero()) { + remainingTime = + this->Timeout - (std::chrono::steady_clock::now() - clock_start); if (remainingTime <= std::chrono::seconds(0)) { if (outstring) { *outstring = "--build-and-test timeout exceeded. "; @@ -324,10 +324,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // how much time is remaining std::chrono::duration remainingTime = std::chrono::seconds(0); - if (this->Timeout > 0) { - remainingTime = std::chrono::duration(this->Timeout) - - std::chrono::duration_cast( - std::chrono::steady_clock::now() - clock_start); + if (this->Timeout > std::chrono::duration::zero()) { + remainingTime = + this->Timeout - (std::chrono::steady_clock::now() - clock_start); if (remainingTime <= std::chrono::seconds(0)) { if (outstring) { *outstring = "--build-and-test timeout exceeded. "; @@ -396,7 +395,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( } if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) { idx++; - this->Timeout = atof(allArgs[idx].c_str()); + this->Timeout = std::chrono::duration(atof(allArgs[idx].c_str())); } if (currentArg == "--build-generator" && idx < allArgs.size() - 1) { idx++; diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index f19cb67..f8a9ed7 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -7,6 +7,7 @@ #include "cmCTestGenericHandler.h" +#include #include #include #include @@ -67,7 +68,7 @@ protected: std::vector TestCommandArgs; std::vector BuildTargets; bool BuildNoCMake; - double Timeout; + std::chrono::duration Timeout; }; #endif -- cgit v0.12