diff options
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.cxx | 9 | ||||
-rw-r--r-- | Source/CTest/cmCTestBuildHandler.h | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestConfigureHandler.cxx | 7 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 16 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 4 | ||||
-rw-r--r-- | Source/CTest/cmCTestUpdateHandler.cxx | 5 | ||||
-rw-r--r-- | Source/cmCTest.cxx | 4 | ||||
-rw-r--r-- | Source/cmXMLWriter.h | 18 |
10 files changed, 44 insertions, 33 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 4ad4831..f25c9c3 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -407,7 +407,7 @@ int cmCTestBuildHandler::ProcessHandler() // Remember start build time this->StartBuild = this->CTest->CurrentTime(); - this->StartBuildTime = cmSystemTools::GetTime(); + this->StartBuildTime = std::chrono::system_clock::now(); int retVal = 0; int res = cmsysProcess_State_Exited; if (!this->CTest->GetShowOnly()) { @@ -421,7 +421,7 @@ int cmCTestBuildHandler::ProcessHandler() // Remember end build time and calculate elapsed time this->EndBuild = this->CTest->CurrentTime(); - this->EndBuildTime = cmSystemTools::GetTime(); + this->EndBuildTime = std::chrono::system_clock::now(); auto elapsed_build_time = std::chrono::steady_clock::now() - elapsed_time_start; @@ -488,8 +488,7 @@ void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml) this->CTest->GenerateSubprojectsOutput(xml); xml.StartElement("Build"); xml.Element("StartDateTime", this->StartBuild); - xml.Element("StartBuildTime", - static_cast<unsigned int>(this->StartBuildTime)); + xml.Element("StartBuildTime", this->StartBuildTime); xml.Element("BuildCommand", this->GetMakeCommand()); } @@ -644,7 +643,7 @@ void cmCTestBuildHandler::GenerateXMLFooter( xml.EndElement(); // Log xml.Element("EndDateTime", this->EndBuild); - xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime)); + xml.Element("EndBuildTime", this->EndBuildTime); xml.Element( "ElapsedMinutes", std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 9a29d6d..d1b9b2e 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -94,8 +94,8 @@ private: std::string StartBuild; std::string EndBuild; - double StartBuildTime; - double EndBuildTime; + std::chrono::system_clock::time_point StartBuildTime; + std::chrono::system_clock::time_point EndBuildTime; std::vector<std::string> CustomErrorMatches; std::vector<std::string> CustomErrorExceptions; diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index e732f9f..ab77986 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -4,7 +4,6 @@ #include "cmCTest.h" #include "cmGeneratedFileStream.h" -#include "cmSystemTools.h" #include "cmXMLWriter.h" #include <chrono> @@ -57,8 +56,7 @@ int cmCTestConfigureHandler::ProcessHandler() return 1; } std::string start_time = this->CTest->CurrentTime(); - unsigned int start_time_time = - static_cast<unsigned int>(cmSystemTools::GetTime()); + auto start_time_time = std::chrono::system_clock::now(); cmGeneratedFileStream ofs; this->StartLogFile("Configure", ofs); @@ -84,8 +82,7 @@ int cmCTestConfigureHandler::ProcessHandler() xml.Element("Log", output); xml.Element("ConfigureStatus", retVal); xml.Element("EndDateTime", this->CTest->CurrentTime()); - xml.Element("EndConfigureTime", - static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("EndConfigureTime", std::chrono::system_clock::now()); xml.Element("ElapsedMinutes", std::chrono::duration_cast<std::chrono::minutes>( std::chrono::steady_clock::now() - elapsed_time_start) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 85f6ce9..bbfe9bd 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -175,14 +175,13 @@ void cmCTestCoverageHandler::StartCoverageLogXML(cmXMLWriter& xml) this->CTest->StartXML(xml, this->AppendXML); xml.StartElement("CoverageLog"); xml.Element("StartDateTime", this->CTest->CurrentTime()); - xml.Element("StartTime", - static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("StartTime", std::chrono::system_clock::now()); } void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml) { xml.Element("EndDateTime", this->CTest->CurrentTime()); - xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("EndTime", std::chrono::system_clock::now()); xml.EndElement(); // CoverageLog this->CTest->EndXML(xml); } @@ -283,8 +282,7 @@ int cmCTestCoverageHandler::ProcessHandler() } std::string coverage_start_time = this->CTest->CurrentTime(); - unsigned int coverage_start_time_time = - static_cast<unsigned int>(cmSystemTools::GetTime()); + auto coverage_start_time_time = std::chrono::system_clock::now(); std::string sourceDir = this->CTest->GetCTestConfiguration("SourceDirectory"); std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory"); @@ -622,8 +620,7 @@ int cmCTestCoverageHandler::ProcessHandler() covSumXML.Element("LOC", total_lines); covSumXML.Element("PercentCoverage", percent_coverage); covSumXML.Element("EndDateTime", end_time); - covSumXML.Element("EndTime", - static_cast<unsigned int>(cmSystemTools::GetTime())); + covSumXML.Element("EndTime", std::chrono::system_clock::now()); covSumXML.Element("ElapsedMinutes", std::chrono::duration_cast<std::chrono::minutes>( std::chrono::steady_clock::now() - elapsed_time_start) @@ -1970,8 +1967,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( std::string coverage_start_time = this->CTest->CurrentTime(); xml.StartElement("Coverage"); xml.Element("StartDateTime", coverage_start_time); - xml.Element("StartTime", - static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("StartTime", std::chrono::system_clock::now()); std::string stdline; std::string errline; // expected output: @@ -2092,7 +2088,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( xml.Element("LOC", total_functions); xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files)); xml.Element("EndDateTime", end_time); - xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("EndTime", std::chrono::system_clock::now()); xml.Element("ElapsedMinutes", std::chrono::duration_cast<std::chrono::minutes>( std::chrono::steady_clock::now() - elapsed_time_start) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 6534fd1..86fee7a 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -1069,6 +1069,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, if (subproject) { str << "subproject=" << curl.Escape(subproject) << "&"; } + auto timeNow = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-" << curl.Escape(this->CTest->GetTestModelString()) << "&" << "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&" @@ -1077,8 +1079,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, << "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&" << "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&" - << "starttime=" << static_cast<int>(cmSystemTools::GetTime()) << "&" - << "endtime=" << static_cast<int>(cmSystemTools::GetTime()) << "&" + << "starttime=" << timeNow << "&" + << "endtime=" << timeNow << "&" << "datafilesmd5[0]=" << md5sum << "&" << "type=" << curl.Escape(typeString); std::string fields = str.str(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b814e35..e7c719c 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1204,7 +1204,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, { this->ComputeTestList(); this->StartTest = this->CTest->CurrentTime(); - this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime()); + this->StartTestTime = std::chrono::system_clock::now(); auto elapsed_time_start = std::chrono::steady_clock::now(); cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs() @@ -1271,7 +1271,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed, } delete parallel; this->EndTest = this->CTest->CurrentTime(); - this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime()); + this->EndTestTime = std::chrono::system_clock::now(); this->ElapsedTestingTime = std::chrono::steady_clock::now() - elapsed_time_start; *this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl; diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index af85e72..8572e7b 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -207,8 +207,8 @@ protected: std::vector<std::string> CustomTestsIgnore; std::string StartTest; std::string EndTest; - unsigned int StartTestTime; - unsigned int EndTestTime; + std::chrono::system_clock::time_point StartTestTime; + std::chrono::system_clock::time_point EndTestTime; bool MemCheck; int CustomMaximumPassedTestOutputSize; int CustomMaximumFailedTestOutputSize; diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 2bd0253..f86d4a3 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -177,8 +177,7 @@ int cmCTestUpdateHandler::ProcessHandler() return -1; } std::string start_time = this->CTest->CurrentTime(); - unsigned int start_time_time = - static_cast<unsigned int>(cmSystemTools::GetTime()); + auto start_time_time = std::chrono::system_clock::now(); auto elapsed_time_start = std::chrono::steady_clock::now(); bool updated = vc->Update(); @@ -226,7 +225,7 @@ int cmCTestUpdateHandler::ProcessHandler() cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet); std::string end_time = this->CTest->CurrentTime(); xml.Element("EndDateTime", end_time); - xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime())); + xml.Element("EndTime", std::chrono::system_clock::now()); xml.Element("ElapsedMinutes", std::chrono::duration_cast<std::chrono::minutes>( std::chrono::steady_clock::now() - elapsed_time_start) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 92da9ab..d358e3d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -12,7 +12,7 @@ #include "cmsys/String.hxx" #include "cmsys/SystemInformation.hxx" #include <algorithm> -#include <cstdint> +#include <chrono> #include <ctype.h> #include <iostream> #include <map> @@ -1418,7 +1418,7 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml, std::string note_time = this->CurrentTime(); xml.StartElement("Note"); xml.Attribute("Name", file); - xml.Element("Time", static_cast<uint64_t>(cmSystemTools::GetTime())); + xml.Element("Time", std::chrono::system_clock::now()); xml.Element("DateTime", note_time); xml.StartElement("Text"); cmsys::ifstream ifs(file.c_str()); diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index 981255d..c890acf 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -7,6 +7,8 @@ #include "cmXMLSafe.h" +#include <chrono> +#include <ctime> #include <ostream> #include <stack> #include <string> @@ -99,6 +101,22 @@ private: return cmXMLSafe(value).Quotes(false); } + /* + * Convert a std::chrono::system::time_point to the number of seconds since + * the UN*X epoch. + * + * It would be tempting to convert a time_point to number of seconds by + * using time_since_epoch(). Unfortunately the C++11 standard does not + * specify what the epoch of the system_clock must be. + * Therefore we must assume it is an arbitary point in time. Instead of this + * method, it is recommended to convert it by means of the to_time_t method. + */ + static std::time_t SafeContent( + std::chrono::system_clock::time_point const& value) + { + return std::chrono::system_clock::to_time_t(value); + } + template <typename T> static T SafeContent(T value) { |