1515
1616import static com .google .common .truth .Truth .assertThat ;
1717import static com .google .devtools .build .lib .packages .Attribute .attr ;
18+ import static com .google .devtools .build .lib .packages .BuildType .LABEL_LIST ;
1819import static org .junit .Assert .assertThrows ;
1920
2021import com .google .common .collect .ImmutableList ;
4445 */
4546@ RunWith (JUnit4 .class )
4647public class ConfigurableAttributesTest extends BuildViewTestCase {
48+
4749 private void writeConfigRules () throws Exception {
4850 scratch .file ("conditions/BUILD" ,
4951 "config_setting(" ,
@@ -150,6 +152,15 @@ public Object getDefault(AttributeMap rule) {
150152 .value (Label .parseAbsoluteUnchecked ("//foo:default" ))
151153 .allowedFileTypes (FileTypeSet .ANY_FILE )));
152154
155+ private static final MockRule RULE_WITH_NO_PLATFORM =
156+ () ->
157+ MockRule .define (
158+ "rule_with_no_platform" ,
159+ (builder , env ) ->
160+ builder
161+ .add (attr ("deps" , LABEL_LIST ).allowedFileTypes ())
162+ .useToolchainResolution (false ));
163+
153164 @ Override
154165 protected ConfiguredRuleClassProvider createRuleClassProvider () {
155166 ConfiguredRuleClassProvider .Builder builder =
@@ -158,7 +169,8 @@ protected ConfiguredRuleClassProvider createRuleClassProvider() {
158169 .addRuleDefinition (RULE_WITH_COMPUTED_DEFAULT )
159170 .addRuleDefinition (RULE_WITH_BOOLEAN_ATTR )
160171 .addRuleDefinition (RULE_WITH_ALLOWED_VALUES )
161- .addRuleDefinition (RULE_WITH_LABEL_DEFAULT );
172+ .addRuleDefinition (RULE_WITH_LABEL_DEFAULT )
173+ .addRuleDefinition (RULE_WITH_NO_PLATFORM );
162174 TestRuleClassProvider .addStandardRules (builder );
163175 return builder .build ();
164176 }
@@ -1073,7 +1085,7 @@ public void selectableDefaultValueWithTypeDefault() throws Exception {
10731085 useConfiguration ("--test_arg=a" );
10741086 ConfiguredTargetAndData ctad = getConfiguredTargetAndData ("//srctest:gen" );
10751087 AttributeMap attributes = getMapperFromConfiguredTargetAndTarget (ctad );
1076- assertThat (attributes .get ("srcs" , BuildType . LABEL_LIST )).isEmpty ();
1088+ assertThat (attributes .get ("srcs" , LABEL_LIST )).isEmpty ();
10771089 }
10781090
10791091 @ Test
@@ -1243,8 +1255,8 @@ public void nonToolchainResolvingTargetsCantSelectDirectlyOnConstraints() throws
12431255 scratch .file (
12441256 "check/BUILD" ,
12451257 "filegroup(name = 'adep', srcs = ['afile'])" ,
1246- "filegroup (name = 'hello'," ,
1247- " srcs = select({" ,
1258+ "rule_with_no_platform (name = 'hello'," ,
1259+ " deps = select({" ,
12481260 " '//conditions:apple': [':adep']," ,
12491261 " })" ,
12501262 ")" );
0 commit comments