Apply the main repo mapping in `BuildIntegrationTestCase`
Some `get*` methods worked with apparent repo names, others didn't, which is a hurdle to contributions in this area (as observed while working on #24328).
Closes #24329.
PiperOrigin-RevId: 697548136
Change-Id: I24c3624875d1d1110ee8685656b88fffe3be6d95
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/util/BUILD b/src/test/java/com/google/devtools/build/lib/buildtool/util/BUILD
index 524f09c..8fd441e 100644
--- a/src/test/java/com/google/devtools/build/lib/buildtool/util/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/buildtool/util/BUILD
@@ -81,6 +81,7 @@
"//src/main/java/com/google/devtools/build/lib/skyframe:action_execution_value",
"//src/main/java/com/google/devtools/build/lib/skyframe:build_result_listener",
"//src/main/java/com/google/devtools/build/lib/skyframe:configured_target_and_data",
+ "//src/main/java/com/google/devtools/build/lib/skyframe:repository_mapping_value",
"//src/main/java/com/google/devtools/build/lib/skyframe:skyframe_cluster",
"//src/main/java/com/google/devtools/build/lib/skyframe:skymeld_module",
"//src/main/java/com/google/devtools/build/lib/standalone",
diff --git a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
index baa4346..60892ca 100644
--- a/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/buildtool/util/BuildIntegrationTestCase.java
@@ -70,6 +70,8 @@
import com.google.devtools.build.lib.buildtool.buildevent.BuildStartingEvent;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
+import com.google.devtools.build.lib.cmdline.RepositoryMapping;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventCollector;
@@ -114,6 +116,7 @@
import com.google.devtools.build.lib.skyframe.ActionExecutionValue;
import com.google.devtools.build.lib.skyframe.BuildResultListener;
import com.google.devtools.build.lib.skyframe.ConfiguredTargetAndData;
+import com.google.devtools.build.lib.skyframe.RepositoryMappingValue;
import com.google.devtools.build.lib.skyframe.SkyframeExecutor;
import com.google.devtools.build.lib.skyframe.SkymeldModule;
import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
@@ -755,7 +758,7 @@
InterruptedException,
TransitionException,
InvalidConfigurationException {
- getPackageManager().getTarget(events.reporter(), Label.parseCanonical(target));
+ getPackageManager().getTarget(events.reporter(), label(target));
return getSkyframeExecutor()
.getConfiguredTargetForTesting(events.reporter(), label(target), getTargetConfiguration());
}
@@ -847,8 +850,15 @@
}
/** Utility function: parse a string as a label. */
- protected static Label label(String labelString) throws LabelSyntaxException {
- return Label.parseCanonical(labelString);
+ protected Label label(String labelString) throws LabelSyntaxException, InterruptedException {
+ RepositoryMapping mainRepoMapping =
+ ((RepositoryMappingValue)
+ getSkyframeExecutor()
+ .getEvaluator()
+ .getExistingValue(RepositoryMappingValue.key(RepositoryName.MAIN)))
+ .repositoryMapping();
+ return Label.parseWithRepoContext(
+ labelString, Label.RepoContext.of(RepositoryName.MAIN, mainRepoMapping));
}
protected String run(Artifact executable, String... arguments) throws Exception {