diff options
author | mjhalupka <mjhalupka@google.com> | 2018-02-07 12:22:17 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-07 12:24:35 -0800 |
commit | 2fff952bbccc4c8436223314e3636fdd05e2073d (patch) | |
tree | bf1fdf3b8089148f2c9ffb6e0c4fc0c88f71b2a8 /src/main/java/com | |
parent | e40603fecbc13380dd9648cf3bf1e31f6ce74c0f (diff) |
Refactor to get rid of some getConfiguredTarget() calls in tests and replace
them with getConfiguredTargetAndTarget() so we can get rid of
ConfiguredTarget.getTarget() callers. This should be a test only change.
PiperOrigin-RevId: 184877255
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/BuildView.java | 6 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java | 30 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java index a3835d836a..a4cf6e421e 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java @@ -1133,6 +1133,12 @@ public class BuildView { getTopLevelTransitionForTarget(label, eventHandler)); } + @VisibleForTesting + public ConfiguredTargetAndTarget getConfiguredTargetAndTargetForTesting( + ExtendedEventHandler eventHandler, Label label, BuildConfiguration config) { + return skyframeExecutor.getConfiguredTargetAndTargetForTesting(eventHandler, label, config); + } + /** * Returns a RuleContext which is the same as the original RuleContext of the target parameter. */ diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index 93775243af..4cc660209a 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java @@ -1641,9 +1641,7 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { return getConfiguredTargetForTesting(eventHandler, label, configuration, NoTransition.INSTANCE); } - /** - * Returns a particular configured target after applying the given transition. - */ + /** Returns a particular configured target after applying the given transition. */ @VisibleForTesting @Nullable public ConfiguredTarget getConfiguredTargetForTesting( @@ -1652,6 +1650,20 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { BuildConfiguration configuration, ConfigurationTransition transition) { ConfiguredTargetAndTarget configuredTargetAndTarget = + getConfiguredTargetAndTargetForTesting(eventHandler, label, configuration, transition); + return configuredTargetAndTarget == null + ? null + : configuredTargetAndTarget.getConfiguredTarget(); + } + + @VisibleForTesting + @Nullable + public ConfiguredTargetAndTarget getConfiguredTargetAndTargetForTesting( + ExtendedEventHandler eventHandler, + Label label, + BuildConfiguration configuration, + ConfigurationTransition transition) { + ConfiguredTargetAndTarget configuredTargetAndTarget = Iterables.getFirst( getConfiguredTargetsForTesting( eventHandler, @@ -1662,9 +1674,15 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { : Dependency.withTransitionAndAspects( label, transition, AspectCollection.EMPTY))), null); - return configuredTargetAndTarget == null - ? null - : configuredTargetAndTarget.getConfiguredTarget(); + return configuredTargetAndTarget; + } + + @VisibleForTesting + @Nullable + public ConfiguredTargetAndTarget getConfiguredTargetAndTargetForTesting( + ExtendedEventHandler eventHandler, Label label, BuildConfiguration configuration) { + return getConfiguredTargetAndTargetForTesting( + eventHandler, label, configuration, NoTransition.INSTANCE); } /** |