Reuse the pre-computed spawnSummary.
Add an integration test for remote cache hits status line.

RELNOTES: None.
PiperOrigin-RevId: 222621275
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
index 8666ce9..6c7a4d7 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BuildSummaryStatsModule.java
@@ -140,7 +140,7 @@
 
       String spawnSummary = spawnStats.getSummary();
       if (statsSummary) {
-        reporter.handle(Event.info(spawnStats.getSummary()));
+        reporter.handle(Event.info(spawnSummary));
         reporter.handle(
             Event.info(
                 String.format(
diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh
index b51698a..f28f4db 100755
--- a/src/test/shell/bazel/remote/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote/remote_execution_test.sh
@@ -149,6 +149,30 @@
       || fail "Remote cache generated different result"
 }
 
+function test_cc_binary_grpc_cache_statsline() {
+  mkdir -p a
+  cat > a/BUILD <<EOF
+package(default_visibility = ["//visibility:public"])
+cc_binary(
+name = 'test',
+srcs = [ 'test.cc' ],
+)
+EOF
+  cat > a/test.cc <<EOF
+#include <iostream>
+int main() { std::cout << "Hello world!" << std::endl; return 0; }
+EOF
+  bazel build \
+      --remote_cache=localhost:${worker_port} \
+      //a:test >& $TEST_log \
+      || fail "Failed to build //a:test with remote gRPC cache service"
+  bazel clean --expunge >& $TEST_log
+  bazel build \
+      --remote_cache=localhost:${worker_port} \
+      //a:test 2>&1 | tee $TEST_log | grep "remote cache hit" \
+      || fail "Output does not contain remote cache hits"
+}
+
 function test_failing_cc_test() {
   mkdir -p a
   cat > a/BUILD <<EOF