Compute the list of test output files in TestRunnerAction

This allows us to slightly simplify the renaming logic in StandaloneTestStrategy.

PiperOrigin-RevId: 190645674
diff --git a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
index c3828d3..aa83718 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java
@@ -163,21 +163,7 @@
                 workingDirectory);
       }
       processLastTestAttempt(attempt, dataBuilder, standaloneTestResult.testResultData());
-      ImmutableList.Builder<Pair<String, Path>> testOutputsBuilder = new ImmutableList.Builder<>();
-      if (actionExecutionContext.getInputPath(action.getTestLog()).exists()) {
-        testOutputsBuilder.add(
-            Pair.of(
-                TestFileNameConstants.TEST_LOG,
-                actionExecutionContext.getInputPath(action.getTestLog())));
-      }
-      if (action.getCoverageData() != null
-          && actionExecutionContext.getInputPath(action.getCoverageData()).exists()) {
-        testOutputsBuilder.add(
-            Pair.of(
-                TestFileNameConstants.TEST_COVERAGE,
-                actionExecutionContext.getInputPath(action.getCoverageData())));
-      }
-      testOutputsBuilder.addAll(TestResult.testOutputsFromPaths(resolvedPaths));
+      ImmutableList<Pair<String, Path>> testOutputs = action.getTestOutputsMapping(execRoot);
       actionExecutionContext
           .getEventBus()
           .post(
@@ -187,7 +173,7 @@
                   standaloneTestResult.testResultData().getStatus(),
                   standaloneTestResult.testResultData().getStartTimeMillisEpoch(),
                   standaloneTestResult.testResultData().getRunDurationMillis(),
-                  testOutputsBuilder.build(),
+                  testOutputs,
                   standaloneTestResult.testResultData().getWarningList(),
                   true));
       finalizeTest(actionExecutionContext, action, dataBuilder.build());
@@ -217,39 +203,33 @@
     attemptsDir.createDirectory();
     String attemptPrefix = "attempt_" + attempt;
     Path testLog = attemptsDir.getChild(attemptPrefix + ".log");
-    if (actionExecutionContext.getInputPath(action.getTestLog()).exists()) {
-      actionExecutionContext.getInputPath(action.getTestLog()).renameTo(testLog);
-      testOutputsBuilder.add(Pair.of(TestFileNameConstants.TEST_LOG, testLog));
-    }
-    if (action.getCoverageData() != null
-        && actionExecutionContext.getInputPath(action.getCoverageData()).exists()) {
-      testOutputsBuilder.add(
-          Pair.of(
-              TestFileNameConstants.TEST_COVERAGE,
-              actionExecutionContext.getInputPath(action.getCoverageData())));
-    }
 
     // Get the normal test output paths, and then update them to use "attempt_N" names, and
     // attemptDir, before adding them to the outputs.
-    ResolvedPaths resolvedPaths = action.resolve(actionExecutionContext.getExecRoot());
-    ImmutableList<Pair<String, Path>> testOutputs = TestResult.testOutputsFromPaths(resolvedPaths);
+    ImmutableList<Pair<String, Path>> testOutputs =
+        action.getTestOutputsMapping(actionExecutionContext.getExecRoot());
     for (Pair<String, Path> testOutput : testOutputs) {
       // e.g. /testRoot/test.dir/file, an example we follow throughout this loop's comments.
       Path testOutputPath = testOutput.getSecond();
+      Path destinationPath;
+      if (testOutput.getFirst().equals(TestFileNameConstants.TEST_LOG)) {
+        // The rename rules for the test log are different than for all the other files.
+        destinationPath = testLog;
+      } else {
+        // e.g. test.dir/file
+        PathFragment relativeToTestDirectory = testOutputPath.relativeTo(testRoot);
 
-      // e.g. test.dir/file
-      PathFragment relativeToTestDirectory = testOutputPath.relativeTo(testRoot);
+        // e.g. attempt_1.dir/file
+        String destinationPathFragmentStr =
+            relativeToTestDirectory.getSafePathString().replaceFirst("test", attemptPrefix);
+        PathFragment destinationPathFragment = PathFragment.create(destinationPathFragmentStr);
 
-      // e.g. attempt_1.dir/file
-      String destinationPathFragmentStr =
-          relativeToTestDirectory.getSafePathString().replaceFirst("test", attemptPrefix);
-      PathFragment destinationPathFragment = PathFragment.create(destinationPathFragmentStr);
+        // e.g. /attemptsDir/attempt_1.dir/file
+        destinationPath = attemptsDir.getRelative(destinationPathFragment);
+        destinationPath.getParentDirectory().createDirectory();
+      }
 
-      // e.g. /attemptsDir/attempt_1.dir/file
-      Path destinationPath = attemptsDir.getRelative(destinationPathFragment);
-      destinationPath.getParentDirectory().createDirectory();
-
-      // Copy to the destination.
+      // Move to the destination.
       testOutputPath.renameTo(destinationPath);
 
       testOutputsBuilder.add(Pair.of(testOutput.getFirst(), destinationPath));