[PATCH] D55789: [VFS] Add isLocal to ProxyFileSystem and add unit tests.
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 17 14:33:24 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349410: [VFS] Add isLocal to ProxyFileSystem and add unit tests. (authored by mspencer, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D55789?vs=178527&id=178533#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55789/new/
https://reviews.llvm.org/D55789
Files:
llvm/trunk/include/llvm/Support/VirtualFileSystem.h
llvm/trunk/unittests/Support/VirtualFileSystemTest.cpp
Index: llvm/trunk/include/llvm/Support/VirtualFileSystem.h
===================================================================
--- llvm/trunk/include/llvm/Support/VirtualFileSystem.h
+++ llvm/trunk/include/llvm/Support/VirtualFileSystem.h
@@ -374,6 +374,9 @@
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; }
Index: llvm/trunk/unittests/Support/VirtualFileSystemTest.cpp
===================================================================
--- llvm/trunk/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/trunk/unittests/Support/VirtualFileSystemTest.cpp
@@ -743,6 +743,43 @@
}
}
+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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55789.178533.patch
Type: text/x-patch
Size: 1972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181217/cfd886ba/attachment.bin>
More information about the llvm-commits
mailing list