Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Apr 17, 2024
1 parent fad6e29 commit de3b782
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public Optional<byte[]> downloadAndRecord(URI uri, Registry.Downloader downloade
// Local files are out of scope for the lockfile.
return downloader.download(uri, Optional.empty());
}
// We use a two-step lookup below to avoid copying around the entries of the
// potentially large knownFiles map.
Optional<Checksum> knownChecksum = knownFiles.get(uri);
if (knownChecksum == null) {
// This should never happen since every file is only ever downloaded once,
// but just in case, we'll check the requested files as well.
knownChecksum = requestedFiles.get(uri);
}

Expand Down
33 changes: 33 additions & 0 deletions src/test/py/bazel/bzlmod/bazel_lockfile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,39 @@ def testChangeModuleInRegistryWithLockfile(self):
# Even adding a new dependency should not fail due to the registry change
self.RunBazel(['build', '--nobuild', '//:all'])

def testAddModuleToRegistryWithLockfile(self):
# Create a project with deps on the BCR's 'platforms' module
self.ScratchFile(
'MODULE.bazel',
[
'bazel_dep(name = "platforms", version = "0.0.9")',
],
)
self.ScratchFile('BUILD', ['filegroup(name = "hello")'])
self.RunBazel(['build', '--nobuild', '//:all'])

# Add a broken 'platforms' module to the first registry
module_dir = self.main_registry.root.joinpath('modules', 'platforms', '0.0.9')
scratchFile(module_dir.joinpath('MODULE.bazel'), ['whatever!'])

# Shutdown bazel to empty any cache of the deps tree
self.RunBazel(['shutdown'])
# Running with the lockfile, should not recognize the registry changes
# hence find no errors
self.RunBazel(['build', '--nobuild', '//:all'])

self.ScratchFile(
'MODULE.bazel',
[
'bazel_dep(name = "platforms", version = "0.0.9")',
'bazel_dep(name = "bbb", version = "1.1")',
],
)
# Shutdown bazel to empty any cache of the deps tree
self.RunBazel(['shutdown'])
# Even adding a new dependency should not fail due to the registry change
self.RunBazel(['build', '--nobuild', '//:all'])

def testChangeFlagWithLockfile(self):
# Create a project with an outdated direct dep on aaa
self.ScratchFile(
Expand Down

0 comments on commit de3b782

Please sign in to comment.