Lines Matching +full:external +full:- +full:contents
1 //===- unittests/Basic/VirtualFileSystem.cpp ---------------- VFS tests ---===//
8 //===----------------------------------------------------------------------===//
53 return I->second; in status()
76 if (LastSep == Path.size() || LastSep == Path.size()-1) in isInPath()
86 if (isInPath(I->first)) { in DirIterImpl()
87 CurrentEntry = I->second; in DirIterImpl()
95 if (isInPath(I->first)) { in increment()
96 CurrentEntry = I->second; in increment()
140 D->addRegularFile("/foo"); in TEST()
141 Status = D->status("/foo"); in TEST()
143 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
144 EXPECT_FALSE(Status->isDirectory()); in TEST()
145 EXPECT_TRUE(Status->isRegularFile()); in TEST()
146 EXPECT_FALSE(Status->isSymlink()); in TEST()
147 EXPECT_FALSE(Status->isOther()); in TEST()
148 EXPECT_TRUE(Status->exists()); in TEST()
150 D->addDirectory("/bar"); in TEST()
151 Status = D->status("/bar"); in TEST()
153 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
154 EXPECT_TRUE(Status->isDirectory()); in TEST()
155 EXPECT_FALSE(Status->isRegularFile()); in TEST()
156 EXPECT_FALSE(Status->isSymlink()); in TEST()
157 EXPECT_FALSE(Status->isOther()); in TEST()
158 EXPECT_TRUE(Status->exists()); in TEST()
160 D->addSymlink("/baz"); in TEST()
161 Status = D->status("/baz"); in TEST()
163 EXPECT_TRUE(Status->isStatusKnown()); in TEST()
164 EXPECT_FALSE(Status->isDirectory()); in TEST()
165 EXPECT_FALSE(Status->isRegularFile()); in TEST()
166 EXPECT_TRUE(Status->isSymlink()); in TEST()
167 EXPECT_FALSE(Status->isOther()); in TEST()
168 EXPECT_TRUE(Status->exists()); in TEST()
170 EXPECT_TRUE(Status->equivalent(*Status)); in TEST()
171 ErrorOr<vfs::Status> Status2 = D->status("/foo"); in TEST()
173 EXPECT_FALSE(Status->equivalent(*Status2)); in TEST()
179 EXPECT_FALSE(Status = D->status("/foo")); in TEST()
182 EXPECT_FALSE(Status = O->status("/foo")); in TEST()
184 D->addRegularFile("/foo"); in TEST()
185 Status = D->status("/foo"); in TEST()
189 Status2 = O->status("/foo"); in TEST()
191 EXPECT_TRUE(Status->equivalent(*Status2)); in TEST()
200 O->pushOverlay(Middle); in TEST()
201 O->pushOverlay(Top); in TEST()
208 Base->addRegularFile("/foo"); in TEST()
209 StatusB = Base->status("/foo"); in TEST()
211 Status1 = O->status("/foo"); in TEST()
213 Middle->addRegularFile("/foo"); in TEST()
214 StatusM = Middle->status("/foo"); in TEST()
216 Status2 = O->status("/foo"); in TEST()
218 Top->addRegularFile("/foo"); in TEST()
219 StatusT = Top->status("/foo"); in TEST()
221 Status3 = O->status("/foo"); in TEST()
224 EXPECT_TRUE(Status1->equivalent(*StatusB)); in TEST()
225 EXPECT_TRUE(Status2->equivalent(*StatusM)); in TEST()
226 EXPECT_TRUE(Status3->equivalent(*StatusT)); in TEST()
228 EXPECT_FALSE(Status1->equivalent(*Status2)); in TEST()
229 EXPECT_FALSE(Status2->equivalent(*Status3)); in TEST()
230 EXPECT_FALSE(Status1->equivalent(*Status3)); in TEST()
238 O->pushOverlay(Upper); in TEST()
240 Lower->addDirectory("/lower-only"); in TEST()
241 Upper->addDirectory("/upper-only"); in TEST()
243 // non-merged paths should be the same in TEST()
244 ErrorOr<vfs::Status> Status1 = Lower->status("/lower-only"); in TEST()
246 ErrorOr<vfs::Status> Status2 = O->status("/lower-only"); in TEST()
248 EXPECT_TRUE(Status1->equivalent(*Status2)); in TEST()
250 Status1 = Upper->status("/upper-only"); in TEST()
252 Status2 = O->status("/upper-only"); in TEST()
254 EXPECT_TRUE(Status1->equivalent(*Status2)); in TEST()
263 O->pushOverlay(Upper); in TEST()
266 Lower->addDirectory("/both", sys::fs::owner_read); in TEST()
267 Upper->addDirectory("/both", sys::fs::owner_all | sys::fs::group_read); in TEST()
268 Status = O->status("/both"); in TEST()
270 EXPECT_EQ(0740, Status->getPermissions()); in TEST()
273 Lower->addRegularFile("/both/foo", sys::fs::owner_read); in TEST()
274 Upper->addRegularFile("/both/bar", sys::fs::owner_write); in TEST()
275 Status = O->status("/both/foo"); in TEST()
277 EXPECT_EQ(0400, Status->getPermissions()); in TEST()
278 Status = O->status("/both/bar"); in TEST()
280 EXPECT_EQ(0200, Status->getPermissions()); in TEST()
307 ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); in TEST()
311 vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); in TEST()
320 I = FS->dir_begin(Twine(TestDirectory), EC); in TEST()
324 EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c")); in TEST()
328 EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c")); in TEST()
334 ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); in TEST()
352 std::vector<std::string> Contents; in TEST() local
355 Contents.push_back(I->getName()); in TEST()
358 // Check contents, which may be in any order in TEST()
359 EXPECT_EQ(4U, Contents.size()); in TEST()
361 for (const std::string &Name : Contents) { in TEST()
363 int Index = Name[Name.size()-1] - 'a'; in TEST()
388 EXPECT_EQ(*ExpectedIter, I->getName()); in checkContents()
399 O->pushOverlay(Upper); in TEST()
402 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>()); in TEST()
404 Lower->addRegularFile("/file1"); in TEST()
405 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>("/file1")); in TEST()
407 Upper->addRegularFile("/file2"); in TEST()
409 const char *Contents[] = {"/file2", "/file1"}; in TEST() local
410 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
413 Lower->addDirectory("/dir1"); in TEST()
414 Lower->addRegularFile("/dir1/foo"); in TEST()
415 Upper->addDirectory("/dir2"); in TEST()
416 Upper->addRegularFile("/dir2/foo"); in TEST()
417 checkContents(O->dir_begin("/dir2", EC), ArrayRef<StringRef>("/dir2/foo")); in TEST()
419 const char *Contents[] = {"/dir2", "/file2", "/dir1", "/file1"}; in TEST() local
420 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
430 O->pushOverlay(Middle); in TEST()
431 O->pushOverlay(Upper); in TEST()
437 Lower->addRegularFile("/file1"); in TEST()
441 Upper->addDirectory("/dir"); in TEST()
442 Upper->addRegularFile("/dir/file2"); in TEST()
444 const char *Contents[] = {"/dir", "/dir/file2", "/file1"}; in TEST() local
446 makeStringRefVector(Contents)); in TEST()
449 Lower->addDirectory("/dir1"); in TEST()
450 Lower->addRegularFile("/dir1/foo"); in TEST()
451 Lower->addDirectory("/dir1/a"); in TEST()
452 Lower->addRegularFile("/dir1/a/b"); in TEST()
453 Middle->addDirectory("/a"); in TEST()
454 Middle->addDirectory("/a/b"); in TEST()
455 Middle->addDirectory("/a/b/c"); in TEST()
456 Middle->addRegularFile("/a/b/c/d"); in TEST()
457 Middle->addRegularFile("/hiddenByUp"); in TEST()
458 Upper->addDirectory("/dir2"); in TEST()
459 Upper->addRegularFile("/dir2/foo"); in TEST()
460 Upper->addRegularFile("/hiddenByUp"); in TEST()
464 const char *Contents[] = { "/dir", "/dir/file2", "/dir2", "/dir2/foo", in TEST() local
468 makeStringRefVector(Contents)); in TEST()
478 O->pushOverlay(Middle); in TEST()
479 O->pushOverlay(Upper); in TEST()
482 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>()); in TEST()
484 Middle->addRegularFile("/file2"); in TEST()
485 checkContents(O->dir_begin("/", EC), ArrayRef<StringRef>("/file2")); in TEST()
487 Lower->addRegularFile("/file1"); in TEST()
488 Upper->addRegularFile("/file3"); in TEST()
490 const char *Contents[] = {"/file3", "/file2", "/file1"}; in TEST() local
491 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
501 O->pushOverlay(Middle); in TEST()
502 O->pushOverlay(Upper); in TEST()
505 Lower->addRegularFile("/onlyInLow", sys::fs::owner_read); in TEST()
506 Lower->addRegularFile("/hiddenByMid", sys::fs::owner_read); in TEST()
507 Lower->addRegularFile("/hiddenByUp", sys::fs::owner_read); in TEST()
508 Middle->addRegularFile("/onlyInMid", sys::fs::owner_write); in TEST()
509 Middle->addRegularFile("/hiddenByMid", sys::fs::owner_write); in TEST()
510 Middle->addRegularFile("/hiddenByUp", sys::fs::owner_write); in TEST()
511 Upper->addRegularFile("/onlyInUp", sys::fs::owner_all); in TEST()
512 Upper->addRegularFile("/hiddenByUp", sys::fs::owner_all); in TEST()
514 const char *Contents[] = {"/hiddenByUp", "/onlyInUp", "/hiddenByMid", in TEST() local
516 checkContents(O->dir_begin("/", EC), makeStringRefVector(Contents)); in TEST()
519 // Make sure we get the top-most entry in TEST()
522 vfs::directory_iterator I = O->dir_begin("/", EC), E; in TEST()
524 if (I->getName() == "/hiddenByUp") in TEST()
527 EXPECT_EQ(sys::fs::owner_all, I->getPermissions()); in TEST()
531 vfs::directory_iterator I = O->dir_begin("/", EC), E; in TEST()
533 if (I->getName() == "/hiddenByMid") in TEST()
536 EXPECT_EQ(sys::fs::owner_write, I->getPermissions()); in TEST()
581 ASSERT_EQ("/a", Stat->getName()); in TEST_F()
589 ASSERT_EQ("/a", Stat->getName()); in TEST_F()
600 ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); in TEST_F()
602 ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); in TEST_F()
604 ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer()); in TEST_F()
614 ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer()); in TEST_F()
616 ASSERT_EQ("d", (*(*File)->getBuffer("ignored"))->getBuffer()); in TEST_F()
633 ASSERT_EQ("/a", I->getName()); in TEST_F()
636 ASSERT_EQ("/b", I->getName()); in TEST_F()
643 ASSERT_EQ("/b/c", I->getName()); in TEST_F()
655 ASSERT_EQ("c", Stat->getName()); in TEST_F()
672 ++Test->NumDiagnostics; in CountingDiagHandler()
705 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
711 " 'contents': [ {\n" in TEST_F()
714 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
719 " 'external-contents': '//root/foo/b'\n" in TEST_F()
730 O->pushOverlay(FS); in TEST_F()
733 ErrorOr<vfs::Status> S = O->status("//root/file1"); in TEST_F()
735 EXPECT_EQ("//root/foo/bar/a", S->getName()); in TEST_F()
736 EXPECT_TRUE(S->IsVFSMapped); in TEST_F()
738 ErrorOr<vfs::Status> SLower = O->status("//root/foo/bar/a"); in TEST_F()
739 EXPECT_EQ("//root/foo/bar/a", SLower->getName()); in TEST_F()
740 EXPECT_TRUE(S->equivalent(*SLower)); in TEST_F()
741 EXPECT_FALSE(SLower->IsVFSMapped); in TEST_F()
744 auto OpenedF = O->openFileForRead("//root/file1"); in TEST_F()
746 auto OpenedS = (*OpenedF)->status(); in TEST_F()
748 EXPECT_EQ("//root/foo/bar/a", OpenedS->getName()); in TEST_F()
749 EXPECT_TRUE(OpenedS->IsVFSMapped); in TEST_F()
752 S = O->status("//root/"); in TEST_F()
754 EXPECT_TRUE(S->isDirectory()); in TEST_F()
755 EXPECT_TRUE(S->equivalent(*O->status("//root/"))); // non-volatile UniqueID in TEST_F()
758 EXPECT_EQ(O->status("//root/file2").getError(), in TEST_F()
765 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
767 getFromYAMLString("{ 'case-sensitive': 'false',\n" in TEST_F()
772 " 'contents': [ {\n" in TEST_F()
775 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
784 O->pushOverlay(FS); in TEST_F()
786 ErrorOr<vfs::Status> S = O->status("//root/XX"); in TEST_F()
789 ErrorOr<vfs::Status> SS = O->status("//root/xx"); in TEST_F()
791 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
792 SS = O->status("//root/xX"); in TEST_F()
793 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
794 SS = O->status("//root/Xx"); in TEST_F()
795 EXPECT_TRUE(S->equivalent(*SS)); in TEST_F()
801 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
803 getFromYAMLString("{ 'case-sensitive': 'true',\n" in TEST_F()
808 " 'contents': [ {\n" in TEST_F()
811 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
820 O->pushOverlay(FS); in TEST_F()
822 ErrorOr<vfs::Status> SS = O->status("//root/xx"); in TEST_F()
824 SS = O->status("//root/xX"); in TEST_F()
826 SS = O->status("//root/Xx"); in TEST_F()
834 // invalid YAML at top-level in TEST_F()
841 "{ 'roots':[ { 'name': 'foo', 'type': 'directory', 'contents': [}", in TEST_F()
848 FS = getFromYAMLString("{ 'case-sensitive': 'maybe', 'roots':[] }", Lower); in TEST_F()
859 "{ 'roots':[ { 'type': 'other', 'name': 'me', 'contents': '' }", Lower); in TEST_F()
862 "'external-contents': 'other' }", in TEST_F()
866 "{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': [] }", in TEST_F()
870 "{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': {} }", in TEST_F()
874 "{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': {} }", in TEST_F()
878 "{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': '' }", in TEST_F()
882 "{ 'roots':[ { 'thingy': 'directory', 'name': 'me', 'contents': [] }", in TEST_F()
890 "{ 'roots':[ { 'type': 'file', 'external-contents': 'other' }", Lower); in TEST_F()
892 FS = getFromYAMLString("{ 'roots':[ { 'name': 'me', 'contents': [] }", Lower); in TEST_F()
899 "{ 'case-sensitive':'true', 'case-sensitive':'true', 'roots':[] }", in TEST_F()
904 "'external-contents':'blah' } ] }", in TEST_F()
915 FS = getFromYAMLRawString("{ 'version':-1, 'roots':[] }", Lower); in TEST_F()
924 Lower->addRegularFile("//root/external/file"); in TEST_F()
929 " 'external-contents': '//root/external/file'\n" in TEST_F()
932 " 'use-external-name': true,\n" in TEST_F()
933 " 'external-contents': '//root/external/file'\n" in TEST_F()
936 " 'use-external-name': false,\n" in TEST_F()
937 " 'external-contents': '//root/external/file'\n" in TEST_F()
943 EXPECT_EQ("//root/external/file", FS->status("//root/A")->getName()); in TEST_F()
945 EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); in TEST_F()
946 EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); in TEST_F()
950 "{ 'use-external-names': false,\n" in TEST_F()
953 " 'external-contents': '//root/external/file'\n" in TEST_F()
956 " 'use-external-name': true,\n" in TEST_F()
957 " 'external-contents': '//root/external/file'\n" in TEST_F()
960 " 'use-external-name': false,\n" in TEST_F()
961 " 'external-contents': '//root/external/file'\n" in TEST_F()
967 EXPECT_EQ("//root/A", FS->status("//root/A")->getName()); in TEST_F()
969 EXPECT_EQ("//root/external/file", FS->status("//root/B")->getName()); in TEST_F()
970 EXPECT_EQ("//root/C", FS->status("//root/C")->getName()); in TEST_F()
975 Lower->addRegularFile("//root/other"); in TEST_F()
981 " 'external-contents': '//root/other' }]\n" in TEST_F()
984 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
985 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
986 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
987 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
993 " 'contents': [ { 'type': 'file', 'name': 'file',\n" in TEST_F()
994 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
997 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
998 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
999 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
1000 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
1006 " 'contents': [ { 'type': 'file', 'name': 'path/to/file',\n" in TEST_F()
1007 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
1010 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
1011 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
1012 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
1013 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
1018 Lower->addRegularFile("//root/other"); in TEST_F()
1024 " 'contents': [ { 'type': 'file', 'name': 'file',\n" in TEST_F()
1025 " 'external-contents': '//root/other' }]}]\n" in TEST_F()
1028 EXPECT_FALSE(FS->status("//root/path/to/file").getError()); in TEST_F()
1029 EXPECT_FALSE(FS->status("//root/path/to").getError()); in TEST_F()
1030 EXPECT_FALSE(FS->status("//root/path").getError()); in TEST_F()
1031 EXPECT_FALSE(FS->status("//root/").getError()); in TEST_F()
1036 Lower->addDirectory("//root/"); in TEST_F()
1037 Lower->addDirectory("//root/foo"); in TEST_F()
1038 Lower->addDirectory("//root/foo/bar"); in TEST_F()
1039 Lower->addRegularFile("//root/foo/bar/a"); in TEST_F()
1040 Lower->addRegularFile("//root/foo/bar/b"); in TEST_F()
1041 Lower->addRegularFile("//root/file3"); in TEST_F()
1043 getFromYAMLString("{ 'use-external-names': false,\n" in TEST_F()
1048 " 'contents': [ {\n" in TEST_F()
1051 " 'external-contents': '//root/foo/bar/a'\n" in TEST_F()
1056 " 'external-contents': '//root/foo/bar/b'\n" in TEST_F()
1067 O->pushOverlay(FS); in TEST_F()
1071 const char *Contents[] = {"//root/file1", "//root/file2", "//root/file3", in TEST_F() local
1073 checkContents(O->dir_begin("//root/", EC), makeStringRefVector(Contents)); in TEST_F()
1077 const char *Contents[] = {"//root/foo/bar/a", "//root/foo/bar/b"}; in TEST_F() local
1078 checkContents(O->dir_begin("//root/foo/bar", EC), in TEST_F()
1079 makeStringRefVector(Contents)); in TEST_F()