mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
ctest: Convert StartTestTime field in Test.xml to seconds
In commit fd55647d16 (ctest: Record `StartTestTime` entry for each test
in Test.xml, 2026-02-12) we added the field with milliseconds to match
instrumentation. However, all other times reported by CTest are in
seconds, including the global `StartTestTime` field. Preserve
sub-second resolution using a floating-point representation.
Issue: #26859
This commit is contained in:
@@ -366,8 +366,7 @@ cmCTestRunTest::EndTestResult cmCTestRunTest::EndTest(size_t completed,
|
||||
this->TestResult.CompletionStatus = "Completed";
|
||||
}
|
||||
this->TestResult.StartTestTime =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
this->TestProcess->GetSystemStartTime().time_since_epoch());
|
||||
this->TestProcess->GetSystemStartTime().time_since_epoch();
|
||||
this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
|
||||
this->MemCheckPostProcess();
|
||||
this->ComputeWeightedCost();
|
||||
|
||||
@@ -652,6 +652,12 @@ bool cmCTestTestHandler::GenerateXML()
|
||||
this->LogFile = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// We represent some times as a double-precision floating-point number
|
||||
// of seconds since the epoch. Print them with microsecond precision.
|
||||
// Representable values differ by hundreds of nanoseconds anyway.
|
||||
xmlfile << std::fixed << std::setprecision(6);
|
||||
|
||||
cmXMLWriter xml(xmlfile);
|
||||
this->GenerateCTestXML(xml);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
std::string TestMeasurementsOutput;
|
||||
std::string InstrumentationFile;
|
||||
int TestCount = 0;
|
||||
std::chrono::milliseconds StartTestTime;
|
||||
cmDuration StartTestTime;
|
||||
cmCTestTestProperties* Properties = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cmDuration.h"
|
||||
#include "cmXMLSafe.h"
|
||||
|
||||
class cmXMLWriter
|
||||
@@ -113,10 +114,8 @@ private:
|
||||
return std::chrono::system_clock::to_time_t(value);
|
||||
}
|
||||
|
||||
static long long SafeContent(std::chrono::milliseconds value)
|
||||
{
|
||||
return value.count();
|
||||
}
|
||||
/* Some code paths use time_since_epoch despite the unspecified epoch. */
|
||||
static double SafeContent(cmDuration value) { return value.count(); }
|
||||
|
||||
template <typename T>
|
||||
static T SafeContent(T value)
|
||||
|
||||
Reference in New Issue
Block a user