summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx12
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h4
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx5
-rw-r--r--Source/CTest/cmCTestBuildHandler.h4
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx7
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx21
-rw-r--r--Source/CTest/cmCTestRunTest.cxx23
-rw-r--r--Source/CTest/cmCTestRunTest.h5
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx13
-rw-r--r--Source/CTest/cmCTestScriptHandler.h3
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx3
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx7
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx17
-rw-r--r--Source/CTest/cmCTestTestHandler.h9
-rw-r--r--Source/CTest/cmProcess.cxx10
-rw-r--r--Source/CTest/cmProcess.h11
-rw-r--r--Source/cmCTest.cxx32
-rw-r--r--Source/cmCTest.h26
-rw-r--r--Source/cmDuration.h8
19 files changed, 111 insertions, 109 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 85d98d0..3383c9d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -19,7 +19,7 @@ cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
this->BuildTwoConfig = false;
this->BuildNoClean = false;
this->BuildNoCMake = false;
- this->Timeout = std::chrono::duration<double>::zero();
+ this->Timeout = cmDuration::zero();
}
void cmCTestBuildAndTestHandler::Initialize()
@@ -224,8 +224,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
this->BuildTargets.push_back("");
}
for (std::string const& tar : this->BuildTargets) {
- std::chrono::duration<double> remainingTime = std::chrono::seconds(0);
- if (this->Timeout > std::chrono::duration<double>::zero()) {
+ cmDuration remainingTime = std::chrono::seconds(0);
+ if (this->Timeout > cmDuration::zero()) {
remainingTime =
this->Timeout - (std::chrono::steady_clock::now() - clock_start);
if (remainingTime <= std::chrono::seconds(0)) {
@@ -323,8 +323,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
out << "\n";
// how much time is remaining
- std::chrono::duration<double> remainingTime = std::chrono::seconds(0);
- if (this->Timeout > std::chrono::duration<double>::zero()) {
+ cmDuration remainingTime = std::chrono::seconds(0);
+ if (this->Timeout > cmDuration::zero()) {
remainingTime =
this->Timeout - (std::chrono::steady_clock::now() - clock_start);
if (remainingTime <= std::chrono::seconds(0)) {
@@ -395,7 +395,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
}
if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
- this->Timeout = std::chrono::duration<double>(atof(allArgs[idx].c_str()));
+ this->Timeout = cmDuration(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 f8a9ed7..5e6d0aa 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -6,8 +6,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
-#include <chrono>
#include <sstream>
#include <stddef.h>
#include <string>
@@ -68,7 +68,7 @@ protected:
std::vector<std::string> TestCommandArgs;
std::vector<std::string> BuildTargets;
bool BuildNoCMake;
- std::chrono::duration<double> Timeout;
+ cmDuration Timeout;
};
#endif
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index ef4d3c6..2acf5e8 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -4,6 +4,7 @@
#include "cmAlgorithms.h"
#include "cmCTest.h"
+#include "cmDuration.h"
#include "cmFileTimeComparison.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
@@ -633,8 +634,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
}
}
-void cmCTestBuildHandler::GenerateXMLFooter(
- cmXMLWriter& xml, std::chrono::duration<double> elapsed_build_time)
+void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
+ cmDuration elapsed_build_time)
{
xml.StartElement("Log");
xml.Attribute("Encoding", "base64");
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index d1b9b2e..a9b121b 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -7,6 +7,7 @@
#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cmsys/RegularExpression.hxx"
#include <chrono>
@@ -87,8 +88,7 @@ private:
void GenerateXMLHeader(cmXMLWriter& xml);
void GenerateXMLLaunched(cmXMLWriter& xml);
void GenerateXMLLogScraped(cmXMLWriter& xml);
- void GenerateXMLFooter(cmXMLWriter& xml,
- std::chrono::duration<double> elapsed_build_time);
+ void GenerateXMLFooter(cmXMLWriter& xml, cmDuration elapsed_build_time);
bool IsLaunchedErrorFile(const char* fname);
bool IsLaunchedWarningFile(const char* fname);
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index eb067e5..821a94a 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -3,6 +3,7 @@
#include "cmCTestConfigureHandler.h"
#include "cmCTest.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmXMLWriter.h"
@@ -62,9 +63,9 @@ int cmCTestConfigureHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Configure with command: " << cCommand << std::endl,
this->Quiet);
- res = this->CTest->RunMakeCommand(
- cCommand.c_str(), output, &retVal, buildDirectory.c_str(),
- std::chrono::duration<double>::zero(), ofs);
+ res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
+ buildDirectory.c_str(),
+ cmDuration::zero(), ofs);
if (ofs) {
ofs.close();
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 2a9fd72..856421f 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -3,6 +3,7 @@
#include "cmCTestCoverageHandler.h"
#include "cmCTest.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmParseBlanketJSCoverage.h"
#include "cmParseCacheCoverage.h"
@@ -40,7 +41,7 @@ public:
{
this->Process = cmsysProcess_New();
this->PipeState = -1;
- this->TimeOut = std::chrono::duration<double>(-1);
+ this->TimeOut = cmDuration(-1);
}
~cmCTestRunProcess()
{
@@ -64,7 +65,7 @@ public:
}
}
void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
- void SetTimeout(std::chrono::duration<double> t) { this->TimeOut = t; }
+ void SetTimeout(cmDuration t) { this->TimeOut = t; }
bool StartProcess()
{
std::vector<const char*> args;
@@ -79,7 +80,7 @@ public:
}
cmsysProcess_SetOption(this->Process, cmsysProcess_Option_HideWindow, 1);
- if (this->TimeOut >= std::chrono::duration<double>::zero()) {
+ if (this->TimeOut >= cmDuration::zero()) {
cmsysProcess_SetTimeout(this->Process, this->TimeOut.count());
}
cmsysProcess_Execute(this->Process);
@@ -108,7 +109,7 @@ private:
cmsysProcess* Process;
std::vector<std::string> CommandLineStrings;
std::string WorkingDirectory;
- std::chrono::duration<double> TimeOut;
+ cmDuration TimeOut;
};
cmCTestCoverageHandler::cmCTestCoverageHandler()
@@ -1022,9 +1023,9 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res = this->CTest->RunCommand(
- covargs, &output, &errors, &retVal, tempDir.c_str(),
- std::chrono::duration<double>::zero() /*this->TimeOut*/);
+ int res = this->CTest->RunCommand(covargs, &output, &errors, &retVal,
+ tempDir.c_str(),
+ cmDuration::zero() /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
@@ -1387,9 +1388,9 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res = this->CTest->RunCommand(
- covargs, &output, &errors, &retVal, fileDir.c_str(),
- std::chrono::duration<double>::zero() /*this->TimeOut*/);
+ int res = this->CTest->RunCommand(covargs, &output, &errors, &retVal,
+ fileDir.c_str(),
+ cmDuration::zero() /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index baf894e..a5ec93d 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -25,7 +25,7 @@ cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler)
{
this->CTest = multiHandler.CTest;
this->TestHandler = multiHandler.TestHandler;
- this->TestResult.ExecutionTime = std::chrono::duration<double>::zero();
+ this->TestResult.ExecutionTime = cmDuration::zero();
this->TestResult.ReturnValue = 0;
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
this->TestResult.TestCount = 0;
@@ -400,7 +400,7 @@ bool cmCTestRunTest::StartTest(size_t total)
// Return immediately if test is disabled
if (this->TestProperties->Disabled) {
this->TestResult.Properties = this->TestProperties;
- this->TestResult.ExecutionTime = std::chrono::duration<double>::zero();
+ this->TestResult.ExecutionTime = cmDuration::zero();
this->TestResult.CompressOutput = false;
this->TestResult.ReturnValue = -1;
this->TestResult.CompletionStatus = "Disabled";
@@ -415,7 +415,7 @@ bool cmCTestRunTest::StartTest(size_t total)
}
this->TestResult.Properties = this->TestProperties;
- this->TestResult.ExecutionTime = std::chrono::duration<double>::zero();
+ this->TestResult.ExecutionTime = cmDuration::zero();
this->TestResult.CompressOutput = false;
this->TestResult.ReturnValue = -1;
this->TestResult.CompletionStatus = "Failed to start";
@@ -590,8 +590,7 @@ void cmCTestRunTest::DartProcessing()
}
}
-bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
- bool explicitTimeout,
+bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
std::vector<std::string>* environment)
{
this->TestProcess = cm::make_unique<cmProcess>(*this);
@@ -602,27 +601,25 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
this->TestProcess->SetCommandArguments(this->Arguments);
// determine how much time we have
- std::chrono::duration<double> timeout =
- this->CTest->GetRemainingTimeAllowed();
+ cmDuration timeout = this->CTest->GetRemainingTimeAllowed();
if (timeout != cmCTest::MaxDuration()) {
timeout -= std::chrono::minutes(2);
}
- if (this->CTest->GetTimeOut() > std::chrono::duration<double>::zero() &&
+ if (this->CTest->GetTimeOut() > cmDuration::zero() &&
this->CTest->GetTimeOut() < timeout) {
timeout = this->CTest->GetTimeOut();
}
- if (testTimeOut > std::chrono::duration<double>::zero() &&
+ if (testTimeOut > cmDuration::zero() &&
testTimeOut < this->CTest->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
}
// always have at least 1 second if we got to here
- if (timeout <= std::chrono::duration<double>::zero()) {
+ if (timeout <= cmDuration::zero()) {
timeout = std::chrono::seconds(1);
}
// handle timeout explicitly set to 0
- if (testTimeOut == std::chrono::duration<double>::zero() &&
- explicitTimeout) {
- timeout = std::chrono::duration<double>::zero();
+ if (testTimeOut == cmDuration::zero() && explicitTimeout) {
+ timeout = cmDuration::zero();
}
cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index fbc202f..4d57357 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -5,13 +5,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <chrono>
#include <set>
#include <stddef.h>
#include <string>
#include <vector>
#include "cmCTestTestHandler.h"
+#include "cmDuration.h"
#include "cmProcess.h" // IWYU pragma: keep (for unique_ptr)
class cmCTest;
@@ -82,8 +82,7 @@ private:
bool NeedsToRerun();
void DartProcessing();
void ExeNotFound(std::string exe);
- bool ForkProcess(std::chrono::duration<double> testTimeOut,
- bool explicitTimeout,
+ bool ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
std::vector<std::string>* environment);
void WriteLogOutputTop(size_t completed, size_t total);
// Run post processing of the process output for MemCheck
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 716ea10..d5faeb5 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -558,8 +558,8 @@ int cmCTestScriptHandler::RunCurrentScript()
// for a continuous, do we ned to run it more than once?
if (this->ContinuousDuration >= 0) {
this->UpdateElapsedTime();
- auto ending_time = std::chrono::steady_clock::now() +
- std::chrono::duration<double>(this->ContinuousDuration);
+ auto ending_time =
+ std::chrono::steady_clock::now() + cmDuration(this->ContinuousDuration);
if (this->EmptyBinDirOnce) {
this->EmptyBinDir = true;
}
@@ -567,8 +567,7 @@ int cmCTestScriptHandler::RunCurrentScript()
auto startOfInterval = std::chrono::steady_clock::now();
result = this->RunConfigurationDashboard();
auto interval = std::chrono::steady_clock::now() - startOfInterval;
- auto minimumInterval =
- std::chrono::duration<double>(this->MinimumInterval);
+ auto minimumInterval = cmDuration(this->MinimumInterval);
if (interval < minimumInterval) {
auto sleepTime = std::chrono::duration_cast<std::chrono::seconds>(
minimumInterval - interval)
@@ -960,7 +959,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
return cmSystemTools::RemoveADirectory(directoryPath);
}
-std::chrono::duration<double> cmCTestScriptHandler::GetRemainingTimeAllowed()
+cmDuration cmCTestScriptHandler::GetRemainingTimeAllowed()
{
if (!this->Makefile) {
return cmCTest::MaxDuration();
@@ -972,9 +971,9 @@ std::chrono::duration<double> cmCTestScriptHandler::GetRemainingTimeAllowed()
return cmCTest::MaxDuration();
}
- auto timelimit = std::chrono::duration<double>(atof(timelimitS));
+ auto timelimit = cmDuration(atof(timelimitS));
- auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(
+ auto duration = std::chrono::duration_cast<cmDuration>(
std::chrono::steady_clock::now() - this->ScriptStartTime);
return (timelimit - duration);
}
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 9b7fa75..ea5d5af 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
#include <chrono>
#include <string>
@@ -96,7 +97,7 @@ public:
* seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
* not been set it returns a very large value.
*/
- std::chrono::duration<double> GetRemainingTimeAllowed();
+ cmDuration GetRemainingTimeAllowed();
cmCTestScriptHandler();
~cmCTestScriptHandler() override;
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 86fee7a..1ce2b6f 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -16,6 +16,7 @@
#include "cmCTestScriptHandler.h"
#include "cmCryptoHash.h"
#include "cmCurl.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmProcessOutput.h"
#include "cmState.h"
@@ -497,7 +498,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
? ""
: this->GetOption("RetryCount");
- auto delay = std::chrono::duration<double>(
+ auto delay = cmDuration(
retryDelay.empty()
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
.c_str())
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index 232bd58..daedf62 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -4,6 +4,7 @@
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
@@ -37,12 +38,12 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
const char* ctestTimeout =
this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
- std::chrono::duration<double> timeout;
+ cmDuration timeout;
if (ctestTimeout) {
- timeout = std::chrono::duration<double>(atof(ctestTimeout));
+ timeout = cmDuration(atof(ctestTimeout));
} else {
timeout = this->CTest->GetTimeOut();
- if (timeout <= std::chrono::duration<double>::zero()) {
+ if (timeout <= cmDuration::zero()) {
// By default use timeout of 10 minutes
timeout = std::chrono::minutes(10);
}
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 4c7cefb..ce7c194 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -21,6 +21,7 @@
#include "cmCTest.h"
#include "cmCTestMultiProcessHandler.h"
#include "cmCommand.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -346,7 +347,7 @@ void cmCTestTestHandler::Initialize()
{
this->Superclass::Initialize();
- this->ElapsedTestingTime = std::chrono::duration<double>();
+ this->ElapsedTestingTime = cmDuration();
this->TestResults.clear();
@@ -539,7 +540,7 @@ int cmCTestTestHandler::ProcessHandler()
this->PrintLabelOrSubprojectSummary(false);
}
char realBuf[1024];
- std::chrono::duration<double> durationInSecs = clock_finish - clock_start;
+ cmDuration durationInSecs = clock_finish - clock_start;
sprintf(realBuf, "%6.2f sec", durationInSecs.count());
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"\nTotal Test time (real) = " << realBuf << "\n",
@@ -1235,9 +1236,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
p.Cost = static_cast<float>(rand());
}
- if (p.Timeout == std::chrono::duration<double>::zero() &&
- this->CTest->GetGlobalTimeout() !=
- std::chrono::duration<double>::zero()) {
+ if (p.Timeout == cmDuration::zero() &&
+ this->CTest->GetGlobalTimeout() != cmDuration::zero()) {
p.Timeout = this->CTest->GetGlobalTimeout();
}
@@ -2140,7 +2140,7 @@ bool cmCTestTestHandler::SetTestsProperties(
rt.FixturesRequired.insert(lval.begin(), lval.end());
}
if (key == "TIMEOUT") {
- rt.Timeout = std::chrono::duration<double>(atof(val.c_str()));
+ rt.Timeout = cmDuration(atof(val.c_str()));
rt.ExplicitTimeout = true;
}
if (key == "COST") {
@@ -2220,8 +2220,7 @@ bool cmCTestTestHandler::SetTestsProperties(
"TIMEOUT_AFTER_MATCH expects two arguments, found "
<< propArgs.size() << std::endl);
} else {
- rt.AlternateTimeout =
- std::chrono::duration<double>(atof(propArgs[0].c_str()));
+ rt.AlternateTimeout = cmDuration(atof(propArgs[0].c_str()));
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(propArgs[1], lval);
for (std::string const& cr : lval) {
@@ -2339,7 +2338,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.WillFail = false;
test.Disabled = false;
test.RunSerial = false;
- test.Timeout = std::chrono::duration<double>::zero();
+ test.Timeout = cmDuration::zero();
test.ExplicitTimeout = false;
test.Cost = 0;
test.Processors = 1;
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 4fb067a..f4978b6 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
#include "cmsys/RegularExpression.hxx"
#include <chrono>
@@ -123,9 +124,9 @@ public:
float Cost;
int PreviousRuns;
bool RunSerial;
- std::chrono::duration<double> Timeout;
+ cmDuration Timeout;
bool ExplicitTimeout;
- std::chrono::duration<double> AlternateTimeout;
+ cmDuration AlternateTimeout;
int Index;
// Requested number of process slots
int Processors;
@@ -146,7 +147,7 @@ public:
std::string Path;
std::string Reason;
std::string FullCommandLine;
- std::chrono::duration<double> ExecutionTime;
+ cmDuration ExecutionTime;
int ReturnValue;
int Status;
std::string ExceptionStatus;
@@ -198,7 +199,7 @@ protected:
//! Clean test output to specified length
bool CleanTestOutput(std::string& output, size_t length);
- std::chrono::duration<double> ElapsedTestingTime;
+ cmDuration ElapsedTestingTime;
typedef std::vector<cmCTestTestResult> TestResultsVector;
TestResultsVector TestResults;
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index e332a77..09ed0a9 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -62,8 +62,8 @@ cmProcess::cmProcess(cmCTestRunTest& runner)
: Runner(runner)
, Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE)
{
- this->Timeout = std::chrono::duration<double>::zero();
- this->TotalTime = std::chrono::duration<double>::zero();
+ this->Timeout = cmDuration::zero();
+ this->TotalTime = cmDuration::zero();
this->ExitValue = 0;
this->Id = 0;
this->StartTime = std::chrono::steady_clock::time_point();
@@ -344,8 +344,8 @@ void cmProcess::OnExit(int64_t exit_status, int term_signal)
// negative. If someone changed the system clock while the process was
// running this may be even more. Make sure not to report a negative
// duration here.
- if (this->TotalTime <= std::chrono::duration<double>::zero()) {
- this->TotalTime = std::chrono::duration<double>::zero();
+ if (this->TotalTime <= cmDuration::zero()) {
+ this->TotalTime = cmDuration::zero();
}
this->ProcessHandleClosed = true;
@@ -360,7 +360,7 @@ cmProcess::State cmProcess::GetProcessStatus()
return this->ProcessState;
}
-void cmProcess::ChangeTimeout(std::chrono::duration<double> t)
+void cmProcess::ChangeTimeout(cmDuration t)
{
this->Timeout = t;
this->StartTimer();
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 633be24..20e24b9 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -4,6 +4,7 @@
#define cmProcess_h
#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cmUVHandlePtr.h"
@@ -31,8 +32,8 @@ public:
void SetCommand(const char* command);
void SetCommandArguments(std::vector<std::string> const& arg);
void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
- void SetTimeout(std::chrono::duration<double> t) { this->Timeout = t; }
- void ChangeTimeout(std::chrono::duration<double> t);
+ void SetTimeout(cmDuration t) { this->Timeout = t; }
+ void ChangeTimeout(cmDuration t);
void ResetStartTime();
// Return true if the process starts
bool StartProcess(uv_loop_t& loop);
@@ -53,7 +54,7 @@ public:
int GetId() { return this->Id; }
void SetId(int id) { this->Id = id; }
int GetExitValue() { return this->ExitValue; }
- std::chrono::duration<double> GetTotalTime() { return this->TotalTime; }
+ cmDuration GetTotalTime() { return this->TotalTime; }
enum class Exception
{
@@ -69,9 +70,9 @@ public:
std::string GetExitExceptionString();
private:
- std::chrono::duration<double> Timeout;
+ cmDuration Timeout;
std::chrono::steady_clock::time_point StartTime;
- std::chrono::duration<double> TotalTime;
+ cmDuration TotalTime;
bool ReadHandleClosed = false;
bool ProcessHandleClosed = false;
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index fd7c5e8..4be02ed 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -277,8 +277,8 @@ cmCTest::cmCTest()
this->TestModel = cmCTest::EXPERIMENTAL;
this->MaxTestNameWidth = 30;
this->InteractiveDebugMode = true;
- this->TimeOut = std::chrono::duration<double>::zero();
- this->GlobalTimeout = std::chrono::duration<double>::zero();
+ this->TimeOut = cmDuration::zero();
+ this->GlobalTimeout = cmDuration::zero();
this->CompressXMLFiles = false;
this->ScheduleType.clear();
this->OutputLogFile = nullptr;
@@ -954,8 +954,7 @@ int cmCTest::GetTestModelFromString(const char* str)
//######################################################################
int cmCTest::RunMakeCommand(const char* command, std::string& output,
- int* retVal, const char* dir,
- std::chrono::duration<double> timeout,
+ int* retVal, const char* dir, cmDuration timeout,
std::ostream& ofs, Encoding encoding)
{
// First generate the command and arguments
@@ -1071,28 +1070,26 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
//######################################################################
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
- int* retVal, std::ostream* log,
- std::chrono::duration<double> testTimeOut,
+ int* retVal, std::ostream* log, cmDuration testTimeOut,
std::vector<std::string>* environment, Encoding encoding)
{
bool modifyEnv = (environment && !environment->empty());
// determine how much time we have
- std::chrono::duration<double> timeout = this->GetRemainingTimeAllowed();
+ cmDuration timeout = this->GetRemainingTimeAllowed();
if (timeout != cmCTest::MaxDuration()) {
timeout -= std::chrono::minutes(2);
}
- if (this->TimeOut > std::chrono::duration<double>::zero() &&
- this->TimeOut < timeout) {
+ if (this->TimeOut > cmDuration::zero() && this->TimeOut < timeout) {
timeout = this->TimeOut;
}
- if (testTimeOut > std::chrono::duration<double>::zero() &&
+ if (testTimeOut > cmDuration::zero() &&
testTimeOut < this->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
}
// always have at least 1 second if we got to here
- if (timeout <= std::chrono::duration<double>::zero()) {
+ if (timeout <= cmDuration::zero()) {
timeout = std::chrono::seconds(1);
}
cmCTestLog(
@@ -1121,7 +1118,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
// good place to check for it, and to add the arguments in
if (strcmp(i, "--build-generator") == 0 &&
timeout != cmCTest::MaxDuration() &&
- timeout > std::chrono::duration<double>::zero()) {
+ timeout > cmDuration::zero()) {
args.push_back("--test-timeout");
std::ostringstream msg;
msg << std::chrono::duration_cast<std::chrono::seconds>(timeout)
@@ -1772,7 +1769,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
i++;
- auto timeout = std::chrono::duration<double>(atof(args[i].c_str()));
+ auto timeout = cmDuration(atof(args[i].c_str()));
this->GlobalTimeout = timeout;
}
@@ -2575,8 +2572,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(
bool cmCTest::RunCommand(std::vector<std::string> const& args,
std::string* stdOut, std::string* stdErr, int* retVal,
- const char* dir,
- std::chrono::duration<double> timeout,
+ const char* dir, cmDuration timeout,
Encoding encoding)
{
std::vector<const char*> argv;
@@ -2788,7 +2784,7 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
}
}
-std::chrono::duration<double> cmCTest::GetRemainingTimeAllowed()
+cmDuration cmCTest::GetRemainingTimeAllowed()
{
if (!this->GetHandler("script")) {
return cmCTest::MaxDuration();
@@ -2800,9 +2796,9 @@ std::chrono::duration<double> cmCTest::GetRemainingTimeAllowed()
return ch->GetRemainingTimeAllowed();
}
-std::chrono::duration<double> cmCTest::MaxDuration()
+cmDuration cmCTest::MaxDuration()
{
- return std::chrono::duration<double>(1.0e7);
+ return cmDuration(1.0e7);
}
void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 61487f1..a4d9a86 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmDuration.h"
#include "cmProcessOutput.h"
#include "cmsys/String.hxx"
#include <chrono>
@@ -140,13 +141,10 @@ public:
/** what is the configuraiton type, e.g. Debug, Release etc. */
std::string const& GetConfigType();
- std::chrono::duration<double> GetTimeOut() { return this->TimeOut; }
- void SetTimeOut(std::chrono::duration<double> t) { this->TimeOut = t; }
+ cmDuration GetTimeOut() { return this->TimeOut; }
+ void SetTimeOut(cmDuration t) { this->TimeOut = t; }
- std::chrono::duration<double> GetGlobalTimeout()
- {
- return this->GlobalTimeout;
- }
+ cmDuration GetGlobalTimeout() { return this->GlobalTimeout; }
/** how many test to run at the same time */
int GetParallelLevel() { return this->ParallelLevel; }
@@ -206,9 +204,9 @@ public:
* seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
* not been set it returns a very large duration.
*/
- std::chrono::duration<double> GetRemainingTimeAllowed();
+ cmDuration GetRemainingTimeAllowed();
- static std::chrono::duration<double> MaxDuration();
+ static cmDuration MaxDuration();
/**
* Open file in the output directory and set the stream
@@ -258,8 +256,7 @@ public:
bool RunCommand(std::vector<std::string> const& args, std::string* stdOut,
std::string* stdErr, int* retVal = nullptr,
const char* dir = nullptr,
- std::chrono::duration<double> timeout =
- std::chrono::duration<double>::zero(),
+ cmDuration timeout = cmDuration::zero(),
Encoding encoding = cmProcessOutput::Auto);
/**
@@ -279,8 +276,7 @@ public:
* and retVal is return value or exception.
*/
int RunMakeCommand(const char* command, std::string& output, int* retVal,
- const char* dir, std::chrono::duration<double> timeout,
- std::ostream& ofs,
+ const char* dir, cmDuration timeout, std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
/** Return the current tag */
@@ -327,7 +323,7 @@ public:
* environment variables are restored to their previous values.
*/
int RunTest(std::vector<const char*> args, std::string* output, int* retVal,
- std::ostream* logfile, std::chrono::duration<double> testTimeOut,
+ std::ostream* logfile, cmDuration testTimeOut,
std::vector<std::string>* environment,
Encoding encoding = cmProcessOutput::Auto);
@@ -508,9 +504,9 @@ private:
int TestModel;
std::string SpecificTrack;
- std::chrono::duration<double> TimeOut;
+ cmDuration TimeOut;
- std::chrono::duration<double> GlobalTimeout;
+ cmDuration GlobalTimeout;
int MaxTestNameWidth;
diff --git a/Source/cmDuration.h b/Source/cmDuration.h
new file mode 100644
index 0000000..5f73585
--- /dev/null
+++ b/Source/cmDuration.h
@@ -0,0 +1,8 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include <chrono>
+#include <ratio>
+
+typedef std::chrono::duration<double, std::ratio<1>> cmDuration;