diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2018-12-17 22:30:05 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2018-12-17 22:30:05 +0000 |
commit | 937a1047f64495696ac84db6c647bb96d75a3806 (patch) | |
tree | 1178436ce316420a2f4871fca593551dd9f1e0ee | |
parent | 28330b9cc072b936e672731f85a1b1b4088b59e2 (diff) | |
download | bcm5719-llvm-937a1047f64495696ac84db6c647bb96d75a3806.tar.gz bcm5719-llvm-937a1047f64495696ac84db6c647bb96d75a3806.zip |
[VFS] Add isLocal to ProxyFileSystem and add unit tests.
Differential Revision: https://reviews.llvm.org/D55789
llvm-svn: 349410
-rw-r--r-- | llvm/include/llvm/Support/VirtualFileSystem.h | 3 | ||||
-rw-r--r-- | llvm/unittests/Support/VirtualFileSystemTest.cpp | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h index b3326bbbe48..3d4094eeb11 100644 --- a/llvm/include/llvm/Support/VirtualFileSystem.h +++ b/llvm/include/llvm/Support/VirtualFileSystem.h @@ -374,6 +374,9 @@ public: SmallVectorImpl<char> &Output) const override { return FS->getRealPath(Path, Output); } + std::error_code isLocal(const Twine &Path, bool &Result) override { + return FS->isLocal(Path, Result); + } protected: FileSystem &getUnderlyingFS() { return *FS; } diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index 458b07e6d43..7b42943f0fd 100644 --- a/llvm/unittests/Support/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -743,6 +743,43 @@ TEST(VirtualFileSystemTest, HiddenInIteration) { } } +TEST(ProxyFileSystemTest, Basic) { + IntrusiveRefCntPtr<vfs::InMemoryFileSystem> Base( + new vfs::InMemoryFileSystem()); + vfs::ProxyFileSystem PFS(Base); + + Base->addFile("/a", 0, MemoryBuffer::getMemBuffer("test")); + + auto Stat = PFS.status("/a"); + ASSERT_FALSE(Stat.getError()); + + auto File = PFS.openFileForRead("/a"); + ASSERT_FALSE(File.getError()); + EXPECT_EQ("test", (*(*File)->getBuffer("ignored"))->getBuffer()); + + std::error_code EC; + vfs::directory_iterator I = PFS.dir_begin("/", EC); + ASSERT_FALSE(EC); + ASSERT_EQ("/a", I->path()); + I.increment(EC); + ASSERT_FALSE(EC); + ASSERT_EQ(vfs::directory_iterator(), I); + + ASSERT_FALSE(PFS.setCurrentWorkingDirectory("/")); + + auto PWD = PFS.getCurrentWorkingDirectory(); + ASSERT_FALSE(PWD.getError()); + ASSERT_EQ("/", *PWD); + + SmallString<16> Path; + ASSERT_FALSE(PFS.getRealPath("a", Path)); + ASSERT_EQ("/a", Path); + + bool Local = true; + ASSERT_FALSE(PFS.isLocal("/a", Local)); + ASSERT_EQ(false, Local); +} + class InMemoryFileSystemTest : public ::testing::Test { protected: llvm::vfs::InMemoryFileSystem FS; |