diff options
author | 2018-03-12 18:50:56 -0700 | |
---|---|---|
committer | 2018-03-12 18:53:23 -0700 | |
commit | 0084e16b55ad54f7aeeffd6d003ea3506039d957 (patch) | |
tree | 306210efed020fe8a7fd8645e383d8fe4e3b2947 /src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java | |
parent | cf37b4f3e44564a154ea0535efa61c6c673bab52 (diff) |
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
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/RegisteredToolchainsFunctionTest.java | 70 |
1 files changed, 69 insertions, 1 deletions
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( @@ -124,6 +124,74 @@ public class RegisteredToolchainsFunctionTest extends ToolchainTestCase { } @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<RegisteredToolchainsValue> 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<RegisteredToolchainsValue> 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')"); |