From 11651824a9d0ffb9adb9611dcd39f4c95a59d750 Mon Sep 17 00:00:00 2001 From: John Cater Date: Tue, 26 Jan 2021 13:36:43 -0800 Subject: [PATCH] =?UTF-8?q?Update=20ConfigurableAttributesTest=20to=20not?= =?UTF-8?q?=20rely=20on=20filegroup=20not=20using=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …toolchain resolution. Part of work on #12899. Closes #12908. PiperOrigin-RevId: 353938904 --- .../analysis/ConfigurableAttributesTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java index b45e242bfc6e26..eb1c8eecf4c21d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfigurableAttributesTest.java @@ -15,6 +15,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.packages.Attribute.attr; +import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; @@ -44,6 +45,7 @@ */ @RunWith(JUnit4.class) public class ConfigurableAttributesTest extends BuildViewTestCase { + private void writeConfigRules() throws Exception { scratch.file("conditions/BUILD", "config_setting(", @@ -150,6 +152,15 @@ public Object getDefault(AttributeMap rule) { .value(Label.parseAbsoluteUnchecked("//foo:default")) .allowedFileTypes(FileTypeSet.ANY_FILE))); + private static final MockRule RULE_WITH_NO_PLATFORM = + () -> + MockRule.define( + "rule_with_no_platform", + (builder, env) -> + builder + .add(attr("deps", LABEL_LIST).allowedFileTypes()) + .useToolchainResolution(false)); + @Override protected ConfiguredRuleClassProvider createRuleClassProvider() { ConfiguredRuleClassProvider.Builder builder = @@ -158,7 +169,8 @@ protected ConfiguredRuleClassProvider createRuleClassProvider() { .addRuleDefinition(RULE_WITH_COMPUTED_DEFAULT) .addRuleDefinition(RULE_WITH_BOOLEAN_ATTR) .addRuleDefinition(RULE_WITH_ALLOWED_VALUES) - .addRuleDefinition(RULE_WITH_LABEL_DEFAULT); + .addRuleDefinition(RULE_WITH_LABEL_DEFAULT) + .addRuleDefinition(RULE_WITH_NO_PLATFORM); TestRuleClassProvider.addStandardRules(builder); return builder.build(); } @@ -1073,7 +1085,7 @@ public void selectableDefaultValueWithTypeDefault() throws Exception { useConfiguration("--test_arg=a"); ConfiguredTargetAndData ctad = getConfiguredTargetAndData("//srctest:gen"); AttributeMap attributes = getMapperFromConfiguredTargetAndTarget(ctad); - assertThat(attributes.get("srcs", BuildType.LABEL_LIST)).isEmpty(); + assertThat(attributes.get("srcs", LABEL_LIST)).isEmpty(); } @Test @@ -1243,8 +1255,8 @@ public void nonToolchainResolvingTargetsCantSelectDirectlyOnConstraints() throws scratch.file( "check/BUILD", "filegroup(name = 'adep', srcs = ['afile'])", - "filegroup(name = 'hello',", - " srcs = select({", + "rule_with_no_platform(name = 'hello',", + " deps = select({", " '//conditions:apple': [':adep'],", " })", ")");