16
16
17
17
import static com .google .common .truth .Truth .assertThat ;
18
18
import static com .google .common .truth .Truth .assertWithMessage ;
19
+ import static com .google .devtools .build .lib .bazel .bzlmod .BzlmodTestUtil .createModuleKey ;
19
20
import static org .junit .Assert .assertThrows ;
20
21
import static org .junit .Assert .fail ;
21
22
@@ -2634,18 +2635,19 @@ public void testArgsCanonicalRepoLabel() throws Exception {
2634
2635
2635
2636
@ Test
2636
2637
public void testArgsApparentRepoLabel () throws Exception {
2637
- scratch .file ("MODULE.bazel" );
2638
+ scratch .overwriteFile ("MODULE.bazel" , "bazel_dep(name = 'foo', version = '1.0')" );
2639
+ registry .addModule (createModuleKey ("foo" , "1.0" ), "module(name='foo', version='1.0')" );
2640
+
2638
2641
StarlarkRuleContext ruleContext = createRuleContext ("//foo:foo" );
2639
2642
setRuleContext (ruleContext );
2640
2643
ev .exec (
2641
2644
"actions = ruleContext.actions" ,
2642
2645
"a = []" ,
2643
- // bazel_tools is a well-known Bazel module whose canonical repo name is bazel_tools.
2644
- "a.append(actions.args().add(Label('@bazel_tools')))" ,
2645
- "a.append(actions.args().add('-flag', Label('@@bazel_tools//:foo')))" ,
2646
- "a.append(actions.args().add('-flag', Label('@@bazel_tools//:foo'), format = '_%s_'))" ,
2647
- "a.append(actions.args().add_all(['foo', Label('@@bazel_tools//:foo')]))" ,
2648
- "a.append(actions.args().add_all(depset([Label('@@repo~//:foo'), Label('@@bazel_tools//:foo')])))" ,
2646
+ "a.append(actions.args().add(Label('@foo')))" ,
2647
+ "a.append(actions.args().add('-flag', Label('@@foo~//:foo')))" ,
2648
+ "a.append(actions.args().add('-flag', Label('@@foo~//:foo'), format = '_%s_'))" ,
2649
+ "a.append(actions.args().add_all(['foo', Label('@@foo~//:foo')]))" ,
2650
+ "a.append(actions.args().add_all(depset([Label('@@repo~//:foo'), Label('@@foo~//:foo')])))" ,
2649
2651
"ruleContext.actions.run(" ,
2650
2652
" inputs = depset(ruleContext.files.srcs)," ,
2651
2653
" outputs = ruleContext.files.srcs," ,
@@ -2660,15 +2662,15 @@ public void testArgsApparentRepoLabel() throws Exception {
2660
2662
assertThat (action .getArguments ())
2661
2663
.containsExactly (
2662
2664
"foo/t.exe" ,
2663
- "@bazel_tools //:bazel_tools " ,
2665
+ "@foo //:foo " ,
2664
2666
"-flag" ,
2665
- "@bazel_tools //:foo" ,
2667
+ "@foo //:foo" ,
2666
2668
"-flag" ,
2667
- "_@bazel_tools //:foo_" ,
2669
+ "_@foo //:foo_" ,
2668
2670
"foo" ,
2669
- "@bazel_tools //:foo" ,
2671
+ "@foo //:foo" ,
2670
2672
"@@repo~//:foo" ,
2671
- "@bazel_tools //:foo" )
2673
+ "@foo //:foo" )
2672
2674
.inOrder ();
2673
2675
}
2674
2676
0 commit comments