aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-06-13 21:57:19 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-13 21:58:58 -0700
commitb9d8d58ef58645544c84ac4bcace869adad7abe5 (patch)
treef4faa461747d1e96b299ed67a3f520679d5481b2 /src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java
parent594e8588bcd0257c5a3c7e1dd8eae82ce28173b2 (diff)
Add functionality to make certain SkyValues unshareable, meaning they are not serialized. Tag TestCompletionValue and any ActionExecutionValue coming from a NotifyOnActionCacheHit (i.e., tests) like that. To make such values really not shared, request the ActionExecutionValue from TestCompletionFunction as opposed to the ArtifactValue (propagating the unshareable bit up seemed like too much fuss, and I have a dream of getting rid of ArtifactValue anyway).
PiperOrigin-RevId: 200504358
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java
index cbbe9f9d30..9a7d7a6aac 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/TestCompletionFunction.java
@@ -13,6 +13,11 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+import com.google.devtools.build.lib.actions.ActionLookupData;
+import com.google.devtools.build.lib.actions.ActionLookupValue;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.TopLevelArtifactContext;
@@ -21,6 +26,7 @@ import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import java.util.Map;
/**
* TestCompletionFunction builds all relevant test artifacts of a {@link
@@ -45,14 +51,40 @@ public final class TestCompletionFunction implements SkyFunction {
ConfiguredTarget ct = ctValue.getConfiguredTarget();
if (key.exclusiveTesting()) {
- // Request test artifacts iteratively if testing exclusively.
+ // Request test execution iteratively if testing exclusively.
for (Artifact testArtifact : TestProvider.getTestStatusArtifacts(ct)) {
- if (env.getValue(ArtifactSkyKey.key(testArtifact, /*isMandatory=*/ true)) == null) {
+ ActionLookupValue.ActionLookupKey actionLookupKey =
+ ArtifactFunction.getActionLookupKey(testArtifact);
+ ActionLookupValue actionLookupValue =
+ ArtifactFunction.getActionLookupValue(actionLookupKey, env, testArtifact);
+ if (actionLookupValue == null) {
+ return null;
+ }
+ env.getValue(getActionLookupData(testArtifact, actionLookupKey, actionLookupValue));
+ if (env.valuesMissing()) {
return null;
}
}
} else {
- env.getValues(TestProvider.getTestStatusArtifacts(ct));
+ Multimap<ActionLookupValue.ActionLookupKey, Artifact> keyToArtifactMap =
+ Multimaps.index(
+ TestProvider.getTestStatusArtifacts(ct), ArtifactFunction::getActionLookupKey);
+ Map<SkyKey, SkyValue> actionLookupValues = env.getValues(keyToArtifactMap.keySet());
+ if (env.valuesMissing()) {
+ return null;
+ }
+ env.getValues(
+ keyToArtifactMap
+ .entries()
+ .stream()
+ .map(
+ entry ->
+ getActionLookupData(
+ entry.getValue(),
+ entry.getKey(),
+ (ActionLookupValue) actionLookupValues.get(entry.getKey())))
+ .distinct()
+ .collect(ImmutableSet.toImmutableSet()));
if (env.valuesMissing()) {
return null;
}
@@ -60,6 +92,14 @@ public final class TestCompletionFunction implements SkyFunction {
return TestCompletionValue.TEST_COMPLETION_MARKER;
}
+ private static ActionLookupData getActionLookupData(
+ Artifact artifact,
+ ActionLookupValue.ActionLookupKey actionLookupKey,
+ ActionLookupValue actionLookupValue) {
+ return ActionExecutionValue.key(
+ actionLookupKey, actionLookupValue.getGeneratingActionIndex(artifact));
+ }
+
@Override
public String extractTag(SkyKey skyKey) {
return Label.print(((ConfiguredTargetKey) skyKey.argument()).getLabel());