diff options
author | Wouter Klouwen <wouter.klouwen@youview.com> | 2017-11-20 20:55:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-12-04 15:43:14 (GMT) |
commit | 66419bc04620c5748df77e2b563d65b0e97b623a (patch) | |
tree | 0c6e38ba923c4eb95c3d5d829c83a849d58eb52a /Source/CTest/cmCTestTestHandler.cxx | |
parent | 923b8fadd5fe6af56197cf3916a3292b60c0e8db (diff) | |
download | CMake-66419bc04620c5748df77e2b563d65b0e97b623a.zip CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.gz CMake-66419bc04620c5748df77e2b563d65b0e97b623a.tar.bz2 |
CTest: convert timeouts to std::chrono::duration
This commit continues the refactoring of CTest to adopt std::chrono.
After the last sets of changes that introduced std::chrono::steady_clock
and std::chrono::system_clock respectively, it makes sense to have all
the timeouts be stored as std::chrono::duration.
No functional change intended.
Diffstat (limited to 'Source/CTest/cmCTestTestHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 6d8180c..1e15cc5 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -653,7 +653,11 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject) for (std::string const& l : p.Labels) { // only use labels found in labels if (labels.find(l) != labels.end()) { - labelTimes[l] += result.ExecutionTime * result.Properties->Processors; + labelTimes[l] += + double(std::chrono::duration_cast<std::chrono::milliseconds>( + result.ExecutionTime) + .count()) / + 1000.0 * result.Properties->Processors; ++labelCounts[l]; } } @@ -1239,7 +1243,9 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, p.Cost = static_cast<float>(rand()); } - if (p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) { + if (p.Timeout == std::chrono::duration<double>::zero() && + this->CTest->GetGlobalTimeout() != + std::chrono::duration<double>::zero()) { p.Timeout = this->CTest->GetGlobalTimeout(); } @@ -1321,7 +1327,11 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml) xml.StartElement("NamedMeasurement"); xml.Attribute("type", "numeric/double"); xml.Attribute("name", "Execution Time"); - xml.Element("Value", result.ExecutionTime); + xml.Element("Value", + double(std::chrono::duration_cast<std::chrono::milliseconds>( + result.ExecutionTime) + .count()) / + 1000.0); xml.EndElement(); // NamedMeasurement if (!result.Reason.empty()) { const char* reasonType = "Pass Reason"; @@ -2142,7 +2152,7 @@ bool cmCTestTestHandler::SetTestsProperties( rt.FixturesRequired.insert(lval.begin(), lval.end()); } if (key == "TIMEOUT") { - rt.Timeout = atof(val.c_str()); + rt.Timeout = std::chrono::duration<double>(atof(val.c_str())); rt.ExplicitTimeout = true; } if (key == "COST") { @@ -2222,7 +2232,8 @@ bool cmCTestTestHandler::SetTestsProperties( "TIMEOUT_AFTER_MATCH expects two arguments, found " << propArgs.size() << std::endl); } else { - rt.AlternateTimeout = atof(propArgs[0].c_str()); + rt.AlternateTimeout = + std::chrono::duration<double>(atof(propArgs[0].c_str())); std::vector<std::string> lval; cmSystemTools::ExpandListArgument(propArgs[1], lval); for (std::string const& cr : lval) { @@ -2340,7 +2351,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) test.WillFail = false; test.Disabled = false; test.RunSerial = false; - test.Timeout = 0; + test.Timeout = std::chrono::duration<double>::zero(); test.ExplicitTimeout = false; test.Cost = 0; test.Processors = 1; |