From 0084e16b55ad54f7aeeffd6d003ea3506039d957 Mon Sep 17 00:00:00 2001 From: John Cater Date: Mon, 12 Mar 2018 18:50:56 -0700 Subject: Fix toolchain and execution platform registration to use patterns. This allows more flexibility in registering toolchains and execution platforms, both in the WORKSPACE and from the command-line. Change-Id: I6fe75507d1a74de74085b7c927fdf093c152b894 PiperOrigin-RevId: 188813688 --- .../skyframe/RegisteredToolchainsFunctionTest.java | 70 +++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java') diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java index d405ef8186..311cd5ad0a 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java @@ -41,7 +41,7 @@ public class RegisteredToolchainsFunctionTest extends ToolchainTestCase { assertThatEvaluationResult(result).hasEntryThat(toolchainsKey).isNotNull(); RegisteredToolchainsValue value = result.get(toolchainsKey); - // We have two registered toolchains, and a default for c++ + // We have two registered toolchains, and a default toolchain for C++. assertThat(value.registeredToolchains()).hasSize(3); assertThat( @@ -123,6 +123,74 @@ public class RegisteredToolchainsFunctionTest extends ToolchainTestCase { + "target does not provide the DeclaredToolchainInfo provider"); } + @Test + public void testRegisteredToolchains_targetPattern_workspace() throws Exception { + scratch.appendFile("extra/BUILD", "filegroup(name = 'not_a_platform')"); + addToolchain( + "extra", + "extra_toolchain1", + ImmutableList.of("//constraints:linux"), + ImmutableList.of("//constraints:linux"), + "foo"); + addToolchain( + "extra", + "extra_toolchain2", + ImmutableList.of("//constraints:linux"), + ImmutableList.of("//constraints:mac"), + "bar"); + addToolchain( + "extra/more", + "more_toolchain", + ImmutableList.of("//constraints:mac"), + ImmutableList.of("//constraints:linux"), + "baz"); + rewriteWorkspace("register_toolchains('//extra/...')"); + + SkyKey toolchainsKey = RegisteredToolchainsValue.key(targetConfigKey); + EvaluationResult result = + requestToolchainsFromSkyframe(toolchainsKey); + assertThatEvaluationResult(result).hasNoError(); + assertToolchainLabels(result.get(toolchainsKey)) + .containsAllOf( + makeLabel("//extra:extra_toolchain1_impl"), + makeLabel("//extra:extra_toolchain2_impl"), + makeLabel("//extra/more:more_toolchain_impl")); + } + + @Test + public void testRegisteredToolchains_targetPattern_flagOverride() throws Exception { + scratch.appendFile("extra/BUILD", "filegroup(name = 'not_a_platform')"); + addToolchain( + "extra", + "extra_toolchain1", + ImmutableList.of("//constraints:linux"), + ImmutableList.of("//constraints:linux"), + "foo"); + addToolchain( + "extra", + "extra_toolchain2", + ImmutableList.of("//constraints:linux"), + ImmutableList.of("//constraints:mac"), + "bar"); + addToolchain( + "extra/more", + "more_toolchain", + ImmutableList.of("//constraints:mac"), + ImmutableList.of("//constraints:linux"), + "baz"); + useConfiguration("--extra_toolchains=//extra/..."); + + SkyKey toolchainsKey = RegisteredToolchainsValue.key(targetConfigKey); + EvaluationResult result = + requestToolchainsFromSkyframe(toolchainsKey); + assertThatEvaluationResult(result).hasNoError(); + assertToolchainLabels(result.get(toolchainsKey)) + .containsAllOf( + makeLabel("//extra:extra_toolchain1_impl"), + makeLabel("//extra:extra_toolchain2_impl"), + makeLabel("//extra/more:more_toolchain_impl")); + } + @Test public void testRegisteredToolchains_reload() throws Exception { rewriteWorkspace("register_toolchains('//toolchain:toolchain_1')"); -- cgit v1.2.3