@@ -103,8 +103,7 @@ public RepositoryMappingValue withMappingForRootModule(
103
103
104
104
@ Test
105
105
public void testSimpleMapping () throws Exception {
106
- scratch .overwriteFile (
107
- "WORKSPACE" ,
106
+ rewriteWorkspace (
108
107
"workspace(name = 'good')" ,
109
108
"local_repository(" ,
110
109
" name = 'a_remote_repo'," ,
@@ -316,8 +315,7 @@ public void testRepoNameMapping_multipleVersionOverride_lookup() throws Exceptio
316
315
317
316
@ Test
318
317
public void testMultipleRepositoriesWithMapping () throws Exception {
319
- scratch .overwriteFile (
320
- "WORKSPACE" ,
318
+ rewriteWorkspace (
321
319
"workspace(name = 'good')" ,
322
320
"local_repository(" ,
323
321
" name = 'a_remote_repo'," ,
@@ -356,8 +354,7 @@ public void testMultipleRepositoriesWithMapping() throws Exception {
356
354
357
355
@ Test
358
356
public void testRepositoryWithMultipleMappings () throws Exception {
359
- scratch .overwriteFile (
360
- "WORKSPACE" ,
357
+ rewriteWorkspace (
361
358
"workspace(name = 'good')" ,
362
359
"local_repository(" ,
363
360
" name = 'a_remote_repo'," ,
@@ -381,9 +378,8 @@ public void testRepositoryWithMultipleMappings() throws Exception {
381
378
}
382
379
383
380
@ Test
384
- public void testMixtureOfBothSystems () throws Exception {
385
- scratch .overwriteFile (
386
- "WORKSPACE" ,
381
+ public void testMixtureOfBothSystems_workspaceRepo () throws Exception {
382
+ rewriteWorkspace (
387
383
"workspace(name = 'root')" ,
388
384
"local_repository(" ,
389
385
" name = 'ws_repo'," ,
@@ -433,6 +429,72 @@ public void testMixtureOfBothSystems() throws Exception {
433
429
.build ()));
434
430
}
435
431
432
+ @ Test
433
+ public void testMixtureOfBothSystems_mainRepo () throws Exception {
434
+ rewriteWorkspace (
435
+ "workspace(name = 'root')" ,
436
+ "local_repository(" ,
437
+ " name = 'ws_repo'," ,
438
+ " path = '/ws_repo'," ,
439
+ ")" );
440
+ scratch .overwriteFile (
441
+ "MODULE.bazel" , "module(name='A',version='0.1')" , "bazel_dep(name='B',version='1.0')" );
442
+ registry
443
+ .addModule (
444
+ createModuleKey ("B" , "1.0" ),
445
+ "module(name='B', version='1.0');bazel_dep(name='C', version='2.0')" )
446
+ .addModule (createModuleKey ("C" , "2.0" ), "module(name='C', version='2.0')" );
447
+
448
+ SkyKey skyKey = RepositoryMappingValue .key (RepositoryName .MAIN );
449
+ assertThatEvaluationResult (eval (skyKey ))
450
+ .hasEntryThat (skyKey )
451
+ .isEqualTo (
452
+ withMappingForRootModule (
453
+ ImmutableMap .of (
454
+ RepositoryName .MAIN ,
455
+ RepositoryName .MAIN ,
456
+ RepositoryName .create ("@A" ),
457
+ RepositoryName .MAIN ,
458
+ RepositoryName .create ("@B" ),
459
+ RepositoryName .create ("@B.1.0" ),
460
+ RepositoryName .create ("@root" ),
461
+ RepositoryName .create ("@root" ),
462
+ RepositoryName .create ("@ws_repo" ),
463
+ RepositoryName .create ("@ws_repo" )),
464
+ RepositoryName .MAIN ));
465
+ }
466
+
467
+ @ Test
468
+ public void testMixtureOfBothSystems_mainRepo_shouldNotSeeWorkspaceRepos () throws Exception {
469
+ rewriteWorkspace (
470
+ "workspace(name = 'root')" ,
471
+ "local_repository(" ,
472
+ " name = 'ws_repo'," ,
473
+ " path = '/ws_repo'," ,
474
+ ")" );
475
+ scratch .overwriteFile (
476
+ "MODULE.bazel" , "module(name='A',version='0.1')" , "bazel_dep(name='B',version='1.0')" );
477
+ registry
478
+ .addModule (
479
+ createModuleKey ("B" , "1.0" ),
480
+ "module(name='B', version='1.0');bazel_dep(name='C', version='2.0')" )
481
+ .addModule (createModuleKey ("C" , "2.0" ), "module(name='C', version='2.0')" );
482
+
483
+ SkyKey skyKey = RepositoryMappingValue .KEY_FOR_ROOT_MODULE_WITHOUT_WORKSPACE_REPOS ;
484
+ assertThatEvaluationResult (eval (skyKey ))
485
+ .hasEntryThat (skyKey )
486
+ .isEqualTo (
487
+ withMapping (
488
+ ImmutableMap .of (
489
+ RepositoryName .MAIN ,
490
+ RepositoryName .MAIN ,
491
+ RepositoryName .create ("@A" ),
492
+ RepositoryName .MAIN ,
493
+ RepositoryName .create ("@B" ),
494
+ RepositoryName .create ("@B.1.0" )),
495
+ RepositoryName .MAIN ));
496
+ }
497
+
436
498
@ Test
437
499
public void testErrorWithMapping () throws Exception {
438
500
reporter .removeHandler (failFastHandler );
0 commit comments