Skip to content

Commit

Permalink
inline a function
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy committed Aug 19, 2024
1 parent 28f76ac commit 161c4ae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,6 @@ public static AnalysisMock get() {
}
}

public static AnalysisMock getAnalysisMockWithMinimalBuiltinModules() {
return new AnalysisMock.Delegate(AnalysisMock.get()) {
@Override
public ImmutableMap<String, NonRegistryOverride> getBuiltinModules(
BlazeDirectories directories) {
return ImmutableMap.of("bazel_tools", LocalPathOverride.create(
directories
.getWorkingDirectory()
.getRelative("embedded_tools")
.getPathString()),
"platforms", LocalPathOverride.create(
directories
.getWorkingDirectory()
.getRelative("platforms_workspace")
.getPathString()));
}
};
}

public static AnalysisMock getAnalysisMockWithoutBuiltinModules() {
return new AnalysisMock.Delegate(AnalysisMock.get()) {
@Override
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/google/devtools/build/lib/skyframe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,9 @@ java_test(
srcs = ["RepositoryMappingFunctionTest.java"],
deps = [
":testutil",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_directories",
"//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:common",
"//src/main/java/com/google/devtools/build/lib/bazel/bzlmod:resolution",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/skyframe:repository_mapping_value",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.testing.EqualsTester;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.bazel.bzlmod.LocalPathOverride;
import com.google.devtools.build.lib.bazel.bzlmod.NonRegistryOverride;
import com.google.devtools.build.lib.bazel.bzlmod.Version;
import com.google.devtools.build.lib.cmdline.RepositoryMapping;
import com.google.devtools.build.lib.cmdline.RepositoryName;
Expand Down Expand Up @@ -58,8 +61,23 @@ private EvaluationResult<RepositoryMappingValue> eval(SkyKey key)

@Override
protected AnalysisMock getAnalysisMock() {
// Make sure we don't have built-in modules affecting the dependency graph.
return AnalysisMock.getAnalysisMockWithMinimalBuiltinModules();
// Make sure we have minimal built-in modules affecting the dependency graph.
return new AnalysisMock.Delegate(AnalysisMock.get()) {
@Override
public ImmutableMap<String, NonRegistryOverride> getBuiltinModules(
BlazeDirectories directories) {
return ImmutableMap.of("bazel_tools", LocalPathOverride.create(
directories
.getWorkingDirectory()
.getRelative("embedded_tools")
.getPathString()),
"platforms", LocalPathOverride.create(
directories
.getWorkingDirectory()
.getRelative("platforms_workspace")
.getPathString()));
}
};
}

private static RepositoryMappingValue valueForWorkspace(
Expand Down

0 comments on commit 161c4ae

Please sign in to comment.