[llvm] 58bc507 - [VirtualFileSystem] Add unit test that showcases another YAMLVFSWriter bug
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 14:56:18 PDT 2020
Author: Jonas Devlieghere
Date: 2020-05-12T14:55:43-07:00
New Revision: 58bc507b6fe6c6276a7c858a7d1de83ca02e999e
URL: https://github.com/llvm/llvm-project/commit/58bc507b6fe6c6276a7c858a7d1de83ca02e999e
DIFF: https://github.com/llvm/llvm-project/commit/58bc507b6fe6c6276a7c858a7d1de83ca02e999e.diff
LOG: [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"
}
]
}
]
}
]
},
Added:
Modified:
llvm/unittests/Support/VirtualFileSystemTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 7c357103ae8f..5e314f7bd8b4 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");
More information about the llvm-commits
mailing list