diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index 7910147a03fd9..6228de8aa897a 100644 --- a/llvm/unittests/Support/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -3306,128 +3306,6 @@ TEST(RedirectingFileSystemTest, PrintOutput) { Output); } -TEST(RedirectingFileSystemTest, Exists) { - IntrusiveRefCntPtr 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 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 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(); auto YAML1 =