summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx19
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h3
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx3
-rw-r--r--Source/CTest/cmCTestRunTest.cxx20
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx11
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx17
-rw-r--r--Source/CTest/cmProcess.cxx19
-rw-r--r--Source/CTest/cmProcess.h7
-rw-r--r--Source/cmCTest.cxx30
-rw-r--r--Source/cmCTest.h2
10 files changed, 42 insertions, 89 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 <chrono>
+#include <ratio>
#include <stdlib.h>
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<double>::zero();
}
void cmCTestBuildAndTestHandler::Initialize()
@@ -224,10 +225,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
for (std::string const& tar : this->BuildTargets) {
std::chrono::duration<double> remainingTime = std::chrono::seconds(0);
- if (this->Timeout > 0) {
- remainingTime = std::chrono::duration<double>(this->Timeout) -
- std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::steady_clock::now() - clock_start);
+ if (this->Timeout > std::chrono::duration<double>::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<double> remainingTime = std::chrono::seconds(0);
- if (this->Timeout > 0) {
- remainingTime = std::chrono::duration<double>(this->Timeout) -
- std::chrono::duration_cast<std::chrono::seconds>(
- std::chrono::steady_clock::now() - clock_start);
+ if (this->Timeout > std::chrono::duration<double>::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<double>(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 <chrono>
#include <sstream>
#include <stddef.h>
#include <string>
@@ -67,7 +68,7 @@ protected:
std::vector<std::string> TestCommandArgs;
std::vector<std::string> BuildTargets;
bool BuildNoCMake;
- double Timeout;
+ std::chrono::duration<double> Timeout;
};
#endif
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 39b90d8..2a9fd72 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -11,7 +11,6 @@
#include "cmParseGTMCoverage.h"
#include "cmParseJacocoCoverage.h"
#include "cmParsePHPCoverage.h"
-#include "cmProcess.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
@@ -81,7 +80,7 @@ public:
cmsysProcess_SetOption(this->Process, cmsysProcess_Option_HideWindow, 1);
if (this->TimeOut >= std::chrono::duration<double>::zero()) {
- cmsysProcess_SetTimeout(this->Process, this->TimeOut);
+ cmsysProcess_SetTimeout(this->Process, this->TimeOut.count());
}
cmsysProcess_Execute(this->Process);
this->PipeState = cmsysProcess_GetState(this->Process);
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 7013db3..dbdefae 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -1,9 +1,5 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#ifdef _WIN32
-/* windows.h defines min() and max() macros that interfere. */
-#define NOMINMAX
-#endif
#include "cmCTestRunTest.h"
#include "cmCTest.h"
@@ -265,11 +261,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
char buf[1024];
- sprintf(buf, "%6.2f sec",
- double(std::chrono::duration_cast<std::chrono::milliseconds>(
- this->TestProcess->GetTotalTime())
- .count()) /
- 1000.0);
+ sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime().count());
cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n");
if (outputTestErrorsToConsole) {
@@ -394,11 +386,7 @@ void cmCTestRunTest::ComputeWeightedCost()
{
double prev = static_cast<double>(this->TestProperties->PreviousRuns);
double avgcost = static_cast<double>(this->TestProperties->Cost);
- double current =
- double(std::chrono::duration_cast<std::chrono::milliseconds>(
- this->TestResult.ExecutionTime)
- .count()) /
- 1000.0;
+ double current = this->TestResult.ExecutionTime.count();
if (this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
this->TestProperties->Cost =
@@ -690,7 +678,7 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
// determine how much time we have
std::chrono::duration<double> timeout =
this->CTest->GetRemainingTimeAllowed();
- if (timeout != std::chrono::duration<double>::max()) {
+ if (timeout != cmCTest::MaxDuration()) {
timeout -= std::chrono::minutes(2);
}
if (this->CTest->GetTimeOut() > std::chrono::duration<double>::zero() &&
@@ -714,7 +702,7 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
<< ": "
<< "Test timeout computed to be: "
- << (timeout == std::chrono::duration<double>::max()
+ << (timeout == cmCTest::MaxDuration()
? std::string("infinite")
: std::to_string(
std::chrono::duration_cast<std::chrono::seconds>(timeout)
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 922f5c7..716ea10 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -1,12 +1,5 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-
-#ifdef _WIN32
-/* windows.h defines min() and max() macros, unless told to otherwise. This
- * interferes with std::min() and std::max() at the very least. */
-#define NOMINMAX
-#endif
-
#include "cmCTestScriptHandler.h"
#include "cmsys/Directory.hxx"
@@ -970,13 +963,13 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
std::chrono::duration<double> cmCTestScriptHandler::GetRemainingTimeAllowed()
{
if (!this->Makefile) {
- return std::chrono::duration<double>::max();
+ return cmCTest::MaxDuration();
}
const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
if (!timelimitS) {
- return std::chrono::duration<double>::max();
+ return cmCTest::MaxDuration();
}
auto timelimit = std::chrono::duration<double>(atof(timelimitS));
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 9819899..4c7cefb 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -539,10 +539,8 @@ int cmCTestTestHandler::ProcessHandler()
this->PrintLabelOrSubprojectSummary(false);
}
char realBuf[1024];
- auto durationInMs = std::chrono::duration_cast<std::chrono::milliseconds>(
- clock_finish - clock_start)
- .count();
- sprintf(realBuf, "%6.2f sec", static_cast<double>(durationInMs) / 1000.0);
+ std::chrono::duration<double> durationInSecs = clock_finish - clock_start;
+ sprintf(realBuf, "%6.2f sec", durationInSecs.count());
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"\nTotal Test time (real) = " << realBuf << "\n",
this->Quiet);
@@ -653,10 +651,7 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
// only use labels found in labels
if (labels.find(l) != labels.end()) {
labelTimes[l] +=
- double(std::chrono::duration_cast<std::chrono::milliseconds>(
- result.ExecutionTime)
- .count()) /
- 1000.0 * result.Properties->Processors;
+ result.ExecutionTime.count() * result.Properties->Processors;
++labelCounts[l];
}
}
@@ -1324,11 +1319,7 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "numeric/double");
xml.Attribute("name", "Execution Time");
- xml.Element("Value",
- double(std::chrono::duration_cast<std::chrono::milliseconds>(
- result.ExecutionTime)
- .count()) /
- 1000.0);
+ xml.Element("Value", result.ExecutionTime.count());
xml.EndElement(); // NamedMeasurement
if (!result.Reason.empty()) {
const char* reasonType = "Pass Reason";
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 69ffb33..0db66c3 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -5,16 +5,6 @@
#include "cmProcessOutput.h"
#include <iostream>
-void cmsysProcess_SetTimeout(cmsysProcess* process,
- std::chrono::duration<double> timeout)
-{
- cmsysProcess_SetTimeout(
- process,
- double(
- std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count()) /
- 1000.0);
-};
-
cmProcess::cmProcess()
{
this->Process = nullptr;
@@ -59,7 +49,7 @@ bool cmProcess::StartProcess()
cmsysProcess_SetWorkingDirectory(this->Process,
this->WorkingDirectory.c_str());
}
- cmsysProcess_SetTimeout(this->Process, this->Timeout);
+ cmsysProcess_SetTimeout(this->Process, this->Timeout.count());
cmsysProcess_SetOption(this->Process, cmsysProcess_Option_MergeOutput, 1);
cmsysProcess_Execute(this->Process);
return (cmsysProcess_GetState(this->Process) ==
@@ -115,10 +105,7 @@ int cmProcess::GetNextOutputLine(std::string& line,
{
cmProcessOutput processOutput(cmProcessOutput::UTF8);
std::string strdata;
- double waitTimeout =
- double(
- std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count()) /
- 1000.0;
+ double waitTimeout = timeout.count();
for (;;) {
// Look for lines already buffered.
if (this->Output.GetLine(line)) {
@@ -240,7 +227,7 @@ int cmProcess::ReportStatus()
void cmProcess::ChangeTimeout(std::chrono::duration<double> t)
{
this->Timeout = t;
- cmsysProcess_SetTimeout(this->Process, this->Timeout);
+ cmsysProcess_SetTimeout(this->Process, this->Timeout.count());
}
void cmProcess::ResetStartTime()
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index cbb611d..f3b0bd7 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -10,13 +10,6 @@
#include <string>
#include <vector>
-/*
- * A wrapper function for cmsysProcess_SetTimeout that takes an
- * std::chrono::duration. For convenience only.
- */
-void cmsysProcess_SetTimeout(cmsysProcess* process,
- std::chrono::duration<double> timeout);
-
/** \class cmProcess
* \brief run a process with c++
*
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index f5ddc23..26e1dcb 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1,11 +1,5 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#ifdef _WIN32
-/* windows.h defines min() and max() macros by default. This interferes with
- * C++ functions names.
- */
-#define NOMINMAX
-#endif
#include "cmCTest.h"
#include "cm_curl.h"
@@ -50,7 +44,6 @@
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
-#include "cmProcess.h"
#include "cmProcessOutput.h"
#include "cmState.h"
#include "cmStateSnapshot.h"
@@ -997,7 +990,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
cmsysProcess_SetCommand(cp, &*argv.begin());
cmsysProcess_SetWorkingDirectory(cp, dir);
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
// Initialize tick's
@@ -1088,9 +1081,10 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
bool modifyEnv = (environment && !environment->empty());
// determine how much time we have
- std::chrono::duration<double> timeout =
- std::min<std::chrono::duration<double>>(this->GetRemainingTimeAllowed(),
- std::chrono::minutes(2));
+ std::chrono::duration<double> timeout = this->GetRemainingTimeAllowed();
+ if (timeout != cmCTest::MaxDuration()) {
+ timeout -= std::chrono::minutes(2);
+ }
if (this->TimeOut > std::chrono::duration<double>::zero() &&
this->TimeOut < timeout) {
timeout = this->TimeOut;
@@ -1106,7 +1100,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
}
cmCTestLog(
this, HANDLER_VERBOSE_OUTPUT, "Test timeout computed to be: "
- << (timeout == std::chrono::duration<double>::max()
+ << (timeout == cmCTest::MaxDuration()
? std::string("infinite")
: std::to_string(
std::chrono::duration_cast<std::chrono::seconds>(timeout)
@@ -1129,6 +1123,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
// invocations. Since --build-generator is required this is a
// 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()) {
args.push_back("--test-timeout");
std::ostringstream msg;
@@ -1183,7 +1178,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
}
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
char* data;
@@ -2604,7 +2599,7 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
}
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
std::vector<char> tempOutput;
@@ -2800,7 +2795,7 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
std::chrono::duration<double> cmCTest::GetRemainingTimeAllowed()
{
if (!this->GetHandler("script")) {
- return std::chrono::duration<double>::max();
+ return cmCTest::MaxDuration();
}
cmCTestScriptHandler* ch =
@@ -2809,6 +2804,11 @@ std::chrono::duration<double> cmCTest::GetRemainingTimeAllowed()
return ch->GetRemainingTimeAllowed();
}
+std::chrono::duration<double> cmCTest::MaxDuration()
+{
+ return std::chrono::duration<double>(1.0e7);
+}
+
void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
{
std::string test_outputs("\n*** Test Failed:\n");
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 44a6350..23d71cb 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -208,6 +208,8 @@ public:
*/
std::chrono::duration<double> GetRemainingTimeAllowed();
+ static std::chrono::duration<double> MaxDuration();
+
/**
* Open file in the output directory and set the stream
*/