diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2023-09-14 20:43:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 20:43:41 -0700 |
commit | 455bf3d1ccd6a52df5e38103532c1b8f49924edc (patch) | |
tree | 6facb5df4f974717455dd8d8b6051484a12ee04d /llvm/unittests/TextAPI | |
parent | 831041be797b099b4e3805db368bacb1d1abab5d (diff) | |
download | llvm-455bf3d1ccd6a52df5e38103532c1b8f49924edc.zip llvm-455bf3d1ccd6a52df5e38103532c1b8f49924edc.tar.gz llvm-455bf3d1ccd6a52df5e38103532c1b8f49924edc.tar.bz2 |
[TextAPI] Consolidate TextAPI Reader/Writer APIs. (#66108)
Both Swift & LLD use TextAPI reader/writer apis to interface with TBD
files. Add doc strings to document what each API does. Also, add
shortcut APIs for validating input is a TBD file.
This reduces the differences between downstream and how tapi calls into
these APIs.
Diffstat (limited to 'llvm/unittests/TextAPI')
-rw-r--r-- | llvm/unittests/TextAPI/TextStubV5Tests.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/unittests/TextAPI/TextStubV5Tests.cpp b/llvm/unittests/TextAPI/TextStubV5Tests.cpp index 54ca21b..60976a5 100644 --- a/llvm/unittests/TextAPI/TextStubV5Tests.cpp +++ b/llvm/unittests/TextAPI/TextStubV5Tests.cpp @@ -185,11 +185,15 @@ TEST(TBDv5, ReadFile) { "libraries": [] })"; - Expected<TBDFile> Result = - TextAPIReader::get(MemoryBufferRef(TBDv5File, "Test.tbd")); + MemoryBufferRef InputBuf = MemoryBufferRef(TBDv5File, "Test.tbd"); + Expected<FileType> ExpectedFT = TextAPIReader::canRead(InputBuf); + EXPECT_TRUE(!!ExpectedFT); + + Expected<TBDFile> Result = TextAPIReader::get(InputBuf); EXPECT_TRUE(!!Result); TBDFile File = std::move(Result.get()); EXPECT_EQ(FileType::TBD_V5, File->getFileType()); + EXPECT_EQ(*ExpectedFT, File->getFileType()); EXPECT_EQ(std::string("/S/L/F/Foo.framework/Foo"), File->getInstallName()); TargetList AllTargets = { @@ -915,7 +919,8 @@ TEST(TBDv5, WriteMultipleDocuments) { // against TBDv5File. SmallString<4096> Buffer; raw_svector_ostream OS(Buffer); - Error Result = TextAPIWriter::writeToStream(OS, File, /*Compact=*/true); + Error Result = TextAPIWriter::writeToStream(OS, File, FileType::Invalid, + /*Compact=*/true); EXPECT_FALSE(Result); Expected<TBDFile> Input = |