@@ -179,6 +179,8 @@ private void generateFilesToTestStrings() throws Exception {
179
179
")" ,
180
180
"" ,
181
181
"def _check_impl(ctx):" ,
182
+ " source_file = ctx.attr.srcs[0].files.to_list()[0]" ,
183
+ " generated_file = ctx.attr.srcs[1].files.to_list()[0]" ,
182
184
" objects = {" ,
183
185
" 'target': ctx.attr.deps[0]," ,
184
186
" 'alias_target': ctx.attr.deps[1]," ,
@@ -188,8 +190,10 @@ private void generateFilesToTestStrings() throws Exception {
188
190
" 'rule_ctx': ctx," ,
189
191
" 'aspect_ctx': ctx.attr.asp_deps[0][aspect_ctx_provider].ctx," ,
190
192
" 'aspect_ctx.rule': ctx.attr.asp_deps[0][aspect_ctx_provider].rule," ,
191
- " 'source_file': ctx.attr.srcs[0].files.to_list()[0]," ,
192
- " 'generated_file': ctx.attr.srcs[1].files.to_list()[0]," ,
193
+ " 'source_file': source_file," ,
194
+ " 'generated_file': generated_file," ,
195
+ " 'source_root': source_file.root," ,
196
+ " 'generated_root': generated_file.root," ,
193
197
" }" ,
194
198
" return struct(**prepare_params(objects))" ,
195
199
"check = rule(" ,
@@ -334,6 +338,19 @@ public void testStringRepresentations_Files() throws Exception {
334
338
}
335
339
}
336
340
341
+ @ Test
342
+ public void testStringRepresentations_Root () throws Exception {
343
+ setSkylarkSemanticsOptions ("--incompatible_descriptive_string_representations=true" );
344
+
345
+ generateFilesToTestStrings ();
346
+ ConfiguredTarget target = getConfiguredTarget ("//test/skylark:check" );
347
+
348
+ for (String suffix : SUFFIXES ) {
349
+ assertThat (target .get ("source_root" + suffix )).isEqualTo ("<source root>" );
350
+ assertThat (target .get ("generated_root" + suffix )).isEqualTo ("<derived root>" );
351
+ }
352
+ }
353
+
337
354
@ Test
338
355
public void testStringRepresentations_Glob () throws Exception {
339
356
setSkylarkSemanticsOptions ("--incompatible_descriptive_string_representations=true" );
0 commit comments