From 2e2351adce3dcd2c180442ce1d6c1163cbf7c380 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 6 Oct 2015 10:04:08 +0000 Subject: [VFS] Transition clang-format to use an in-memory FS. Apart from being cleaner this also means that clang-format no longer has access to the host file system. This isn't necessary because clang-format never reads includes :) Includes minor tweaks and bugfixes found in the VFS implementation while running clang-format tests. llvm-svn: 249385 --- clang/unittests/Basic/VirtualFileSystemTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/unittests/Basic/VirtualFileSystemTest.cpp') diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index 4d4522a85b4..ccfac28dc7b 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -548,17 +548,29 @@ TEST_F(InMemoryFileSystemTest, OverlayFile) { FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")); auto Stat = FS.status("/"); ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString(); + Stat = FS.status("/."); + ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString(); Stat = FS.status("/a"); ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); ASSERT_EQ("/a", Stat->getName()); } +TEST_F(InMemoryFileSystemTest, OverlayFileNoOwn) { + auto Buf = MemoryBuffer::getMemBuffer("a"); + FS.addFileNoOwn("/a", 0, Buf.get()); + auto Stat = FS.status("/a"); + ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString(); + ASSERT_EQ("/a", Stat->getName()); +} + TEST_F(InMemoryFileSystemTest, OpenFileForRead) { FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")); auto File = FS.openFileForRead("/a"); ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); File = FS.openFileForRead("/a"); // Open again. ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); + File = FS.openFileForRead("/././a"); // Open again. + ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); File = FS.openFileForRead("/"); ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString(); File = FS.openFileForRead("/b"); -- cgit v1.2.3