Skip to content

Commit

Permalink
Only set test_attempt_start and test_attempt_duration if a test w…
Browse files Browse the repository at this point in the history
…as run.

Fixes a defect in bazelbuild@db4c550 (commit db4c550) which leads to `TestResult` protobufs containing a default-value `Timestamp`. This `Timestamp` is a valid representation of the UNIX epoch. To ensure downstream consumers do not need to special-case this `Timestamp` we should take care not to produce this value unless a test actually starts/ends at the UNIX epoch.

PiperOrigin-RevId: 668155710
Change-Id: Iaf6fa56a5b572e1416cfda61b94328f7a7fb83bc
  • Loading branch information
michaeledgar authored and copybara-github committed Aug 27, 2024
1 parent 17aa900 commit 2d12615
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,13 @@ public BuildEventStreamProtos.TestResult asTestResult(BuildEventContext converte
builder.setStatusDetails(statusDetails);
builder.setExecutionInfo(executionInfo);
builder.setCachedLocally(cachedLocally);
builder.setTestAttemptStart(Timestamps.fromMillis(startTimeMillis));
if (startTimeMillis != 0) {
builder.setTestAttemptStart(Timestamps.fromMillis(startTimeMillis));
}
builder.setTestAttemptStartMillisEpoch(startTimeMillis);
builder.setTestAttemptDuration(Durations.fromMillis(durationMillis));
if (durationMillis != 0) {
builder.setTestAttemptDuration(Durations.fromMillis(durationMillis));
}
builder.setTestAttemptDurationMillis(durationMillis);
builder.addAllWarning(testWarnings);
for (Pair<String, Path> file : files) {
Expand Down

0 comments on commit 2d12615

Please sign in to comment.