From 2fff952bbccc4c8436223314e3636fdd05e2073d Mon Sep 17 00:00:00 2001 From: mjhalupka Date: Wed, 7 Feb 2018 12:22:17 -0800 Subject: 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 --- .../devtools/build/lib/analysis/BuildView.java | 6 +++++ .../build/lib/skyframe/SkyframeExecutor.java | 30 +++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/google/devtools') 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( @@ -1651,6 +1649,20 @@ public abstract class SkyframeExecutor implements WalkableGraphFactory { Label label, 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( @@ -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); } /** -- cgit v1.2.3