Skip to content

Commit

Permalink
Fix inconsistent dep graph stubs in Bzlmod tests
Browse files Browse the repository at this point in the history
These cause failures when relying on `depGraph` containing `ModuleKey`s for all modules, which is the case in production.

Work towards #20997

Closes #21037.

PiperOrigin-RevId: 601822357
Change-Id: Ifcad9d7b73835491c1f1fca975e05834057a6825
  • Loading branch information
fmeum authored and copybara-github committed Jan 26, 2024
1 parent 57c1801 commit 27419e3
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ private static ModuleExtensionUsage createModuleExtensionUsage(

@Test
public void createValue_moduleExtensions() throws Exception {
ModuleKey rjeKey = createModuleKey("rules_jvm_external", "1.0");
ModuleKey rpyKey = createModuleKey("rules_python", "2.0");
Module root =
buildModule("root", "1.0")
.setKey(ModuleKey.ROOT)
.addDep("rje", createModuleKey("rules_jvm_external", "1.0"))
.addDep("rpy", createModuleKey("rules_python", "2.0"))
.addDep("rje", rjeKey)
.addDep("rpy", rpyKey)
.addExtensionUsage(
createModuleExtensionUsage("@rje//:defs.bzl", "maven", "av", "autovalue"))
.addExtensionUsage(
Expand All @@ -240,15 +242,24 @@ public void createValue_moduleExtensions() throws Exception {
Module dep =
buildModule("dep", "2.0")
.setKey(depKey)
.addDep("rules_python", createModuleKey("rules_python", "2.0"))
.addDep("rules_python", rpyKey)
.addExtensionUsage(
createModuleExtensionUsage("@rules_python//:defs.bzl", "pip", "np", "numpy"))
.addExtensionUsage(
createModuleExtensionUsage("//:defs.bzl", "myext", "oneext", "myext"))
.addExtensionUsage(
createModuleExtensionUsage("//incredible:conflict.bzl", "myext", "twoext", "myext"))
.build();
ImmutableMap<ModuleKey, Module> depGraph = ImmutableMap.of(ModuleKey.ROOT, root, depKey, dep);
ImmutableMap<ModuleKey, Module> depGraph =
ImmutableMap.of(
ModuleKey.ROOT,
root,
depKey,
dep,
rjeKey,
buildModule("rules_jvm_external", "1.0").setKey(rjeKey).build(),
rpyKey,
buildModule("rules_python", "2.0").setKey(rpyKey).build());

ModuleExtensionId maven =
ModuleExtensionId.create(
Expand Down Expand Up @@ -326,6 +337,7 @@ public void createValue_moduleExtensions() throws Exception {
public void useExtensionBadLabelFails() throws Exception {
Module root =
buildModule("module", "1.0")
.setKey(ModuleKey.ROOT)
.addExtensionUsage(createModuleExtensionUsage("@foo//:defs.bzl", "bar"))
.build();
ImmutableMap<ModuleKey, Module> depGraph = ImmutableMap.of(ModuleKey.ROOT, root);
Expand Down

0 comments on commit 27419e3

Please sign in to comment.