-
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.
- Loading branch information
Showing
6 changed files
with
98 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,17 @@ | |
from src.test.py.bazel.bzlmod.test_utils import BazelRegistry | ||
from src.test.py.bazel.bzlmod.test_utils import scratchFile | ||
|
||
_OVERRIDE = """ | ||
archive_override( | ||
integrity = "sha256-L9ASXKv/pEv9VKLmueHxobnl5aCWk4MNTZywE0MKIe4=", | ||
module_name = "rules_cc", | ||
strip_prefix = "rules_cc-ffaaf6bfb168eef354ae3b089085ccb86b47d1da", | ||
urls = [ | ||
"https://github.com/keith/rules_cc/archive/ffaaf6bfb168eef354ae3b089085ccb86b47d1da.tar.gz", | ||
], | ||
) | ||
""" | ||
|
||
|
||
class BazelModuleTest(test_base.TestBase): | ||
|
||
|
@@ -109,6 +120,7 @@ def writeMainProjectFiles(self): | |
|
||
def testSimple(self): | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.0")', | ||
]) | ||
self.ScratchFile('BUILD', [ | ||
|
@@ -129,6 +141,7 @@ def testSimple(self): | |
|
||
def testSimpleTransitive(self): | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "bbb", version = "1.0")', | ||
]) | ||
self.ScratchFile('BUILD', [ | ||
|
@@ -153,6 +166,7 @@ def testSimpleDiamond(self): | |
self.ScratchFile( | ||
'MODULE.bazel', | ||
[ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1")', | ||
# [email protected] has to depend on [email protected] after MVS. | ||
'bazel_dep(name = "bbb", version = "1.0")', | ||
|
@@ -167,6 +181,7 @@ def testSingleVersionOverrideWithPatch(self): | |
self.ScratchFile( | ||
'MODULE.bazel', | ||
[ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1")', | ||
'bazel_dep(name = "bbb", version = "1.1")', | ||
# Both main and [email protected] has to depend on the locally patched [email protected] | ||
|
@@ -189,6 +204,7 @@ def testRegistryOverride(self): | |
' from another registry') | ||
another_registry.createCcModule('aaa', '1.0') | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.0")', | ||
'bazel_dep(name = "bbb", version = "1.0")', | ||
'single_version_override(', | ||
|
@@ -205,6 +221,7 @@ def testArchiveOverride(self): | |
self.writeMainProjectFiles() | ||
archive_aaa_1_0 = self.main_registry.archives.joinpath('aaa.1.0.zip') | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1")', | ||
'bazel_dep(name = "bbb", version = "1.1")', | ||
'archive_override(', | ||
|
@@ -240,6 +257,7 @@ def testGitOverride(self): | |
commit = stdout[0].strip() | ||
|
||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1")', | ||
'bazel_dep(name = "bbb", version = "1.1")', | ||
'git_override(', | ||
|
@@ -259,6 +277,7 @@ def testLocalPathOverride(self): | |
src_aaa_1_0 = self.main_registry.projects.joinpath('aaa', '1.0') | ||
self.writeMainProjectFiles() | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1")', | ||
'bazel_dep(name = "bbb", version = "1.1")', | ||
'local_path_override(', | ||
|
@@ -287,6 +306,7 @@ def testRemotePatchForBazelDep(self): | |
self.main_registry.createCcModule( | ||
'aaa', '1.1-1', patches=[patch_file], patch_strip=1) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.1-1")', | ||
]) | ||
self.ScratchFile('BUILD', [ | ||
|
@@ -310,6 +330,7 @@ def testRepoNameForBazelDep(self): | |
self.ScratchFile( | ||
'MODULE.bazel', | ||
[ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.0", repo_name = "my_repo_a_name")', | ||
# bbb should still be able to access aaa as com_foo_aaa | ||
'bazel_dep(name = "bbb", version = "1.0")', | ||
|
@@ -332,6 +353,7 @@ def testRepoNameForBazelDep(self): | |
def testCheckDirectDependencies(self): | ||
self.writeMainProjectFiles() | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "aaa", version = "1.0")', | ||
'bazel_dep(name = "bbb", version = "1.0")', | ||
'bazel_dep(name = "ccc", version = "1.1")', | ||
|
@@ -362,6 +384,7 @@ def testCheckDirectDependencies(self): | |
|
||
def testRepositoryRuleErrorInModuleExtensionFailsTheBuild(self): | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'module_ext = use_extension("//pkg:extension.bzl", "module_ext")', | ||
'use_repo(module_ext, "foo")', | ||
]) | ||
|
@@ -391,6 +414,7 @@ def testRepositoryRuleErrorInModuleExtensionFailsTheBuild(self): | |
|
||
def testCommandLineModuleOverride(self): | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "ss", version = "1.0")', | ||
'local_path_override(', | ||
' module_name = "ss",', | ||
|
@@ -429,6 +453,7 @@ def testDownload(self): | |
data_path = self.ScratchFile('data.txt', ['some data']) | ||
data_url = pathlib.Path(data_path).resolve().as_uri() | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'data_ext = use_extension("//:ext.bzl", "data_ext")', | ||
'use_repo(data_ext, "no_op")', | ||
]) | ||
|
@@ -454,6 +479,7 @@ def testNonRegistryOverriddenModulesIgnoreYanked(self): | |
self.writeBazelrcFile(allow_yanked_versions=False) | ||
src_yanked1 = self.main_registry.projects.joinpath('yanked1', '1.0') | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "yanked1", version = "1.0")', 'local_path_override(', | ||
' module_name = "yanked1",', | ||
' path = "%s",' % str(src_yanked1.resolve()).replace('\\', '/'), ')' | ||
|
@@ -471,6 +497,7 @@ def testNonRegistryOverriddenModulesIgnoreYanked(self): | |
def testContainingYankedDepFails(self): | ||
self.writeBazelrcFile(allow_yanked_versions=False) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "yanked1", version = "1.0")', | ||
]) | ||
self.ScratchFile('WORKSPACE') | ||
|
@@ -491,6 +518,7 @@ def testContainingYankedDepFails(self): | |
def testAllowedYankedDepsSuccessByFlag(self): | ||
self.writeBazelrcFile(allow_yanked_versions=False) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "ddd", version = "1.0")', | ||
]) | ||
self.ScratchFile('WORKSPACE') | ||
|
@@ -510,6 +538,7 @@ def testAllowedYankedDepsSuccessByFlag(self): | |
def testAllowedYankedDepsByEnvVar(self): | ||
self.writeBazelrcFile(allow_yanked_versions=False) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "ddd", version = "1.0")', | ||
]) | ||
self.ScratchFile('WORKSPACE') | ||
|
@@ -538,6 +567,7 @@ def testAllowedYankedDepsByEnvVar(self): | |
def testAllowedYankedDepsSuccessMix(self): | ||
self.writeBazelrcFile(allow_yanked_versions=False) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "ddd", version = "1.0")', | ||
]) | ||
self.ScratchFile('WORKSPACE') | ||
|
@@ -566,6 +596,7 @@ def setUpProjectWithLocalRegistryModule(self, dep_name, dep_version): | |
'}', | ||
]) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name = "%s", version = "%s")' % (dep_name, dep_version), | ||
]) | ||
self.ScratchFile('BUILD', [ | ||
|
@@ -621,6 +652,7 @@ def testRunfilesRepoMappingManifest(self): | |
|
||
# Now set up a project tree shaped like a diamond | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'module(name="me",version="1.0")', | ||
'bazel_dep(name="foo",version="1.0")', | ||
'bazel_dep(name="bar",version="2.0")', | ||
|
@@ -747,7 +779,10 @@ def testBashRunfilesLibraryRepoMapping(self): | |
""".splitlines()) | ||
os.chmod(test_script, 0o755) | ||
|
||
self.ScratchFile('MODULE.bazel', ['bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('MODULE.bazel', [ | ||
|
||
_OVERRIDE, | ||
'bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('WORKSPACE') | ||
|
||
# Run sandboxed on Linux and macOS. | ||
|
@@ -804,7 +839,9 @@ def testCppRunfilesLibraryRepoMapping(self): | |
'}', | ||
]) | ||
|
||
self.ScratchFile('MODULE.bazel', ['bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('WORKSPACE') | ||
|
||
# Run sandboxed on Linux and macOS. | ||
|
@@ -867,7 +904,9 @@ def testJavaRunfilesLibraryRepoMapping(self): | |
'}', | ||
]) | ||
|
||
self.ScratchFile('MODULE.bazel', ['bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('MODULE.bazel', [ | ||
_OVERRIDE, | ||
'bazel_dep(name="test",version="1.0")']) | ||
self.ScratchFile('WORKSPACE') | ||
|
||
# Run sandboxed on Linux and macOS. | ||
|
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