diff options
author | Greg Estren <gregce@google.com> | 2016-11-18 20:03:43 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-11-21 19:37:41 +0000 |
commit | 7883bf1da7f071dd8810e9b0bef7d70c9838e06c (patch) | |
tree | 7e2078f151846b1033d970bf16f64f288451ffc6 /src/test/java/com | |
parent | 2eaa31fade12242b7075c2bbac945aeeedf985e8 (diff) |
Adds support for multiple top-level dynamic configurations
(e.g. --experimental_multi_cpu).
--
MOS_MIGRATED_REVID=139607063
Diffstat (limited to 'src/test/java/com')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java index 2463760aee..b36cc32010 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/AnalysisTestCase.java @@ -258,8 +258,32 @@ public abstract class AnalysisTestCase extends FoundationTestCase { return masterConfig; } - protected BuildConfiguration getTargetConfiguration() { - return Iterables.getOnlyElement(masterConfig.getTargetConfigurations()); + /** + * Returns the target configuration for the most recent build, as created in Blaze's + * master configuration creation phase. Most significantly, this is never a dynamic + * configuration. + */ + protected BuildConfiguration getTargetConfiguration() throws InterruptedException { + return getTargetConfiguration(false); + } + + /** + * Returns the target configuration for the most recent build. If useDynamicVersionIfEnabled is + * true and dynamic configurations are enabled, returns the dynamic version. Else returns the + * static version. + */ + // TODO(gregce): force getTargetConfiguration() to getTargetConfiguration(true) once we know + // all callers can handle the dynamic version + protected BuildConfiguration getTargetConfiguration(boolean useDynamicVersionIfEnabled) + throws InterruptedException { + BuildConfiguration targetConfig = + Iterables.getOnlyElement(masterConfig.getTargetConfigurations()); + if (useDynamicVersionIfEnabled && targetConfig.useDynamicConfigurations()) { + return skyframeExecutor.getConfigurationForTesting(eventCollector, + targetConfig.fragmentClasses(), targetConfig.getOptions()); + } else { + return targetConfig; + } } protected BuildConfiguration getHostConfiguration() { @@ -379,7 +403,7 @@ public abstract class AnalysisTestCase extends FoundationTestCase { * Returns the corresponding configured target, if it exists. Note that this will only return * anything useful after a call to update() with the same label. */ - protected ConfiguredTarget getConfiguredTarget(String label) { + protected ConfiguredTarget getConfiguredTarget(String label) throws InterruptedException { return getConfiguredTarget(label, getTargetConfiguration()); } @@ -396,7 +420,8 @@ public abstract class AnalysisTestCase extends FoundationTestCase { return buildView.hasErrors(configuredTarget); } - protected Artifact getBinArtifact(String packageRelativePath, ConfiguredTarget owner) { + protected Artifact getBinArtifact(String packageRelativePath, ConfiguredTarget owner) + throws InterruptedException { Label label = owner.getLabel(); return buildView.getArtifactFactory().getDerivedArtifact( label.getPackageFragment().getRelative(packageRelativePath), |