15
15
16
16
import static com .google .common .truth .Truth .assertThat ;
17
17
import static com .google .devtools .build .lib .packages .Attribute .attr ;
18
+ import static com .google .devtools .build .lib .packages .BuildType .LABEL_LIST ;
18
19
import static org .junit .Assert .assertThrows ;
19
20
20
21
import com .google .common .collect .ImmutableList ;
44
45
*/
45
46
@ RunWith (JUnit4 .class )
46
47
public class ConfigurableAttributesTest extends BuildViewTestCase {
48
+
47
49
private void writeConfigRules () throws Exception {
48
50
scratch .file ("conditions/BUILD" ,
49
51
"config_setting(" ,
@@ -150,6 +152,15 @@ public Object getDefault(AttributeMap rule) {
150
152
.value (Label .parseAbsoluteUnchecked ("//foo:default" ))
151
153
.allowedFileTypes (FileTypeSet .ANY_FILE )));
152
154
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
+
153
164
@ Override
154
165
protected ConfiguredRuleClassProvider createRuleClassProvider () {
155
166
ConfiguredRuleClassProvider .Builder builder =
@@ -158,7 +169,8 @@ protected ConfiguredRuleClassProvider createRuleClassProvider() {
158
169
.addRuleDefinition (RULE_WITH_COMPUTED_DEFAULT )
159
170
.addRuleDefinition (RULE_WITH_BOOLEAN_ATTR )
160
171
.addRuleDefinition (RULE_WITH_ALLOWED_VALUES )
161
- .addRuleDefinition (RULE_WITH_LABEL_DEFAULT );
172
+ .addRuleDefinition (RULE_WITH_LABEL_DEFAULT )
173
+ .addRuleDefinition (RULE_WITH_NO_PLATFORM );
162
174
TestRuleClassProvider .addStandardRules (builder );
163
175
return builder .build ();
164
176
}
@@ -1073,7 +1085,7 @@ public void selectableDefaultValueWithTypeDefault() throws Exception {
1073
1085
useConfiguration ("--test_arg=a" );
1074
1086
ConfiguredTargetAndData ctad = getConfiguredTargetAndData ("//srctest:gen" );
1075
1087
AttributeMap attributes = getMapperFromConfiguredTargetAndTarget (ctad );
1076
- assertThat (attributes .get ("srcs" , BuildType . LABEL_LIST )).isEmpty ();
1088
+ assertThat (attributes .get ("srcs" , LABEL_LIST )).isEmpty ();
1077
1089
}
1078
1090
1079
1091
@ Test
@@ -1243,8 +1255,8 @@ public void nonToolchainResolvingTargetsCantSelectDirectlyOnConstraints() throws
1243
1255
scratch .file (
1244
1256
"check/BUILD" ,
1245
1257
"filegroup(name = 'adep', srcs = ['afile'])" ,
1246
- "filegroup (name = 'hello'," ,
1247
- " srcs = select({" ,
1258
+ "rule_with_no_platform (name = 'hello'," ,
1259
+ " deps = select({" ,
1248
1260
" '//conditions:apple': [':adep']," ,
1249
1261
" })" ,
1250
1262
")" );
0 commit comments