Skip to content

Commit

Permalink
Update ConfigurableAttributesTest to not rely on filegroup not using …
Browse files Browse the repository at this point in the history
…toolchain

resolution.

Part of work on bazelbuild#12899.

Closes bazelbuild#12908.

PiperOrigin-RevId: 353938904
  • Loading branch information
katre authored and copybara-github committed Jan 26, 2021
1 parent 13031e5 commit 1165182
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +45,7 @@
*/
@RunWith(JUnit4.class)
public class ConfigurableAttributesTest extends BuildViewTestCase {

private void writeConfigRules() throws Exception {
scratch.file("conditions/BUILD",
"config_setting(",
Expand Down Expand Up @@ -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 =
Expand All @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'],",
" })",
")");
Expand Down

0 comments on commit 1165182

Please sign in to comment.