diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-12 14:46:23 -0700 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-05-12 14:47:31 -0700 |
commit | 59ba19c56e1cf6d01e6acce1bf405a57f19c340c (patch) | |
tree | 44aa5acc1735fd42b6f59251d2e01fe2edeefb57 /llvm/unittests/Support/VirtualFileSystemTest.cpp | |
parent | aa1eb5152d9a5bd588c8479a376fa65cbeabbc9f (diff) | |
download | llvm-59ba19c56e1cf6d01e6acce1bf405a57f19c340c.zip llvm-59ba19c56e1cf6d01e6acce1bf405a57f19c340c.tar.gz llvm-59ba19c56e1cf6d01e6acce1bf405a57f19c340c.tar.bz2 |
[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"
}
]
},
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
-rw-r--r-- | llvm/unittests/Support/VirtualFileSystemTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index 8c08cb1..7c35710 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"); |