Skip to content

[llvm][vfs] Fix merge from llvm.org/main in VirtualFileSystemTest #11108

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

Merged
merged 1 commit into from
Aug 4, 2025
Merged
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
122 changes: 0 additions & 122 deletions llvm/unittests/Support/VirtualFileSystemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3306,128 +3306,6 @@ TEST(RedirectingFileSystemTest, PrintOutput) {
Output);
}

TEST(RedirectingFileSystemTest, Exists) {
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
auto YAML =
MemoryBuffer::getMemBuffer("{\n"
" 'version': 0,\n"
" 'roots': [\n"
" {\n"
" 'type': 'directory-remap',\n"
" 'name': '/dremap',\n"
" 'external-contents': '/a',\n"
" },"
" {\n"
" 'type': 'directory-remap',\n"
" 'name': '/dmissing',\n"
" 'external-contents': '/dmissing',\n"
" },"
" {\n"
" 'type': 'directory',\n"
" 'name': '/both',\n"
" 'contents': [\n"
" {\n"
" 'type': 'file',\n"
" 'name': 'vfile',\n"
" 'external-contents': '/c'\n"
" }\n"
" ]\n"
" },\n"
" {\n"
" 'type': 'directory',\n"
" 'name': '/vdir',\n"
" 'contents': ["
" {\n"
" 'type': 'directory-remap',\n"
" 'name': 'dremap',\n"
" 'external-contents': '/b'\n"
" },\n"
" {\n"
" 'type': 'file',\n"
" 'name': 'missing',\n"
" 'external-contents': '/missing'\n"
" },\n"
" {\n"
" 'type': 'file',\n"
" 'name': 'vfile',\n"
" 'external-contents': '/c'\n"
" }]\n"
" }]\n"
"}");

Dummy->addDirectory("/a");
Dummy->addRegularFile("/a/foo");
Dummy->addDirectory("/b");
Dummy->addRegularFile("/c");
Dummy->addRegularFile("/both/foo");

auto Redirecting = vfs::RedirectingFileSystem::create(
std::move(YAML), nullptr, "", nullptr, Dummy);

EXPECT_TRUE(Redirecting->exists("/dremap"));
EXPECT_FALSE(Redirecting->exists("/dmissing"));
EXPECT_FALSE(Redirecting->exists("/unknown"));
EXPECT_TRUE(Redirecting->exists("/both"));
EXPECT_TRUE(Redirecting->exists("/both/foo"));
EXPECT_TRUE(Redirecting->exists("/both/vfile"));
EXPECT_TRUE(Redirecting->exists("/vdir"));
EXPECT_TRUE(Redirecting->exists("/vdir/dremap"));
EXPECT_FALSE(Redirecting->exists("/vdir/missing"));
EXPECT_TRUE(Redirecting->exists("/vdir/vfile"));
EXPECT_FALSE(Redirecting->exists("/vdir/unknown"));
}

TEST(RedirectingFileSystemTest, ExistsFallback) {
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
auto YAML =
MemoryBuffer::getMemBuffer("{\n"
" 'version': 0,\n"
" 'redirecting-with': 'fallback',\n"
" 'roots': [\n"
" {\n"
" 'type': 'file',\n"
" 'name': '/fallback',\n"
" 'external-contents': '/missing',\n"
" },"
" ]\n"
"}");

Dummy->addRegularFile("/fallback");

auto Redirecting = vfs::RedirectingFileSystem::create(
std::move(YAML), nullptr, "", nullptr, Dummy);

EXPECT_TRUE(Redirecting->exists("/fallback"));
EXPECT_FALSE(Redirecting->exists("/missing"));
}

TEST(RedirectingFileSystemTest, ExistsRedirectOnly) {
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
auto YAML =
MemoryBuffer::getMemBuffer("{\n"
" 'version': 0,\n"
" 'redirecting-with': 'redirect-only',\n"
" 'roots': [\n"
" {\n"
" 'type': 'file',\n"
" 'name': '/vfile',\n"
" 'external-contents': '/a',\n"
" },"
" ]\n"
"}");

Dummy->addRegularFile("/a");
Dummy->addRegularFile("/b");

auto Redirecting = vfs::RedirectingFileSystem::create(
std::move(YAML), nullptr, "", nullptr, Dummy);

EXPECT_FALSE(Redirecting->exists("/a"));
EXPECT_FALSE(Redirecting->exists("/b"));
EXPECT_TRUE(Redirecting->exists("/vfile"));
}


TEST(RedirectingFileSystemTest, Used) {
auto Dummy = makeIntrusiveRefCnt<DummyFileSystem>();
auto YAML1 =
Expand Down