-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn on Bzlmod for all
BuildViewTestCase
s
Notable changes: - No more injected PrecomputedValue boilerplate to enable Bzlmod; it's all built into BuildViewTestCase - All "mocked" repos are turned into builtin modules PiperOrigin-RevId: 573163786 Change-Id: I952bfa8b1cc964c2de4e90e58fb97140cd2475fd
- Loading branch information
1 parent
cfaefb9
commit d51144c
Showing
50 changed files
with
342 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,20 +22,9 @@ | |
import com.google.devtools.build.lib.actions.Action; | ||
import com.google.devtools.build.lib.actions.CommandLineExpansionException; | ||
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; | ||
import com.google.devtools.build.lib.bazel.bzlmod.BazelLockFileFunction; | ||
import com.google.devtools.build.lib.bazel.bzlmod.BazelModuleResolutionFunction; | ||
import com.google.devtools.build.lib.bazel.bzlmod.FakeRegistry; | ||
import com.google.devtools.build.lib.bazel.bzlmod.ModuleFileFunction; | ||
import com.google.devtools.build.lib.bazel.bzlmod.YankedVersionsUtil; | ||
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.BazelCompatibilityMode; | ||
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.CheckDirectDepsMode; | ||
import com.google.devtools.build.lib.bazel.repository.RepositoryOptions.LockfileMode; | ||
import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryDirtinessChecker; | ||
import com.google.devtools.build.lib.skyframe.PrecomputedValue; | ||
import com.google.devtools.build.lib.skyframe.PrecomputedValue.Injected; | ||
import com.google.devtools.build.lib.skyframe.SkyframeExecutorRepositoryHelpersHolder; | ||
import com.google.devtools.build.lib.util.Fingerprint; | ||
import com.google.devtools.build.lib.vfs.Path; | ||
import com.google.devtools.build.lib.vfs.PathFragment; | ||
import java.util.Map.Entry; | ||
import net.starlark.java.eval.EvalException; | ||
|
@@ -48,25 +37,6 @@ | |
/** Tests that the repo mapping manifest file is properly generated for runfiles. */ | ||
@RunWith(JUnit4.class) | ||
public class RunfilesRepoMappingManifestTest extends BuildViewTestCase { | ||
private Path moduleRoot; | ||
private FakeRegistry registry; | ||
|
||
@Override | ||
protected ImmutableList<Injected> extraPrecomputedValues() throws Exception { | ||
moduleRoot = scratch.dir("modules"); | ||
registry = FakeRegistry.DEFAULT_FACTORY.newFakeRegistry(moduleRoot.getPathString()); | ||
return ImmutableList.of( | ||
PrecomputedValue.injected( | ||
ModuleFileFunction.REGISTRIES, ImmutableList.of(registry.getUrl())), | ||
PrecomputedValue.injected(ModuleFileFunction.IGNORE_DEV_DEPS, false), | ||
PrecomputedValue.injected(ModuleFileFunction.MODULE_OVERRIDES, ImmutableMap.of()), | ||
PrecomputedValue.injected( | ||
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING), | ||
PrecomputedValue.injected( | ||
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR), | ||
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE), | ||
PrecomputedValue.injected(YankedVersionsUtil.ALLOWED_YANKED_VERSIONS, ImmutableList.of())); | ||
} | ||
|
||
@Override | ||
protected SkyframeExecutorRepositoryHelpersHolder getRepositoryHelpersHolder() { | ||
|
@@ -76,11 +46,6 @@ protected SkyframeExecutorRepositoryHelpersHolder getRepositoryHelpersHolder() { | |
new RepositoryDirectoryDirtinessChecker()); | ||
} | ||
|
||
@Before | ||
public void enableBzlmod() throws Exception { | ||
setBuildLanguageOptions("--enable_bzlmod"); | ||
} | ||
|
||
/** | ||
* Sets up a Bazel module [email protected], which provides a bare_binary rule that passes along | ||
* runfiles in the data attribute, and does nothing else. | ||
|
@@ -269,6 +234,7 @@ public void actionRerunsOnRepoMappingChange_workspaceName() throws Exception { | |
"bazel_dep(name='bare_rule',version='1.0')"); | ||
scratch.overwriteFile( | ||
"BUILD", "load('@bare_rule//:defs.bzl', 'bare_binary')", "bare_binary(name='aaa')"); | ||
invalidatePackages(); | ||
|
||
RepoMappingManifestAction actionBeforeChange = getRepoMappingManifestActionForTarget("//:aaa"); | ||
|
||
|
@@ -288,6 +254,7 @@ public void actionRerunsOnRepoMappingChange_repoName() throws Exception { | |
"bazel_dep(name='bare_rule',version='1.0')"); | ||
scratch.overwriteFile( | ||
"BUILD", "load('@bare_rule//:defs.bzl', 'bare_binary')", "bare_binary(name='aaa')"); | ||
invalidatePackages(); | ||
|
||
RepoMappingManifestAction actionBeforeChange = getRepoMappingManifestActionForTarget("//:aaa"); | ||
|
||
|
@@ -320,6 +287,7 @@ public void actionRerunsOnRepoMappingChange_newEntry() throws Exception { | |
scratch.overwriteFile(moduleRoot.getRelative("bbb~1.0").getRelative("BUILD").getPathString()); | ||
scratch.overwriteFile( | ||
moduleRoot.getRelative("bbb~1.0").getRelative("def.bzl").getPathString(), "BBB = '1'"); | ||
invalidatePackages(); | ||
|
||
RepoMappingManifestAction actionBeforeChange = getRepoMappingManifestActionForTarget("//:aaa"); | ||
|
||
|
@@ -391,6 +359,7 @@ public void hasMappingForSymlinks() throws Exception { | |
moduleRoot.getRelative("ddd~1.0/BUILD").getPathString(), | ||
"load('@bare_rule//:defs.bzl', 'bare_binary')", | ||
"bare_binary(name='ddd')"); | ||
invalidatePackages(); | ||
|
||
RunfilesSupport runfilesSupport = getRunfilesSupport("@aaa~1.0//:aaa"); | ||
ImmutableList<String> runfilesPaths = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.