[llvm] 59ba19c - [VirtualFileSystem] Add unit test that showcases YAMLVFSWriter bug
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Tue May 12 14:47:38 PDT 2020
Author: Jonas Devlieghere
Date: 2020-05-12T14:47:31-07:00
New Revision: 59ba19c56e1cf6d01e6acce1bf405a57f19c340c
URL: https://github.com/llvm/llvm-project/commit/59ba19c56e1cf6d01e6acce1bf405a57f19c340c
DIFF: https://github.com/llvm/llvm-project/commit/59ba19c56e1cf6d01e6acce1bf405a57f19c340c.diff
LOG: [VirtualFileSystem] Add unit test that showcases YAMLVFSWriter bug
This scenario generates a broken YAML mapping as illustrated below.
{
'type': 'directory',
'name': "c",
'contents': [
{
'type': 'file',
'name': "d",
'external-contents': "//root/a/c/d"
} {
'type': 'file',
'name': "e",
'external-contents': "//root/a/c/e"
} {
'type': 'file',
'name': "f",
'external-contents': "//root/a/c/f"
}
]
},
Added:
Modified:
llvm/unittests/Support/VirtualFileSystemTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 8c08cb159304..7c357103ae8f 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -2239,6 +2239,38 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest) {
EXPECT_TRUE(FS->exists(_h.Path));
}
+TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest2) {
+ ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/ true);
+ ScopedDir _a(TestDirectory + "/a");
+ ScopedFile _ab(TestDirectory + "/a/b", "");
+ ScopedDir _ac(TestDirectory + "/a/c");
+ ScopedFile _acd(TestDirectory + "/a/c/d", "");
+ ScopedFile _ace(TestDirectory + "/a/c/e", "");
+ ScopedFile _acf(TestDirectory + "/a/c/f", "");
+ ScopedDir _ag(TestDirectory + "/a/g");
+ ScopedFile _agh(TestDirectory + "/a/g/h", "");
+
+ vfs::YAMLVFSWriter VFSWriter;
+ VFSWriter.addDirectoryMapping(_a.Path, "//root/a");
+ VFSWriter.addFileMapping(_ab.Path, "//root/a/b");
+ VFSWriter.addDirectoryMapping(_ac.Path, "//root/a/c");
+ VFSWriter.addFileMapping(_acd.Path, "//root/a/c/d");
+ VFSWriter.addFileMapping(_ace.Path, "//root/a/c/e");
+ VFSWriter.addFileMapping(_acf.Path, "//root/a/c/f");
+ VFSWriter.addDirectoryMapping(_ag.Path, "//root/a/g");
+ VFSWriter.addFileMapping(_agh.Path, "//root/a/g/h");
+
+ 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: Missing comma separator between file entries.
+ 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