Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ConfigurableAttributesTest to not rely on filegroup not using … #12908

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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