aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/VirtualFileSystemTest.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-05-12 14:55:17 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-05-12 14:55:43 -0700
commit58bc507b6fe6c6276a7c858a7d1de83ca02e999e (patch)
tree20ce16eb920420b01934bb5747e325e782dd3478 /llvm/unittests/Support/VirtualFileSystemTest.cpp
parent59ba19c56e1cf6d01e6acce1bf405a57f19c340c (diff)
downloadllvm-58bc507b6fe6c6276a7c858a7d1de83ca02e999e.zip
llvm-58bc507b6fe6c6276a7c858a7d1de83ca02e999e.tar.gz
llvm-58bc507b6fe6c6276a7c858a7d1de83ca02e999e.tar.bz2
[VirtualFileSystem] Add unit test that showcases another YAMLVFSWriter bug
This scenario generates another broken YAML mapping as illustrated below. { 'type': 'directory', 'name': "c", 'contents': [ , { 'type': 'directory', 'name': "d", 'contents': [ , { 'type': 'directory', 'name': "e", 'contents': [ { 'type': 'file', 'name': "f", 'external-contents': "//root/a/c/d/e/f" } { 'type': 'file', 'name': "g", 'external-contents': "//root/a/c/d/e/g" } ] } ] } ] },
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 7c35710..5e314f7 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2271,6 +2271,40 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest2) {
EXPECT_FALSE(FS.get() != nullptr);
}
+TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest3) {
+ ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true);
+ ScopedDir _a(TestDirectory + "/a");
+ ScopedFile _ab(TestDirectory + "/a/b", "");
+ ScopedDir _ac(TestDirectory + "/a/c");
+ ScopedDir _acd(TestDirectory + "/a/c/d");
+ ScopedDir _acde(TestDirectory + "/a/c/d/e");
+ ScopedFile _acdef(TestDirectory + "/a/c/d/e/f", "");
+ ScopedFile _acdeg(TestDirectory + "/a/c/d/e/g", "");
+ ScopedDir _ah(TestDirectory + "/a/h");
+ ScopedFile _ahi(TestDirectory + "/a/h/i", "");
+
+ vfs::YAMLVFSWriter VFSWriter;
+ VFSWriter.addDirectoryMapping(_a.Path, "//root/a");
+ VFSWriter.addFileMapping(_ab.Path, "//root/a/b");
+ VFSWriter.addDirectoryMapping(_ac.Path, "//root/a/c");
+ VFSWriter.addDirectoryMapping(_acd.Path, "//root/a/c/d");
+ VFSWriter.addDirectoryMapping(_acde.Path, "//root/a/c/d/e");
+ VFSWriter.addFileMapping(_acdef.Path, "//root/a/c/d/e/f");
+ VFSWriter.addFileMapping(_acdeg.Path, "//root/a/c/d/e/g");
+ VFSWriter.addDirectoryMapping(_ahi.Path, "//root/a/h");
+ VFSWriter.addFileMapping(_ahi.Path, "//root/a/h/i");
+
+ std::string Buffer;
+ raw_string_ostream OS(Buffer);
+ VFSWriter.write(OS);
+ OS.flush();
+
+ IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
+ IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLRawString(Buffer, Lower);
+ // FIXME: Spurious comma separator before first file entry in directory.
+ EXPECT_FALSE(FS.get() != nullptr);
+}
+
TEST_F(VFSFromYAMLTest, YAMLVFSWriterTestHandleDirs) {
ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true);
ScopedDir _a(TestDirectory + "/a");