diff options
author | John Cater <jcater@google.com> | 2018-06-22 14:20:22 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-22 14:22:15 -0700 |
commit | c8bd74f76c3e02657571432d2fe4d923803410be (patch) | |
tree | c4cf818a9e8d9bd4723c830331311697b8aaeae5 /src/test/java/com/google/devtools | |
parent | 368bc8ac6080cfce5933ef7ff5d566619bb93add (diff) |
ToolchainContext directly implements SkylarkValue and SkylarkIndexable.
Change-Id: I355b138e143771fd826ab03951df821ea7d58ac5
PiperOrigin-RevId: 201740564
Diffstat (limited to 'src/test/java/com/google/devtools')
4 files changed, 36 insertions, 45 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java index 5fcae537c2..14a3cc5386 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewForTesting.java @@ -352,9 +352,7 @@ public class BuildViewForTesting { configurations.getHostConfiguration(), /*aspect=*/ null, getConfigurableAttributeKeysForTesting(eventHandler, ctgNode), - toolchainContext == null - ? ImmutableSet.of() - : toolchainContext.getResolvedToolchainLabels(), + toolchainContext == null ? ImmutableSet.of() : toolchainContext.resolvedToolchainLabels(), skyframeExecutor.getDefaultBuildOptions(), ruleClassProvider.getTrimmingTransitionFactory()); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java index d6938814fc..2f72860c2b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcToolchainSelectionTest.java @@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.ToolchainContext.ResolvedToolchainProviders; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter; import com.google.devtools.build.lib.cmdline.Label; @@ -64,12 +63,11 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { ScratchAttributeWriter.fromLabelString(this, "cc_library", "//lib") .setList("srcs", "a.cc") .write(); - ResolvedToolchainProviders providers = - (ResolvedToolchainProviders) - getRuleContext(target).getToolchainContext().getResolvedToolchainProviders(); CcToolchainProvider toolchain = (CcToolchainProvider) - providers.getForToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + getRuleContext(target) + .getToolchainContext() + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); assertThat(Iterables.getOnlyElement(toolchain.getCompile()).getExecPathString()) .endsWith("piii"); } @@ -101,12 +99,11 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { ScratchAttributeWriter.fromLabelString(this, "cc_library", "//lib") .setList("srcs", "a.cc") .write(); - ResolvedToolchainProviders providers = - (ResolvedToolchainProviders) - getRuleContext(target).getToolchainContext().getResolvedToolchainProviders(); CcToolchainProvider toolchain = (CcToolchainProvider) - providers.getForToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + getRuleContext(target) + .getToolchainContext() + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); assertThat(toolchain.getToolchainIdentifier()).endsWith("piii"); } @@ -163,12 +160,11 @@ public class CcToolchainSelectionTest extends BuildViewTestCase { ScratchAttributeWriter.fromLabelString(this, "cc_library", "//lib") .setList("srcs", "a.cc") .write(); - ResolvedToolchainProviders providers = - (ResolvedToolchainProviders) - getRuleContext(target).getToolchainContext().getResolvedToolchainProviders(); CcToolchainProvider toolchain = (CcToolchainProvider) - providers.getForToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); + getRuleContext(target) + .getToolchainContext() + .forToolchainType(Label.parseAbsolute(CPP_TOOLCHAIN_TYPE)); assertThat(toolchain.getToolPathFragment(CppConfiguration.Tool.LD).toString()) .contains("piii-ld"); } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java index 8f33c0b0e6..7423652698 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/RuleContextTest.java @@ -17,7 +17,6 @@ package com.google.devtools.build.lib.skyframe; import static com.google.common.truth.Truth.assertThat; import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.ToolchainContext.ResolvedToolchainProviders; import com.google.devtools.build.lib.analysis.platform.ToolchainInfo; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.platform.ToolchainTestCase; @@ -36,15 +35,13 @@ public class RuleContextTest extends ToolchainTestCase { "--host_platform=//platforms:linux", "--platforms=//platforms:mac"); RuleContext ruleContext = getRuleContext(getConfiguredTarget("//x")); - assertThat(ruleContext.getToolchainContext().getResolvedToolchainLabels()) + assertThat(ruleContext.getToolchainContext().resolvedToolchainLabels()) .contains(Label.parseAbsolute("//toolchain:toolchain_1_impl")); - ResolvedToolchainProviders resolvedToolchainProviders = - (ResolvedToolchainProviders) - ruleContext.getToolchainContext().getResolvedToolchainProviders(); ToolchainInfo toolchain = - resolvedToolchainProviders.getForToolchainType( - Label.parseAbsolute("//toolchain:test_toolchain")); + ruleContext + .getToolchainContext() + .forToolchainType(Label.parseAbsolute("//toolchain:test_toolchain")); assertThat(toolchain.getValue("data")).isEqualTo("foo"); } } diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainUtilTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainUtilTest.java index b2175c640a..fa3af8e923 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainUtilTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainUtilTest.java @@ -104,16 +104,16 @@ public class ToolchainUtilTest extends ToolchainTestCase { ToolchainContext toolchainContext = result.get(key).toolchainContext(); assertThat(toolchainContext).isNotNull(); - assertThat(toolchainContext.getRequiredToolchains()).containsExactly(testToolchainType); - assertThat(toolchainContext.getResolvedToolchainLabels()) + assertThat(toolchainContext.requiredToolchainTypes()).containsExactly(testToolchainType); + assertThat(toolchainContext.resolvedToolchainLabels()) .containsExactly(Label.parseAbsoluteUnchecked("//extra:extra_toolchain_mac_impl")); - assertThat(toolchainContext.getExecutionPlatform()).isNotNull(); - assertThat(toolchainContext.getExecutionPlatform().label()) + assertThat(toolchainContext.executionPlatform()).isNotNull(); + assertThat(toolchainContext.executionPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:mac")); - assertThat(toolchainContext.getTargetPlatform()).isNotNull(); - assertThat(toolchainContext.getTargetPlatform().label()) + assertThat(toolchainContext.targetPlatform()).isNotNull(); + assertThat(toolchainContext.targetPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:linux")); } @@ -132,15 +132,15 @@ public class ToolchainUtilTest extends ToolchainTestCase { ToolchainContext toolchainContext = result.get(key).toolchainContext(); assertThat(toolchainContext).isNotNull(); - assertThat(toolchainContext.getRequiredToolchains()).isEmpty(); + assertThat(toolchainContext.requiredToolchainTypes()).isEmpty(); // With no toolchains requested, should fall back to the host platform. - assertThat(toolchainContext.getExecutionPlatform()).isNotNull(); - assertThat(toolchainContext.getExecutionPlatform().label()) + assertThat(toolchainContext.executionPlatform()).isNotNull(); + assertThat(toolchainContext.executionPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//host:host")); - assertThat(toolchainContext.getTargetPlatform()).isNotNull(); - assertThat(toolchainContext.getTargetPlatform().label()) + assertThat(toolchainContext.targetPlatform()).isNotNull(); + assertThat(toolchainContext.targetPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:linux")); } @@ -176,15 +176,15 @@ public class ToolchainUtilTest extends ToolchainTestCase { ToolchainContext toolchainContext = result.get(key).toolchainContext(); assertThat(toolchainContext).isNotNull(); - assertThat(toolchainContext.getRequiredToolchains()).isEmpty(); + assertThat(toolchainContext.requiredToolchainTypes()).isEmpty(); // With no toolchains requested, should fall back to the host platform. - assertThat(toolchainContext.getExecutionPlatform()).isNotNull(); - assertThat(toolchainContext.getExecutionPlatform().label()) + assertThat(toolchainContext.executionPlatform()).isNotNull(); + assertThat(toolchainContext.executionPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//sample:sample_b")); - assertThat(toolchainContext.getTargetPlatform()).isNotNull(); - assertThat(toolchainContext.getTargetPlatform().label()) + assertThat(toolchainContext.targetPlatform()).isNotNull(); + assertThat(toolchainContext.targetPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:linux")); } @@ -365,16 +365,16 @@ public class ToolchainUtilTest extends ToolchainTestCase { ToolchainContext toolchainContext = result.get(key).toolchainContext(); assertThat(toolchainContext).isNotNull(); - assertThat(toolchainContext.getRequiredToolchains()).containsExactly(testToolchainType); - assertThat(toolchainContext.getResolvedToolchainLabels()) + assertThat(toolchainContext.requiredToolchainTypes()).containsExactly(testToolchainType); + assertThat(toolchainContext.resolvedToolchainLabels()) .containsExactly(Label.parseAbsoluteUnchecked("//extra:extra_toolchain_linux_impl")); - assertThat(toolchainContext.getExecutionPlatform()).isNotNull(); - assertThat(toolchainContext.getExecutionPlatform().label()) + assertThat(toolchainContext.executionPlatform()).isNotNull(); + assertThat(toolchainContext.executionPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:linux")); - assertThat(toolchainContext.getTargetPlatform()).isNotNull(); - assertThat(toolchainContext.getTargetPlatform().label()) + assertThat(toolchainContext.targetPlatform()).isNotNull(); + assertThat(toolchainContext.targetPlatform().label()) .isEqualTo(Label.parseAbsoluteUnchecked("//platforms:linux")); } |