From 96b4081b29c639c24660411cc2d326afb826d9a7 Mon Sep 17 00:00:00 2001 From: John Cater Date: Tue, 18 Jul 2017 18:08:03 +0200 Subject: Implement toolchain resolution via constraint checks. Part of #2219. Change-Id: I5777e9b6cafbb7586cbbfb5b300344fd4417513d PiperOrigin-RevId: 162359389 --- .../lib/rules/platform/ToolchainTestCase.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/rules') diff --git a/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java index 5d170baac0..3b9548d9a6 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/platform/ToolchainTestCase.java @@ -24,8 +24,8 @@ import org.junit.Before; /** Utility methods for setting up platform and toolchain related tests. */ public abstract class ToolchainTestCase extends SkylarkTestCase { - public PlatformInfo targetPlatform; - public PlatformInfo hostPlatform; + public PlatformInfo linuxPlatform; + public PlatformInfo macPlatform; public ConstraintSettingInfo setting; public ConstraintValueInfo linuxConstraint; @@ -46,18 +46,22 @@ public abstract class ToolchainTestCase extends SkylarkTestCase { setting = ConstraintSettingInfo.create(makeLabel("//constraint:os")); linuxConstraint = ConstraintValueInfo.create(setting, makeLabel("//constraint:linux")); macConstraint = ConstraintValueInfo.create(setting, makeLabel("//constraint:mac")); - } - @Before - public void createPlatforms() throws Exception { - targetPlatform = - PlatformInfo.builder().setLabel(makeLabel("//platforms:target_platform")).build(); - hostPlatform = PlatformInfo.builder().setLabel(makeLabel("//platforms:host_platform")).build(); + linuxPlatform = + PlatformInfo.builder() + .setLabel(makeLabel("//platforms:target_platform")) + .addConstraint(linuxConstraint) + .build(); + macPlatform = + PlatformInfo.builder() + .setLabel(makeLabel("//platforms:host_platform")) + .addConstraint(macConstraint) + .build(); } @Before public void createToolchains() throws Exception { - rewriteWorkspace("register_toolchains('//toolchain:toolchain_1', '//toolchain:toolchain_2')"); + rewriteWorkspace("register_toolchains('//toolchain:toolchain_1', '//toolchain:toolchain_2')"); scratch.file( "toolchain/BUILD", -- cgit v1.2.3