@@ -1266,6 +1266,45 @@ public void nonToolchainResolvingTargetsCantSelectDirectlyOnConstraints() throws
1266
1266
assertContainsEvent ("//conditions:apple is not a valid select() condition for //check:hello" );
1267
1267
}
1268
1268
1269
+ @ Test
1270
+ public void selectDirectlyOnConstraintsWithAlias () throws Exception {
1271
+ // Tests select()ing directly on a constraint_value (with no intermediate config_setting).
1272
+ scratch .file (
1273
+ "conditions/BUILD" ,
1274
+ "constraint_setting(name = 'fruit')" ,
1275
+ "constraint_value(name = 'apple', constraint_setting = 'fruit')" ,
1276
+ "constraint_value(name = 'banana', constraint_setting = 'fruit')" ,
1277
+ "platform(" ,
1278
+ " name = 'apple_platform'," ,
1279
+ " constraint_values = [':apple']," ,
1280
+ ")" ,
1281
+ "platform(" ,
1282
+ " name = 'banana_platform'," ,
1283
+ " constraint_values = [':banana']," ,
1284
+ ")" );
1285
+ scratch .file (
1286
+ "check/BUILD" ,
1287
+ "filegroup(name = 'adep', srcs = ['afile'])" ,
1288
+ "filegroup(name = 'bdep', srcs = ['bfile'])" ,
1289
+ "alias(name = 'hello'," ,
1290
+ " actual = select({" ,
1291
+ " '//conditions:apple': ':adep'," ,
1292
+ " '//conditions:banana': ':bdep'," ,
1293
+ " }))" );
1294
+ checkRule (
1295
+ "//check:hello" ,
1296
+ "srcs" ,
1297
+ ImmutableList .of ("--platforms=//conditions:apple_platform" ),
1298
+ /*expected:*/ ImmutableList .of ("src check/afile" ),
1299
+ /*not expected:*/ ImmutableList .of ("src check/bfile" ));
1300
+ checkRule (
1301
+ "//check:hello" ,
1302
+ "srcs" ,
1303
+ ImmutableList .of ("--platforms=//conditions:banana_platform" ),
1304
+ /*expected:*/ ImmutableList .of ("src check/bfile" ),
1305
+ /*not expected:*/ ImmutableList .of ("src check/afile" ));
1306
+ }
1307
+
1269
1308
@ Test
1270
1309
public void multipleMatchErrorWhenAliasResolvesToSameSetting () throws Exception {
1271
1310
scratch .file (
0 commit comments