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 c0739034e73977..0a1ff9777c7677 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 @@ -406,6 +406,6 @@ private final void finalizeTest( @Override public TestResult newCachedTestResult( Path execRoot, TestRunnerAction action, TestResultData data) { - return new TestResult(action, data, /*cached*/ true); + return new TestResult(action, data, /*cached*/ true, execRoot); } } diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestResult.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestResult.java index 4aa61ada5f7a9f..742ef1f320a098 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/TestResult.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestResult.java @@ -19,6 +19,7 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; +import com.google.devtools.build.lib.rules.test.TestRunnerAction.ResolvedPaths; import com.google.devtools.build.lib.util.Pair; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.Path; @@ -26,6 +27,7 @@ import com.google.devtools.build.lib.view.test.TestStatus.BlazeTestStatus; import com.google.devtools.build.lib.view.test.TestStatus.TestResultData; import java.util.Collection; +import javax.annotation.Nullable; /** * This is the event passed from the various test strategies to the {@code RecordingTestListener} @@ -38,6 +40,7 @@ public class TestResult { private final TestRunnerAction testAction; private final TestResultData data; private final boolean cached; + @Nullable private final Path execRoot; /** * Construct the TestResult for the given test / status. @@ -45,11 +48,19 @@ public class TestResult { * @param testAction The test that was run. * @param data test result protobuffer. * @param cached true if this is a locally cached test result. + * @param execRooot The execution root in which the action was carried out; can be null, in which + * case everything depending on the execution root is ignored. */ - public TestResult(TestRunnerAction testAction, TestResultData data, boolean cached) { + public TestResult( + TestRunnerAction testAction, TestResultData data, boolean cached, @Nullable Path execRoot) { this.testAction = Preconditions.checkNotNull(testAction); this.data = data; this.cached = cached; + this.execRoot = execRoot; + } + + public TestResult(TestRunnerAction testAction, TestResultData data, boolean cached) { + this(testAction, data, cached, null); } public static boolean isBlazeTestStatusPassed(BlazeTestStatus status) { @@ -143,6 +154,12 @@ public Collection> getFiles() { if (testAction.getTestLog().getPath().exists()) { builder.add(Pair.of("test.log", testAction.getTestLog().getPath())); } + if (execRoot != null) { + ResolvedPaths resolvedPaths = testAction.resolve(execRoot); + if (resolvedPaths.getXmlOutputPath().exists()) { + builder.add(Pair.of("test.xml", resolvedPaths.getXmlOutputPath())); + } + } return builder.build(); } } diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh index 119afdd873f65c..39f15e188e5432 100755 --- a/src/test/shell/integration/build_event_stream_test.sh +++ b/src/test/shell/integration/build_event_stream_test.sh @@ -161,12 +161,14 @@ function test_cached_test_results() { || fail "Clean testing pkg:true failed" expect_log '^test_result' expect_log 'name:.*test.log' + expect_log 'name:.*test.xml' expect_log_once '^progress ' expect_not_log 'aborted' bazel test --experimental_build_event_text_file=$TEST_log pkg:true \ || fail "Second testing of pkg:true failed" expect_log '^test_result' expect_log 'name:.*test.log' + expect_log 'name:.*test.xml' expect_log_once '^progress ' expect_not_log 'aborted' }