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:
Brad King
2026-02-14 18:39:15 -05:00
parent 91db2be3a1
commit fa69e8348d
4 changed files with 11 additions and 7 deletions
+1 -2
View File
@@ -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();
+6
View File
@@ -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);
}
+1 -1
View File
@@ -194,7 +194,7 @@ public:
std::string TestMeasurementsOutput;
std::string InstrumentationFile;
int TestCount = 0;
std::chrono::milliseconds StartTestTime;
cmDuration StartTestTime;
cmCTestTestProperties* Properties = nullptr;
};
+3 -4
View File
@@ -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)