llvm.org GIT mirror llvm / 754733f
[VFS] Add isLocal to ProxyFileSystem and add unit tests. Differential Revision: https://reviews.llvm.org/D55789 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349410 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 1 year, 10 months ago
2 changed file(s) with 40 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
373373 SmallVectorImpl &Output) const override {
374374 return FS->getRealPath(Path, Output);
375375 }
376 std::error_code isLocal(const Twine &Path, bool &Result) override {
377 return FS->isLocal(Path, Result);
378 }
376379
377380 protected:
378381 FileSystem &getUnderlyingFS() { return *FS; }
742742 }
743743 }
744744
745 TEST(ProxyFileSystemTest, Basic) {
746 IntrusiveRefCntPtr Base(
747 new vfs::InMemoryFileSystem());
748 vfs::ProxyFileSystem PFS(Base);
749
750 Base->addFile("/a", 0, MemoryBuffer::getMemBuffer("test"));
751
752 auto Stat = PFS.status("/a");
753 ASSERT_FALSE(Stat.getError());
754
755 auto File = PFS.openFileForRead("/a");
756 ASSERT_FALSE(File.getError());
757 EXPECT_EQ("test", (*(*File)->getBuffer("ignored"))->getBuffer());
758
759 std::error_code EC;
760 vfs::directory_iterator I = PFS.dir_begin("/", EC);
761 ASSERT_FALSE(EC);
762 ASSERT_EQ("/a", I->path());
763 I.increment(EC);
764 ASSERT_FALSE(EC);
765 ASSERT_EQ(vfs::directory_iterator(), I);
766
767 ASSERT_FALSE(PFS.setCurrentWorkingDirectory("/"));
768
769 auto PWD = PFS.getCurrentWorkingDirectory();
770 ASSERT_FALSE(PWD.getError());
771 ASSERT_EQ("/", *PWD);
772
773 SmallString<16> Path;
774 ASSERT_FALSE(PFS.getRealPath("a", Path));
775 ASSERT_EQ("/a", Path);
776
777 bool Local = true;
778 ASSERT_FALSE(PFS.isLocal("/a", Local));
779 ASSERT_EQ(false, Local);
780 }
781
745782 class InMemoryFileSystemTest : public ::testing::Test {
746783 protected:
747784 llvm::vfs::InMemoryFileSystem FS;