Create the temporary _coverage dir under bazel-out/.../testlogs.

During test execution, it's normally expected that created files be under
bazel-out. Creating files outside of this directory can have implications
sandboxing and filesystem abstractions.

PiperOrigin-RevId: 453677860
Change-Id: I920951326c05510d449cd147b7b27e2d223e98a2
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java b/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java
index 36e5087..31a6744 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/test/TestRunnerAction.java
@@ -878,14 +878,16 @@
    * or remote execution.
    *
    * <p>Otherwise, the directory name for the given test runner action is constructed as: {@code
-   * _coverage/target_path/test_log_name} where {@code test_log_name} is usually a target name but
-   * potentially can include extra suffix, such as a shard number (if test execution was sharded).
+   * [blaze-out/.../testlogs/]_coverage/target_path/test_log_name} where {@code test_log_name} is
+   * usually a target name but potentially can include extra suffix, such as a shard number (if test
+   * execution was sharded).
    */
   public PathFragment getCoverageDirectory() {
     if (coverageDirectory != null) {
       return coverageDirectory.getExecPath();
     }
-    return COVERAGE_TMP_ROOT.getRelative(
+    PathFragment coverageRoot = getTestLog().getRoot().getExecPath().getRelative(COVERAGE_TMP_ROOT);
+    return coverageRoot.getRelative(
         FileSystemUtils.removeExtension(getTestLog().getRootRelativePath()));
   }