aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-02-17 11:55:40 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2017-02-17 14:55:30 +0000
commit4afb4b513f58c7dd724c7ea8c336be26b57afa45 (patch)
tree16bebfd8533125603c19a134e85036eeb23db5ed /src/main/java/com/google/devtools
parent1cb5059396e46d9ff2c317b8a0a046af32b3a1d8 (diff)
BEP: Also report the xml file in cached test
When the result of a test is reported from cache, report the full list of files. This requires knowing the exec root for, e.g., the xml output file. Therefore, add this path when constructing a cached TestResult. -- Change-Id: Id448eacfe3cfd0d36c25a5344874de4dc57acee9 Reviewed-on: https://cr.bazel.build/8934 PiperOrigin-RevId: 147823951 MOS_MIGRATED_REVID=147823951
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/StandaloneTestStrategy.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestResult.java19
2 files changed, 19 insertions, 2 deletions
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 c0739034e7..0a1ff9777c 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 @@ public class StandaloneTestStrategy extends TestStrategy {
@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 4aa61ada5f..742ef1f320 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.actions.Artifact;
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.vfs.PathFragment;
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 class TestResult {
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();
}
}