Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion llvm/lib/Support/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ class llvm::vfs::RedirectingFileSystemParser {
EC = FS->makeAbsolute(FullPath, Name);
Name = canonicalize(Name);
} else {
EC = sys::fs::make_absolute(Name);
EC = FS->makeAbsolute(Name);
}
if (EC) {
assert(NameValueNode && "Name presence should be checked earlier");
Expand Down
31 changes: 30 additions & 1 deletion llvm/unittests/Support/VirtualFileSystemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1941,7 +1941,7 @@ TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
EXPECT_EQ(0, NumDiagnostics);
}

TEST_F(VFSFromYAMLTest, RootRelativeTest) {
TEST_F(VFSFromYAMLTest, RootRelativeToOverlayDirTest) {
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
Lower->addDirectory("//root/foo/bar");
Lower->addRegularFile("//root/foo/bar/a");
Expand Down Expand Up @@ -2004,6 +2004,35 @@ TEST_F(VFSFromYAMLTest, RootRelativeTest) {
#endif
}

TEST_F(VFSFromYAMLTest, RootRelativeToCWDTest) {
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
Lower->addDirectory("//root/foo/bar");
Lower->addRegularFile("//root/foo/bar/a");
Lower->addDirectory("//root/foo/bar/cwd");
Lower->addRegularFile("//root/foo/bar/cwd/a");
Lower->setCurrentWorkingDirectory("//root/foo/bar/cwd");
IntrusiveRefCntPtr<vfs::FileSystem> FS =
getFromYAMLString("{\n"
" 'case-sensitive': false,\n"
" 'root-relative': 'cwd',\n"
" 'roots': [\n"
" { 'name': 'b', 'type': 'file',\n"
" 'external-contents': '//root/foo/bar/a'\n"
" }\n"
" ]\n"
"}",
Lower, "//root/foo/bar/overlay");

ASSERT_NE(FS.get(), nullptr);

ErrorOr<vfs::Status> S1 = FS->status("//root/foo/bar/b");
ASSERT_TRUE(S1.getError());

ErrorOr<vfs::Status> S2 = FS->status("//root/foo/bar/cwd/b");
ASSERT_FALSE(S2.getError());
EXPECT_EQ("//root/foo/bar/a", S2->getName());
}

TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
BaseFS->addFile("//root/foo/realname", 0,
Expand Down
Loading