Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate lockfile entry when the extension name prefix changes #23527

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ SingleExtensionUsagesValue trimForEvaluation() {
return SingleExtensionUsagesValue.create(
ImmutableMap.copyOf(
Maps.transformValues(getExtensionUsages(), ModuleExtensionUsage::trimForEvaluation)),
// extensionUniqueName: Not accessible to the extension's implementation function.
// TODO: Reconsider this when resolving #19055.
"",
getExtensionUniqueName(),
getAbridgedModules(),
// repoMappings: The usage of repo mappings by the extension's implementation function is
// tracked on the level of individual entries and all label attributes are provided as
Expand Down
56 changes: 56 additions & 0 deletions src/test/py/bazel/bzlmod/bazel_lockfile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2597,6 +2597,62 @@ def testModuleExtensionRerunsOnGetenvChanges(self):
stderr = '\n'.join(stderr)
self.assertIn('LAZYEVAL_KEY=None', stderr)

def testModuleExtensionRerunsOnUniqueNameChange(self):
self.ScratchFile(
'MODULE.bazel',
[
'my_ext_1 = use_extension("//:ext1.bzl","my_ext")',
'use_repo(my_ext_1, "foo")',
],
)
self.ScratchFile('BUILD.bazel')
self.ScratchFile(
'ext1.bzl',
[
'def _my_repo_impl(ctx):',
' ctx.file("REPO.bazel")',
' ctx.file("BUILD")',
' ctx.file("hi.txt", "hi")',
' if ctx.attr.label:',
' print("label: {}".format(ctx.attr.label))',
'my_repo = repository_rule(',
' implementation=_my_repo_impl,',
' attrs={"label": attr.label()}',
')',
'def _my_ext_impl(ctx):',
' my_repo(name="foo",label="@bar")',
' my_repo(name="bar")',
'my_ext = module_extension(implementation=_my_ext_impl)',
],
)
self.ScratchFile(
'ext2.bzl',
[
'load(":ext1.bzl", "my_repo")',
'def _my_ext_impl(ctx):',
' my_repo(name="foo")',
'my_ext = module_extension(implementation=_my_ext_impl)',
]
)

_, _, stderr = self.RunBazel(['build', '@foo//:all'])
stderr = '\n'.join(stderr)
self.assertIn('label: @@+my_ext+bar//:bar\n', stderr)

self.ScratchFile(
'MODULE.bazel',
[
'my_ext_2 = use_extension("//:ext2.bzl","my_ext")',
'use_repo(my_ext_2, other_foo = "foo")',
'my_ext_1 = use_extension("//:ext1.bzl","my_ext")',
'use_repo(my_ext_1, "foo")',
],
)

_, _, stderr = self.RunBazel(['build', '@foo//:all'])
stderr = '\n'.join(stderr)
self.assertIn('label: @@+my_ext2+bar//:bar\n', stderr)


if __name__ == '__main__':
absltest.main()
10 changes: 5 additions & 5 deletions src/test/tools/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading