Add status details to the protos

Both for the build event stream proto, which contains the TestResult event,
and to the test status proto which is used for caching. The new field may be
populated in the future.

PiperOrigin-RevId: 199846232
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
index 8543980..1323584 100644
--- a/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
+++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto
@@ -499,6 +499,10 @@
   // The status of this test.
   TestStatus status = 5;
 
+  // Additional details about the status of the test. This is intended for
+  // user display and must not be parsed.
+  string status_details = 9;
+
   // True, if the reported attempt is taken from the tool's local cache.
   bool cached_locally = 4;
 
diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java b/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
index ed70ad2..deec19e 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/TestAttempt.java
@@ -42,6 +42,7 @@
 
   private final TestRunnerAction testAction;
   private final TestStatus status;
+  private final String statusDetails;
   private final boolean cachedLocally;
   private final int attempt;
   private final boolean lastAttempt;
@@ -64,6 +65,7 @@
       BuildEventStreamProtos.TestResult.ExecutionInfo executionInfo,
       int attempt,
       BlazeTestStatus status,
+      String statusDetails,
       long startTimeMillis,
       long durationMillis,
       Collection<Pair<String, Path>> files,
@@ -73,6 +75,7 @@
     this.executionInfo = Preconditions.checkNotNull(executionInfo);
     this.attempt = attempt;
     this.status = BuildEventStreamerUtils.bepStatus(Preconditions.checkNotNull(status));
+    this.statusDetails = statusDetails;
     this.cachedLocally = cachedLocally;
     this.startTimeMillis = startTimeMillis;
     this.durationMillis = durationMillis;
@@ -98,6 +101,7 @@
         executionInfo,
         attempt,
         attemptData.getStatus(),
+        attemptData.getStatusDetails(),
         attemptData.getStartTimeMillisEpoch(),
         attemptData.getRunDurationMillis(),
         files,
@@ -118,6 +122,7 @@
         executionInfo,
         attempt,
         attemptData.getStatus(),
+        attemptData.getStatusDetails(),
         attemptData.getStartTimeMillisEpoch(),
         attemptData.getRunDurationMillis(),
         files,
@@ -184,10 +189,16 @@
 
   @Override
   public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventContext converters) {
+    return GenericBuildEvent.protoChaining(this).setTestResult(asTestResult(converters)).build();
+  }
+
+  @VisibleForTesting
+  public BuildEventStreamProtos.TestResult asTestResult(BuildEventContext converters) {
     PathConverter pathConverter = converters.pathConverter();
     BuildEventStreamProtos.TestResult.Builder builder =
         BuildEventStreamProtos.TestResult.newBuilder();
     builder.setStatus(status);
+    builder.setStatusDetails(statusDetails);
     builder.setExecutionInfo(executionInfo);
     builder.setCachedLocally(cachedLocally);
     builder.setTestAttemptStartMillisEpoch(startTimeMillis);
@@ -200,6 +211,6 @@
               .setUri(pathConverter.apply(file.getSecond()))
               .build());
     }
-    return GenericBuildEvent.protoChaining(this).setTestResult(builder.build()).build();
+    return builder.build();
   }
 }
diff --git a/src/main/protobuf/test_status.proto b/src/main/protobuf/test_status.proto
index fc7f6c7..72cb268 100644
--- a/src/main/protobuf/test_status.proto
+++ b/src/main/protobuf/test_status.proto
@@ -82,6 +82,7 @@
 
   // Following data is informational.
   optional BlazeTestStatus status = 3 [default = NO_STATUS];
+  optional string status_details = 16;
   repeated string failed_logs = 4;
   repeated string warning = 5;
   optional bool has_coverage = 6;