@@ -334,22 +334,22 @@ public void testRootModule_include_good() throws Exception {
334
334
scratch .overwriteFile (
335
335
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
336
336
"module(name='aaa')" ,
337
- "include('//java:MODULE.bazel.segment ')" ,
337
+ "include('//java:java. MODULE.bazel')" ,
338
338
"bazel_dep(name='foo', version='1.0')" ,
339
339
"register_toolchains('//:whatever')" ,
340
- "include('//python:MODULE.bazel.segment ')" );
340
+ "include('//python:python. MODULE.bazel')" );
341
341
scratch .overwriteFile (rootDirectory .getRelative ("java/BUILD" ).getPathString ());
342
342
scratch .overwriteFile (
343
- rootDirectory .getRelative ("java/MODULE.bazel.segment " ).getPathString (),
343
+ rootDirectory .getRelative ("java/java. MODULE.bazel" ).getPathString (),
344
344
"bazel_dep(name='java-foo', version='1.0')" );
345
345
scratch .overwriteFile (rootDirectory .getRelative ("python/BUILD" ).getPathString ());
346
346
scratch .overwriteFile (
347
- rootDirectory .getRelative ("python/MODULE.bazel.segment " ).getPathString (),
347
+ rootDirectory .getRelative ("python/python. MODULE.bazel" ).getPathString (),
348
348
"bazel_dep(name='py-foo', version='1.0', repo_name='python-foo')" ,
349
349
"single_version_override(module_name='java-foo', version='2.0')" ,
350
- "include('//python:toolchains/MODULE.bazel.segment ')" );
350
+ "include('//python:toolchains/toolchains. MODULE.bazel')" );
351
351
scratch .overwriteFile (
352
- rootDirectory .getRelative ("python/toolchains/MODULE.bazel.segment " ).getPathString (),
352
+ rootDirectory .getRelative ("python/toolchains/toolchains. MODULE.bazel" ).getPathString (),
353
353
"register_toolchains('//:python-whatever')" );
354
354
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
355
355
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
@@ -387,7 +387,7 @@ public void testRootModule_include_bad_otherRepoLabel() throws Exception {
387
387
scratch .overwriteFile (
388
388
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
389
389
"module(name='aaa')" ,
390
- "include('@haha//java:MODULE.bazel.segment ')" );
390
+ "include('@haha//java:java. MODULE.bazel')" );
391
391
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
392
392
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
393
393
@@ -403,7 +403,7 @@ public void testRootModule_include_bad_relativeLabel() throws Exception {
403
403
scratch .overwriteFile (
404
404
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
405
405
"module(name='aaa')" ,
406
- "include(':MODULE.bazel.segment ')" );
406
+ "include(':relative. MODULE.bazel')" );
407
407
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
408
408
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
409
409
@@ -414,12 +414,28 @@ public void testRootModule_include_bad_relativeLabel() throws Exception {
414
414
assertThat (result .getError ().toString ()).contains ("starting with double slashes" );
415
415
}
416
416
417
+ @ Test
418
+ public void testRootModule_include_bad_notEndingInModuleBazel () throws Exception {
419
+ scratch .overwriteFile (
420
+ rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
421
+ "module(name='aaa')" ,
422
+ "include('//:MODULE.bazel.segment')" );
423
+ FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
424
+ ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
425
+
426
+ EvaluationResult <RootModuleFileValue > result =
427
+ evaluator .evaluate (
428
+ ImmutableList .of (ModuleFileValue .KEY_FOR_ROOT_MODULE ), evaluationContext );
429
+ assertThat (result .hasError ()).isTrue ();
430
+ assertThat (result .getError ().toString ()).contains ("have a name ending in '.MODULE.bazel'" );
431
+ }
432
+
417
433
@ Test
418
434
public void testRootModule_include_bad_badLabelSyntax () throws Exception {
419
435
scratch .overwriteFile (
420
436
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
421
437
"module(name='aaa')" ,
422
- "include('//haha/:::')" );
438
+ "include('//haha/:::.MODULE.bazel ')" );
423
439
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
424
440
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
425
441
@@ -435,10 +451,10 @@ public void testRootModule_include_bad_badLabelSyntax() throws Exception {
435
451
public void testRootModule_include_bad_moduleAfterInclude () throws Exception {
436
452
scratch .overwriteFile (
437
453
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
438
- "include('//java:MODULE.bazel.segment ')" );
454
+ "include('//java:java. MODULE.bazel')" );
439
455
scratch .overwriteFile (rootDirectory .getRelative ("java/BUILD" ).getPathString ());
440
456
scratch .overwriteFile (
441
- rootDirectory .getRelative ("java/MODULE.bazel.segment " ).getPathString (),
457
+ rootDirectory .getRelative ("java/java. MODULE.bazel" ).getPathString (),
442
458
"module(name='bet-you-didnt-expect-this-didya')" ,
443
459
"bazel_dep(name='java-foo', version='1.0', repo_name='foo')" );
444
460
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
@@ -457,15 +473,15 @@ public void testRootModule_include_bad_repoNameCollision() throws Exception {
457
473
scratch .overwriteFile (
458
474
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
459
475
"module(name='aaa')" ,
460
- "include('//java:MODULE.bazel.segment ')" ,
461
- "include('//python:MODULE.bazel.segment ')" );
476
+ "include('//java:java. MODULE.bazel')" ,
477
+ "include('//python:python. MODULE.bazel')" );
462
478
scratch .overwriteFile (rootDirectory .getRelative ("java/BUILD" ).getPathString ());
463
479
scratch .overwriteFile (
464
- rootDirectory .getRelative ("java/MODULE.bazel.segment " ).getPathString (),
480
+ rootDirectory .getRelative ("java/java. MODULE.bazel" ).getPathString (),
465
481
"bazel_dep(name='java-foo', version='1.0', repo_name='foo')" );
466
482
scratch .overwriteFile (rootDirectory .getRelative ("python/BUILD" ).getPathString ());
467
483
scratch .overwriteFile (
468
- rootDirectory .getRelative ("python/MODULE.bazel.segment " ).getPathString (),
484
+ rootDirectory .getRelative ("python/python. MODULE.bazel" ).getPathString (),
469
485
"bazel_dep(name='python-foo', version='1.0', repo_name='foo')" );
470
486
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
471
487
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
@@ -484,10 +500,10 @@ public void testRootModule_include_bad_tryingToLeakBindings() throws Exception {
484
500
rootDirectory .getRelative ("MODULE.bazel" ).getPathString (),
485
501
"module(name='aaa')" ,
486
502
"FOO_NAME = 'foo'" ,
487
- "include('//java:MODULE.bazel.segment ')" );
503
+ "include('//java:java. MODULE.bazel')" );
488
504
scratch .overwriteFile (rootDirectory .getRelative ("java/BUILD" ).getPathString ());
489
505
scratch .overwriteFile (
490
- rootDirectory .getRelative ("java/MODULE.bazel.segment " ).getPathString (),
506
+ rootDirectory .getRelative ("java/java. MODULE.bazel" ).getPathString (),
491
507
"bazel_dep(name=FOO_NAME, version='1.0')" );
492
508
FakeRegistry registry = registryFactory .newFakeRegistry ("/foo" );
493
509
ModuleFileFunction .REGISTRIES .set (differencer , ImmutableList .of (registry .getUrl ()));
0 commit comments