diff options
author | 2017-10-30 17:33:04 -0400 | |
---|---|---|
committer | 2017-10-31 10:37:41 -0400 | |
commit | 61c48b50fe7d8b1bd491a20d35f851be90bf07d2 (patch) | |
tree | 730d32908d11b7d2766702f41e377f6098ffe559 /src | |
parent | 41375ac41679bee2b5e51b5deba1597848d4134b (diff) |
Fixes EvaluationResult Builder
RELNOTES: None
PiperOrigin-RevId: 173950304
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java | 47 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java | 5 |
2 files changed, 25 insertions, 27 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java index ca864a89e0..6a9d2df3a5 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/query2/SkyQueryEnvironment.java @@ -254,9 +254,7 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> result = graphFactory.prepareAndGet(roots, loadingPhaseThreads, universeEvalEventHandler); } - if (roots.size() == 1 && Iterables.getOnlyElement(roots).equals(universeKey)) { - checkEvaluationResult(result); - } + checkEvaluationResult(roots, result); packageSemaphore = makeFreshPackageMultisetSemaphore(); graph = result.getWalkableGraph(); @@ -301,27 +299,28 @@ public class SkyQueryEnvironment extends AbstractBlazeQueryEnvironment<Target> return packageSemaphore; } - /** - * The {@link EvaluationResult} is from the evaluation of a single PrepareDepsOfPatterns node. We - * expect to see either a single successfully evaluated value or a cycle in the result. - */ - private void checkEvaluationResult(EvaluationResult<SkyValue> result) { - Collection<SkyValue> values = result.values(); - if (!values.isEmpty()) { - Preconditions.checkState( - values.size() == 1, - "Universe query \"%s\" returned multiple values unexpectedly (%s values in result)", - universeScope, - values.size()); - Preconditions.checkNotNull(result.get(universeKey), result); - } else { - // No values in the result, so there must be an error. We expect the error to be a cycle. - boolean foundCycle = !Iterables.isEmpty(result.getError().getCycleInfo()); - Preconditions.checkState( - foundCycle, - "Universe query \"%s\" failed with non-cycle error: %s", - universeScope, - result.getError()); + protected void checkEvaluationResult(Set<SkyKey> roots, EvaluationResult<SkyValue> result) + throws QueryException { + // If the only root is the universe key, we expect to see either a single successfully evaluated + // value or a cycle in the result. + if (roots.size() == 1 && Iterables.getOnlyElement(roots).equals(universeKey)) { + Collection<SkyValue> values = result.values(); + if (!values.isEmpty()) { + Preconditions.checkState( + values.size() == 1, + "Universe query \"%s\" returned multiple values unexpectedly (%s values in result)", + universeScope, + values.size()); + Preconditions.checkNotNull(result.get(universeKey), result); + } else { + // No values in the result, so there must be an error. We expect the error to be a cycle. + boolean foundCycle = !Iterables.isEmpty(result.getError().getCycleInfo()); + Preconditions.checkState( + foundCycle, + "Universe query \"%s\" failed with non-cycle error: %s", + universeScope, + result.getError()); + } } } diff --git a/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java b/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java index 8a885fe879..7efc01abe2 100644 --- a/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java +++ b/src/main/java/com/google/devtools/build/skyframe/EvaluationResult.java @@ -18,12 +18,10 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.devtools.build.lib.util.Preconditions; - import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; - import javax.annotation.Nullable; /** @@ -193,8 +191,9 @@ public class EvaluationResult<T extends SkyValue> { return new EvaluationResult<>(result, errors, catastrophe, walkableGraph); } - public void setCatastrophe(Exception catastrophe) { + public Builder<T> setCatastrophe(Exception catastrophe) { this.catastrophe = catastrophe; + return this; } } } |