• Home
  • Raw
  • Download

Lines Matching +full:external +full:- +full:contents

1 //===- unittests/Basic/VirtualFileSystem.cpp ---------------- VFS tests ---===//
8 //===----------------------------------------------------------------------===//
40 return I->second; in status()
48 int64_t FileSize = -1, in getBufferForFile()
60 if (LastSep == Path.size() || LastSep == Path.size()-1) in isInPath()
70 if (isInPath(I->first)) { in DirIterImpl()
71 CurrentEntry = I->second; in DirIterImpl()
79 if (isInPath(I->first)) { in increment()
80 CurrentEntry = I->second; in increment()
124 D->addRegularFile("/foo"); in TEST()
125 Status = D->status("/foo"); in TEST()
127 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
128 EXPECT_FALSE(Status->isDirectory()); in TEST()
129 EXPECT_TRUE(Status->isRegularFile()); in TEST()
130 EXPECT_FALSE(Status->isSymlink()); in TEST()
131 EXPECT_FALSE(Status->isOther()); in TEST()
132 EXPECT_TRUE(Status->exists()); in TEST()
134 D->addDirectory("/bar"); in TEST()
135 Status = D->status("/bar"); in TEST()
137 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
138 EXPECT_TRUE(Status->isDirectory()); in TEST()
139 EXPECT_FALSE(Status->isRegularFile()); in TEST()
140 EXPECT_FALSE(Status->isSymlink()); in TEST()
141 EXPECT_FALSE(Status->isOther()); in TEST()
142 EXPECT_TRUE(Status->exists()); in TEST()
144 D->addSymlink("/baz"); in TEST()
145 Status = D->status("/baz"); in TEST()
147 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
148 EXPECT_FALSE(Status->isDirectory()); in TEST()
149 EXPECT_FALSE(Status->isRegularFile()); in TEST()
150 EXPECT_TRUE(Status->isSymlink()); in TEST()
151 EXPECT_FALSE(Status->isOther()); in TEST()
152 EXPECT_TRUE(Status->exists()); in TEST()
154 EXPECT_TRUE(Status->equivalent(*Status)); in TEST()
155 ErrorOr<vfs::Status> Status2 = D->status("/foo"); in TEST()
157 EXPECT_FALSE(Status->equivalent(*Status2)); in TEST()
163 EXPECT_FALSE(Status = D->status("/foo")); in TEST()
166 EXPECT_FALSE(Status = O->status("/foo")); in TEST()
168 D->addRegularFile("/foo"); in TEST()
169 Status = D->status("/foo"); in TEST()
173 Status2 = O->status("/foo"); in TEST()
175 EXPECT_TRUE(Status->equivalent(*Status2)); in TEST()
184 O->pushOverlay(Middle); in TEST()
185 O->pushOverlay(Top); in TEST()
192 Base->addRegularFile("/foo"); in TEST()
193 StatusB = Base->status("/foo"); in TEST()
195 Status1 = O->status("/foo"); in TEST()
197 Middle->addRegularFile("/foo"); in TEST()
198 StatusM = Middle->status("/foo"); in TEST()
200 Status2 = O->status("/foo"); in TEST()
202 Top->addRegularFile("/foo"); in TEST()
203 StatusT = Top->status("/foo"); in TEST()
205 Status3 = O->status("/foo"); in TEST()
208 EXPECT_TRUE(Status1->equivalent(*StatusB)); in TEST()
209 EXPECT_TRUE(Status2->equivalent(*StatusM)); in TEST()
210 EXPECT_TRUE(Status3->equivalent(*StatusT)); in TEST()
212 EXPECT_FALSE(Status1->equivalent(*Status2)); in TEST()
213 EXPECT_FALSE(Status2->equivalent(*Status3)); in TEST()
214 EXPECT_FALSE(Status1->equivalent(*Status3)); in TEST()
222 O->pushOverlay(Upper); in TEST()
224 Lower->addDirectory("/lower-only"); in TEST()
225 Upper->addDirectory("/upper-only"); in TEST()
227 // non-merged paths should be the same in TEST()
228 ErrorOr<vfs::Status> Status1 = Lower->status("/lower-only"); in TEST()
230 ErrorOr<vfs::Status> Status2 = O->status("/lower-only"); in TEST()
232 EXPECT_TRUE(Status1->equivalent(*Status2)); in TEST()
234 Status1 = Upper->status("/upper-only"); in TEST()
236 Status2 = O->status("/upper-only"); in TEST()
238 EXPECT_TRUE(Status1->equivalent(*Status2)); in TEST()
247 O->pushOverlay(Upper); in TEST()
250 Lower->addDirectory("/both", sys::fs::owner_read); in TEST()
251 Upper->addDirectory("/both", sys::fs::owner_all | sys::fs::group_read); in TEST()
252 Status = O->status("/both"); in TEST()
254 EXPECT_EQ(0740, Status->getPermissions()); in TEST()
257 Lower->addRegularFile("/both/foo", sys::fs::owner_read); in TEST()
258 Upper->addRegularFile("/both/bar", sys::fs::owner_write); in TEST()
259 Status = O->status("/both/foo"); in TEST()
261 EXPECT_EQ(0400, Status->getPermissions()); in TEST()
262 Status = O->status("/both/bar"); in TEST()
264 EXPECT_EQ(0200, Status->getPermissions()); in TEST()
291 ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); in TEST()
295 vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); in TEST()
304 I = FS->dir_begin(Twine(TestDirectory), EC); in TEST()
308 EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c")); in TEST()
312 EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c")); in TEST()
318 ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); in TEST()
336 std::vector<std::string> Contents; in TEST() local
339 Contents.push_back(I->getName()); in TEST()
342 // Check contents, which may be in any order in TEST()
343 EXPECT_EQ(4U, Contents.size()); in TEST()
345 for (const std::string &Name : Contents) { in TEST()
347 int Index = Name[Name.size()-1] - 'a'; in TEST()
372 EXPECT_EQ(*ExpectedIter, I->getName()); in checkContents()
383 O->pushOverlay(Upper); in TEST()
386 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>()); in TEST()
388 Lower->addRegularFile("/file1"); in TEST()
389 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>("/file1")); in TEST()
391 Upper->addRegularFile("/file2"); in TEST()
393 const char *Contents[] = {"/file2", "/file1"}; in TEST() local
394 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
397 Lower->addDirectory("/dir1"); in TEST()
398 Lower->addRegularFile("/dir1/foo"); in TEST()
399 Upper->addDirectory("/dir2"); in TEST()
400 Upper->addRegularFile("/dir2/foo"); in TEST()
401 checkContents(O->dir_begin("/dir2", EC), ArrayRef<StringRef>("/dir2/foo")); in TEST()
403 const char *Contents[] = {"/dir2", "/file2", "/dir1", "/file1"}; in TEST() local
404 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
414 O->pushOverlay(Middle); in TEST()
415 O->pushOverlay(Upper); in TEST()
421 Lower->addRegularFile("/file1"); in TEST()
425 Upper->addDirectory("/dir"); in TEST()
426 Upper->addRegularFile("/dir/file2"); in TEST()
428 const char *Contents[] = {"/dir", "/dir/file2", "/file1"}; in TEST() local
430 makeStringRefVector(Contents)); in TEST()
433 Lower->addDirectory("/dir1"); in TEST()
434 Lower->addRegularFile("/dir1/foo"); in TEST()
435 Lower->addDirectory("/dir1/a"); in TEST()
436 Lower->addRegularFile("/dir1/a/b"); in TEST()
437 Middle->addDirectory("/a"); in TEST()
438 Middle->addDirectory("/a/b"); in TEST()
439 Middle->addDirectory("/a/b/c"); in TEST()
440 Middle->addRegularFile("/a/b/c/d"); in TEST()
441 Middle->addRegularFile("/hiddenByUp"); in TEST()
442 Upper->addDirectory("/dir2"); in TEST()
443 Upper->addRegularFile("/dir2/foo"); in TEST()
444 Upper->addRegularFile("/hiddenByUp"); in TEST()
448 const char *Contents[] = { "/dir", "/dir/file2", "/dir2", "/dir2/foo", in TEST() local
452 makeStringRefVector(Contents)); in TEST()
462 O->pushOverlay(Middle); in TEST()
463 O->pushOverlay(Upper); in TEST()
466 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>()); in TEST()
468 Middle->addRegularFile("/file2"); in TEST()
469 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>("/file2")); in TEST()
471 Lower->addRegularFile("/file1"); in TEST()
472 Upper->addRegularFile("/file3"); in TEST()
474 const char *Contents[] = {"/file3", "/file2", "/file1"}; in TEST() local
475 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
485 O->pushOverlay(Middle); in TEST()
486 O->pushOverlay(Upper); in TEST()
489 Lower->addRegularFile("/onlyInLow", sys::fs::owner_read); in TEST()
490 Lower->addRegularFile("/hiddenByMid", sys::fs::owner_read); in TEST()
491 Lower->addRegularFile("/hiddenByUp", sys::fs::owner_read); in TEST()
492 Middle->addRegularFile("/onlyInMid", sys::fs::owner_write); in TEST()
493 Middle->addRegularFile("/hiddenByMid", sys::fs::owner_write); in TEST()
494 Middle->addRegularFile("/hiddenByUp", sys::fs::owner_write); in TEST()
495 Upper->addRegularFile("/onlyInUp", sys::fs::owner_all); in TEST()
496 Upper->addRegularFile("/hiddenByUp", sys::fs::owner_all); in TEST()
498 const char *Contents[] = {"/hiddenByUp", "/onlyInUp", "/hiddenByMid", in TEST() local
500 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
503 // Make sure we get the top-most entry in TEST()
506 vfs::directory_iterator I = O->dir_begin("/", EC), E; in TEST()
508 if (I->getName() == "/hiddenByUp") in TEST()
511 EXPECT_EQ(sys::fs::owner_all, I->getPermissions()); in TEST()
515 vfs::directory_iterator I = O->dir_begin("/", EC), E; in TEST()
517 if (I->getName() == "/hiddenByMid") in TEST()
520 EXPECT_EQ(sys::fs::owner_write, I->getPermissions()); in TEST()
536 ++Test->NumDiagnostics; in CountingDiagHandler()
568 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
574 " 'contents': [ {\n" in TEST_F()
577 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
582 " 'external-contents': '//root/foo/b'\n" in TEST_F()
593 O->pushOverlay(FS); in TEST_F()
596 ErrorOr<vfs::Status> S = O->status("//root/file1"); in TEST_F()
598 EXPECT_EQ("//root/foo/bar/a", S->getName()); in TEST_F()
600 ErrorOr<vfs::Status> SLower = O->status("//root/foo/bar/a"); in TEST_F()
601 EXPECT_EQ("//root/foo/bar/a", SLower->getName()); in TEST_F()
602 EXPECT_TRUE(S->equivalent(*SLower)); in TEST_F()
605 S = O->status("//root/"); in TEST_F()
607 EXPECT_TRUE(S->isDirectory()); in TEST_F()
608 EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID in TEST_F()
611 EXPECT_EQ(O->status("//root/file2").getError(), in TEST_F()
618 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
620 getFromYAMLString("{ 'case-sensitive': 'false',\n" in TEST_F()
625 " 'contents': [ {\n" in TEST_F()
628 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
637 O->pushOverlay(FS); in TEST_F()
639 ErrorOr<vfs::Status> S = O->status("//root/XX"); in TEST_F()
642 ErrorOr<vfs::Status> SS = O->status("//root/xx"); in TEST_F()
644 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
645 SS = O->status("//root/xX"); in TEST_F()
646 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
647 SS = O->status("//root/Xx"); in TEST_F()
648 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
654 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
656 getFromYAMLString("{ 'case-sensitive': 'true',\n" in TEST_F()
661 " 'contents': [ {\n" in TEST_F()
664 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
673 O->pushOverlay(FS); in TEST_F()
675 ErrorOr<vfs::Status> SS = O->status("//root/xx"); in TEST_F()
677 SS = O->status("//root/xX"); in TEST_F()
679 SS = O->status("//root/Xx"); in TEST_F()
687 // invalid YAML at top-level in TEST_F()
694 "{ 'roots':[ { 'name': 'foo', 'type': 'directory', 'contents': [}", in TEST_F()
701 FS = getFromYAMLString("{ 'case-sensitive': 'maybe', 'roots':[] }", Lower); in TEST_F()
712 "{ 'roots':[ { 'type': 'other', 'name': 'me', 'contents': '' }", Lower); in TEST_F()
715 "'external-contents': 'other' }", in TEST_F()
719 "{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': [] }", in TEST_F()
723 "{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': {} }", in TEST_F()
727 "{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': {} }", in TEST_F()
731 "{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': '' }", in TEST_F()
735 "{ 'roots':[ { 'thingy': 'directory', 'name': 'me', 'contents': [] }", in TEST_F()
743 "{ 'roots':[ { 'type': 'file', 'external-contents': 'other' }", Lower); in TEST_F()
745 FS = getFromYAMLString("{ 'roots':[ { 'name': 'me', 'contents': [] }", Lower); in TEST_F()
752 "{ 'case-sensitive':'true', 'case-sensitive':'true', 'roots':[] }", in TEST_F()
757 "'external-contents':'blah' } ] }", in TEST_F()
768 FS = getFromYAMLRawString("{ 'version':-1, 'roots':[] }", Lower); in TEST_F()
777 Lower->addRegularFile("//root/external/file"); in TEST_F()
782 " 'external-contents': '//root/external/file'\n" in TEST_F()
785 " 'use-external-name': true,\n" in TEST_F()
786 " 'external-contents': '//root/external/file'\n" in TEST_F()
789 " 'use-external-name': false,\n" in TEST_F()
790 " 'external-contents': '//root/external/file'\n" in TEST_F()
796 EXPECT_EQ("//root/external/file", FS->status("//root/A")->getName()); in TEST_F()
798 EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); in TEST_F()
799 EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); in TEST_F()
803 "{ 'use-external-names': false,\n" in TEST_F()
806 " 'external-contents': '//root/external/file'\n" in TEST_F()
809 " 'use-external-name': true,\n" in TEST_F()
810 " 'external-contents': '//root/external/file'\n" in TEST_F()
813 " 'use-external-name': false,\n" in TEST_F()
814 " 'external-contents': '//root/external/file'\n" in TEST_F()
820 EXPECT_EQ("//root/A", FS->status("//root/A")->getName()); in TEST_F()
822 EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); in TEST_F()
823 EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); in TEST_F()
828 Lower->addRegularFile("//root/other"); in TEST_F()
834 " 'external-contents': '//root/other' }]\n" in TEST_F()
837 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
838 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
839 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
840 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
846 " 'contents': [ { 'type': 'file', 'name': 'file',\n" in TEST_F()
847 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
850 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
851 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
852 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
853 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
859 " 'contents': [ { 'type': 'file', 'name': 'path/to/file',\n" in TEST_F()
860 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
863 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
864 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
865 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
866 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
871 Lower->addRegularFile("//root/other"); in TEST_F()
877 " 'contents': [ { 'type': 'file', 'name': 'file',\n" in TEST_F()
878 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
881 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
882 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
883 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
884 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
889 Lower->addDirectory("//root/"); in TEST_F()
890 Lower->addDirectory("//root/foo"); in TEST_F()
891 Lower->addDirectory("//root/foo/bar"); in TEST_F()
892 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
893 Lower->addRegularFile("//root/foo/bar/b"); in TEST_F()
894 Lower->addRegularFile("//root/file3"); in TEST_F()
896 getFromYAMLString("{ 'use-external-names': false,\n" in TEST_F()
901 " 'contents': [ {\n" in TEST_F()
904 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
909 " 'external-contents': '//root/foo/bar/b'\n" in TEST_F()
920 O->pushOverlay(FS); in TEST_F()
924 const char *Contents[] = {"//root/file1", "//root/file2", "//root/file3", in TEST_F() local
926 checkContents(O->dir_begin("//root/", EC), makeStringRefVector(Contents)); in TEST_F()
930 const char *Contents[] = {"//root/foo/bar/a", "//root/foo/bar/b"}; in TEST_F() local
931 checkContents(O->dir_begin("//root/foo/bar", EC), in TEST_F()
932 makeStringRefVector(Contents)); in TEST_F()