bzlmod: Refactor repository mapping with a new class
To support strict repository dependency in Bzlmod, we need to distinguish repo mapping behaviour between repos generated from Bzlmod and WORKSPACE, therefore we have to refactor the repo mapping from a ImmutableMap to the RepositoryMapping class.
Working towards: https://github.com/bazelbuild/bazel/issues/13793
Related: https://github.com/bazelbuild/bazel/issues/13316
RELNOTES: None
PiperOrigin-RevId: 394180770
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderTest.java b/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderTest.java
index 2e92de0..fdf64e6 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/LocationExpanderTest.java
@@ -18,6 +18,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.LocationExpander.LocationFunction;
+import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import java.util.ArrayList;
import java.util.List;
@@ -73,7 +74,7 @@
ImmutableMap.<String, LocationFunction>of(
"location", f1,
"locations", f2),
- ImmutableMap.of());
+ RepositoryMapping.ALWAYS_FALLBACK);
}
private String expand(String input) throws Exception {
@@ -133,10 +134,11 @@
RepositoryName.create("@foo"),
RepositoryName.create("@bar"));
- LocationExpander locationExpander = new LocationExpander(
- new Capture(),
- ImmutableMap.<String, LocationFunction>of("location", f1),
- repositoryMapping);
+ LocationExpander locationExpander =
+ new LocationExpander(
+ new Capture(),
+ ImmutableMap.<String, LocationFunction>of("location", f1),
+ RepositoryMapping.createAllowingFallback(repositoryMapping));
String value = locationExpander.expand("$(location @foo//a)");
assertThat(value).isEqualTo("src/a");