Skip to content
Open
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 @@ -542,7 +542,8 @@ public PathFragment resolveOneLink(PathFragment path) throws IOException {

@Override
public Path resolveSymbolicLinks(PathFragment path) throws IOException {
return fsForPath(path).resolveSymbolicLinks(path);
// Ensure that the return value doesn't leave the overlay file system.
return getPath(fsForPath(path).resolveSymbolicLinks(path).asFragment());
}

@Nullable
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/google/devtools/build/lib/vfs/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,8 @@ public void prefetchPackageAsync(int maxDirs) {
private void checkSameFileSystem(Path that) {
if (this.fileSystem != that.fileSystem) {
throw new IllegalArgumentException(
"Files are on different filesystems: " + this + ", " + that);
"Files are on different filesystems: %s (on %s), %s (on %s)"
.formatted(this, this.fileSystem, that, that.fileSystem));
}
}
}
21 changes: 18 additions & 3 deletions src/test/py/bazel/bzlmod/remote_repo_contents_cache_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,11 @@ def testUseRepoFileInBuildRule_actionUsesCache(self):
with open(self.Path('bazel-bin/main/out.txt')) as f:
self.assertEqual(f.read(), 'hello')

def testUseRepoFileInBuildRule_actionDoesNotUseCache(self):
def do_testUseRepoFileInBuildRule_actionDoesNotUseCache(
self, extra_flags=None
):
if extra_flags is None:
extra_flags = []
self.ScratchFile(
'MODULE.bazel',
[
Expand Down Expand Up @@ -518,7 +522,7 @@ def testUseRepoFileInBuildRule_actionDoesNotUseCache(self):
repo_dir = self.RepoDir('my_repo')

# First fetch: not cached
_, _, stderr = self.RunBazel(['build', '//main:use_data'])
_, _, stderr = self.RunBazel(['build', '//main:use_data'] + extra_flags)
self.assertIn('JUST FETCHED', '\n'.join(stderr))
self.assertTrue(os.path.exists(os.path.join(repo_dir, 'BUILD')))
self.assertTrue(os.path.exists(os.path.join(repo_dir, 'data.txt')))
Expand All @@ -528,14 +532,25 @@ def testUseRepoFileInBuildRule_actionDoesNotUseCache(self):

# After expunging: repo and build action cached
self.RunBazel(['clean', '--expunge'])
_, _, stderr = self.RunBazel(['build', '//main:use_data'])
_, _, stderr = self.RunBazel(['build', '//main:use_data'] + extra_flags)
self.assertNotIn('JUST FETCHED', '\n'.join(stderr))
self.assertFalse(os.path.exists(os.path.join(repo_dir, 'BUILD')))
self.assertTrue(os.path.exists(os.path.join(repo_dir, 'data.txt')))
self.assertTrue(os.path.exists(self.Path('bazel-bin/main/out.txt')))
with open(self.Path('bazel-bin/main/out.txt')) as f:
self.assertEqual(f.read(), 'hello')

def testUseRepoFileInBuildRule_actionDoesNotUseCache(self):
self.do_testUseRepoFileInBuildRule_actionDoesNotUseCache()

def testUseRepoFileInBuildRule_actionDoesNotUseCache_withExplicitSandboxBase(
self,
):
tmpdir = self.ScratchDir('sandbox_base')
self.do_testUseRepoFileInBuildRule_actionDoesNotUseCache(
extra_flags=['--sandbox_base=' + tmpdir]
)

def testLostRemoteFile_build(self):
# Create a repo with two BUILD files (one in a subpackage), build a target
# from one to cause it to be cached, then build that target again after
Expand Down