1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[llvm][TextAPI/MachO] clean up auto usages in tests, NFC

This commit is contained in:
Cyndy Ishida 2020-06-15 19:59:42 -07:00
parent 972e60a052
commit f772c98f9f
5 changed files with 237 additions and 203 deletions

View File

@ -24,6 +24,7 @@ struct ExportedSymbol {
using ExportedSymbolSeq = std::vector<ExportedSymbol>;
using UUIDs = std::vector<std::pair<llvm::MachO::Target, std::string>>;
using TBDFile = std::unique_ptr<MachO::InterfaceFile>;
inline bool operator<(const ExportedSymbol &LHS, const ExportedSymbol &RHS) {
return std::tie(LHS.Kind, LHS.Name) < std::tie(RHS.Kind, RHS.Name);

View File

@ -66,9 +66,10 @@ TEST(TBDv1, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1File1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
auto Platform = PlatformKind::iOS;
@ -119,9 +120,10 @@ TEST(TBDv1, ReadFile2) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1File2, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1File2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
auto Platform = PlatformKind::iOS;
@ -191,7 +193,7 @@ TEST(TBDv1, WriteFile) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv1File3, Buffer.c_str());
}
@ -203,11 +205,11 @@ TEST(TBDv1, Platform_macOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -220,11 +222,11 @@ TEST(TBDv1, Platform_iOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -237,11 +239,11 @@ TEST(TBDv1, Platform_watchOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformWatchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -254,11 +256,11 @@ TEST(TBDv1, Platform_tvOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::tvOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -271,10 +273,11 @@ TEST(TBDv1, Platform_bridgeOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1BridgeOS, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -288,9 +291,10 @@ TEST(TBDv1, Swift_1_0) {
"swift-version: 1.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(1U, File->getSwiftABIVersion());
}
@ -303,9 +307,10 @@ TEST(TBDv1, Swift_1_1) {
"swift-version: 1.1\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift1dot, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift1dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(2U, File->getSwiftABIVersion());
}
@ -318,9 +323,10 @@ TEST(TBDv1, Swift_2_0) {
"swift-version: 2.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift2, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(3U, File->getSwiftABIVersion());
}
@ -333,9 +339,10 @@ TEST(TBDv1, Swift_3_0) {
"swift-version: 3.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift3, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(4U, File->getSwiftABIVersion());
}
@ -348,12 +355,13 @@ TEST(TBDv1, Swift_4_0) {
"swift-version: 4.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift4, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
"version.\nswift-version: 4.0\n ^~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv1, Swift_5) {
@ -364,9 +372,10 @@ TEST(TBDv1, Swift_5) {
"swift-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift5, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(5U, File->getSwiftABIVersion());
}
@ -379,9 +388,10 @@ TEST(TBDv1, Swift_99) {
"swift-version: 99\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv1Swift99, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V1, File->getFileType());
EXPECT_EQ(99U, File->getSwiftABIVersion());
}
@ -393,7 +403,7 @@ TEST(TBDv1, UnknownArchitecture) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
@ -404,13 +414,13 @@ TEST(TBDv1, UnknownPlatform) {
"platform: newOS\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
"newOS\n ^~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv1, MalformedFile1) {
@ -419,13 +429,13 @@ TEST(TBDv1, MalformedFile1) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
"'platform'\narchs: [ arm64 ]\n^\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv1, MalformedFile2) {
@ -436,14 +446,14 @@ TEST(TBDv1, MalformedFile2) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv1FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ(
"malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: "
"\"Unsupported key\"\n ^~~~~~~~~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
} // end namespace TBDv1.

View File

@ -67,9 +67,10 @@ TEST(TBDv2, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2File1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
auto Platform = PlatformKind::iOS;
@ -138,9 +139,10 @@ TEST(TBDv2, ReadFile2) {
" weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2File2, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2File2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64;
auto Platform = PlatformKind::iOS;
@ -211,7 +213,7 @@ TEST(TBDv2, WriteFile) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv2File3, Buffer.c_str());
}
@ -223,10 +225,10 @@ TEST(TBDv2, Platform_macOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
auto Platform = PlatformKind::macOS;
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -240,11 +242,11 @@ TEST(TBDv2, Platform_iOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -257,11 +259,11 @@ TEST(TBDv2, Platform_watchOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformWatchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -274,11 +276,11 @@ TEST(TBDv2, Platform_tvOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::tvOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -291,10 +293,11 @@ TEST(TBDv2, Platform_bridgeOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2BridgeOS, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
@ -308,9 +311,10 @@ TEST(TBDv2, Swift_1_0) {
"swift-version: 1.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(1U, File->getSwiftABIVersion());
}
@ -323,9 +327,10 @@ TEST(TBDv2, Swift_1_1) {
"swift-version: 1.1\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift1dot, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift1dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(2U, File->getSwiftABIVersion());
}
@ -338,10 +343,10 @@ TEST(TBDv2, Swift_2_0) {
"swift-version: 2.0\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_2_0, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(3U, File->getSwiftABIVersion());
}
@ -354,9 +359,10 @@ TEST(TBDv2, Swift_3_0) {
"swift-version: 3.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift3, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(4U, File->getSwiftABIVersion());
}
@ -369,12 +375,13 @@ TEST(TBDv2, Swift_4_0) {
"swift-version: 4.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift4, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI "
"version.\nswift-version: 4.0\n ^~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv2, Swift_5) {
@ -385,9 +392,10 @@ TEST(TBDv2, Swift_5) {
"swift-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift5, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(5U, File->getSwiftABIVersion());
}
@ -400,9 +408,10 @@ TEST(TBDv2, Swift_99) {
"swift-version: 99\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv2Swift99, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V2, File->getFileType());
EXPECT_EQ(99U, File->getSwiftABIVersion());
}
@ -413,7 +422,7 @@ TEST(TBDv2, UnknownArchitecture) {
"platform: macosx\n"
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
@ -424,13 +433,13 @@ TEST(TBDv2, UnknownPlatform) {
"platform: newOS\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
"newOS\n ^~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv2, InvalidPlatform) {
@ -440,13 +449,13 @@ TEST(TBDv2, InvalidPlatform) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileInvalidPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: invalid platform\nplatform: "
"iosmac\n ^~~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv2, MalformedFile1) {
@ -455,13 +464,13 @@ TEST(TBDv2, MalformedFile1) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
"'platform'\narchs: [ arm64 ]\n^\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv2, MalformedFile2) {
@ -472,14 +481,14 @@ TEST(TBDv2, MalformedFile2) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv2FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ(
"malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: "
"\"Unsupported key\"\n ^~~~~~~~~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
} // namespace TBDv2

View File

@ -70,9 +70,10 @@ TEST(TBDv3, ReadFile) {
" thread-local-symbols: [ _tlv3 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3File1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3File1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
auto Archs = AK_armv7 | AK_arm64;
auto Platform = PlatformKind::iOS;
@ -158,9 +159,10 @@ TEST(TBDv3, ReadMultipleDocuments) {
" symbols: [ _sym5, _sym6 ]\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Inlines, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Inlines, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(File->documents().size(), 1U);
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
auto Archs = AK_armv7 | AK_arm64;
@ -287,7 +289,7 @@ TEST(TBDv3, WriteFile) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv3File3, Buffer.c_str());
}
@ -368,7 +370,7 @@ TEST(TBDv3, WriteMultipleDocuments) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv3Inlines, Buffer.c_str());
}
@ -380,18 +382,18 @@ TEST(TBDv3, Platform_macOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformMacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformMacOS),
stripWhitespace(Buffer.c_str()));
@ -404,18 +406,18 @@ TEST(TBDv3, Platform_iOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOS), stripWhitespace(Buffer.c_str()));
}
@ -427,17 +429,18 @@ TEST(TBDv3, Platform_watchOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3watchOS, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3watchOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3watchOS), stripWhitespace(Buffer.c_str()));
}
@ -449,10 +452,10 @@ TEST(TBDv3, Platform_tvOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformtvOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
auto Platform = PlatformKind::tvOS;
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -460,8 +463,8 @@ TEST(TBDv3, Platform_tvOS) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_FALSE(WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformtvOS),
stripWhitespace(Buffer.c_str()));
}
@ -473,17 +476,18 @@ TEST(TBDv3, Platform_bridgeOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3BridgeOS, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3BridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::bridgeOS;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3BridgeOS), stripWhitespace(Buffer.c_str()));
}
@ -495,17 +499,17 @@ TEST(TBDv3, Platform_macCatalyst) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOSmac, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::macCatalyst;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOSmac),
stripWhitespace(Buffer.c_str()));
@ -518,10 +522,10 @@ TEST(TBDv3, Platform_zippered) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformZippered, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
PlatformSet Platforms;
@ -533,7 +537,7 @@ TEST(TBDv3, Platform_zippered) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformZippered),
stripWhitespace(Buffer.c_str()));
@ -546,18 +550,18 @@ TEST(TBDv3, Platform_iOSSim) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformiOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::iOSSimulator;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformiOSsim),
stripWhitespace(Buffer.c_str()));
@ -570,18 +574,18 @@ TEST(TBDv3, Platform_watchOSSim) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3watchOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto Platform = PlatformKind::watchOSSimulator;
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(Platform, *File->getPlatforms().begin());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3watchOSsim), stripWhitespace(Buffer.c_str()));
}
@ -593,10 +597,10 @@ TEST(TBDv3, Platform_tvOSSim) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3PlatformtvOSsim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
auto Platform = PlatformKind::tvOSSimulator;
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -604,7 +608,7 @@ TEST(TBDv3, Platform_tvOSSim) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3PlatformtvOSsim),
stripWhitespace(Buffer.c_str()));
@ -617,10 +621,10 @@ TEST(TBDv3, Arch_arm64e) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3ArchArm64e, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
auto Platform = PlatformKind::iOS;
auto Archs = AK_arm64 | AK_arm64e;
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
@ -630,7 +634,7 @@ TEST(TBDv3, Arch_arm64e) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3ArchArm64e), stripWhitespace(Buffer.c_str()));
}
@ -643,15 +647,16 @@ TEST(TBDv3, Swift_1_0) {
"swift-abi-version: 1.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift1, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(1U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3Swift1), stripWhitespace(Buffer.c_str()));
}
@ -664,15 +669,16 @@ TEST(TBDv3, Swift_1_1) {
"swift-abi-version: 1.1\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift1Dot, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift1Dot, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(2U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3Swift1Dot), stripWhitespace(Buffer.c_str()));
}
@ -685,15 +691,16 @@ TEST(TBDv3, Swift_2_0) {
"swift-abi-version: 2.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift2, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(3U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3Swift2), stripWhitespace(Buffer.c_str()));
}
@ -706,15 +713,16 @@ TEST(TBDv3, Swift_3_0) {
"swift-abi-version: 3.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift3, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift3, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(4U, File->getSwiftABIVersion());
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto WriteResult = TextAPIWriter::writeToStream(OS, *File);
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
EXPECT_TRUE(!WriteResult);
EXPECT_EQ(stripWhitespace(TBDv3Swift3), stripWhitespace(Buffer.c_str()));
}
@ -727,12 +735,13 @@ TEST(TBDv3, Swift_4_0) {
"swift-abi-version: 4.0\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift4, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift4, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
"version.\nswift-abi-version: 4.0\n ^~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv3, Swift_5) {
@ -743,9 +752,10 @@ TEST(TBDv3, Swift_5) {
"swift-abi-version: 5\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift5, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(5U, File->getSwiftABIVersion());
}
@ -758,9 +768,10 @@ TEST(TBDv3, Swift_99) {
"swift-abi-version: 99\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv3Swift99, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3Swift99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V3, File->getFileType());
EXPECT_EQ(99U, File->getSwiftABIVersion());
}
@ -772,7 +783,7 @@ TEST(TBDv3, UnknownArchitecture) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileUnknownArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
}
@ -783,13 +794,13 @@ TEST(TBDv3, UnknownPlatform) {
"platform: newOS\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileUnknownPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: "
"newOS\n ^~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv3, MalformedFile1) {
@ -798,13 +809,13 @@ TEST(TBDv3, MalformedFile1) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileMalformed1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
"'platform'\narchs: [ arm64 ]\n^\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv3, MalformedFile2) {
@ -815,14 +826,14 @@ TEST(TBDv3, MalformedFile2) {
"foobar: \"Unsupported key\"\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv3FileMalformed2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ(
"malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: "
"\"Unsupported key\"\n ^~~~~~~~~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
} // namespace TBDv3

View File

@ -76,9 +76,10 @@ TEST(TBDv4, ReadFile) {
" thread-local-symbols: []\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv4File, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4File, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
PlatformSet Platforms;
Platforms.insert(PlatformKind::macOS);
@ -234,9 +235,10 @@ TEST(TBDv4, ReadMultipleDocuments) {
{Targets[3], "11111111-1111-1111-1111-111111111112"},
};
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv4Inlines, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Inlines, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(Archs, File->getArchitectures());
EXPECT_EQ(Uuids, File->uuids());
@ -391,7 +393,7 @@ TEST(TBDv4, WriteFile) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv4File, Buffer.c_str());
}
@ -474,7 +476,7 @@ TEST(TBDv4, WriteMultipleDocuments) {
SmallString<4096> Buffer;
raw_svector_ostream OS(Buffer);
auto Result = TextAPIWriter::writeToStream(OS, File);
Error Result = TextAPIWriter::writeToStream(OS, File);
EXPECT_FALSE(Result);
EXPECT_STREQ(TBDv4Inlines, Buffer.c_str());
}
@ -487,14 +489,14 @@ TEST(TBDv4, MultipleTargets) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MultipleTargets, "Test.tbd"));
EXPECT_TRUE(!!Result);
PlatformSet Platforms;
Platforms.insert(PlatformKind::macCatalyst);
Platforms.insert(PlatformKind::tvOS);
Platforms.insert(PlatformKind::iOS);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(AK_x86_64 | AK_arm64 | AK_i386, File->getArchitectures());
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
@ -517,13 +519,13 @@ TEST(TBDv4, MultipleTargetsSameArch) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4TargetsSameArch, "Test.tbd"));
EXPECT_TRUE(!!Result);
PlatformSet Platforms;
Platforms.insert(PlatformKind::tvOS);
Platforms.insert(PlatformKind::macCatalyst);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
@ -546,10 +548,10 @@ TEST(TBDv4, MultipleTargetsSamePlatform) {
"install-name: Test.dylib\n"
"...\n";
auto Result = TextAPIReader::get(
Expected<TBDFile> Result = TextAPIReader::get(
MemoryBufferRef(TBDv4MultipleTargetsSamePlatform, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(AK_arm64 | AK_armv7k, File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -571,10 +573,10 @@ TEST(TBDv4, Target_maccatalyst) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4TargetMacCatalyst, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -595,10 +597,10 @@ TEST(TBDv4, Target_x86_ios) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -619,10 +621,10 @@ TEST(TBDv4, Target_arm_bridgeOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4PlatformBridgeOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PlatformKind::bridgeOS, *File->getPlatforms().begin());
@ -643,10 +645,10 @@ TEST(TBDv4, Target_arm_iOS) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4ArchArm64e, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(File->getPlatforms().size(), 1U);
EXPECT_EQ(PlatformKind::iOS, *File->getPlatforms().begin());
@ -666,10 +668,10 @@ TEST(TBDv4, Target_x86_macos) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86MacOS, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -691,10 +693,10 @@ TEST(TBDv4, Target_x86_ios_simulator) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -715,10 +717,10 @@ TEST(TBDv4, Target_x86_tvos_simulator) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4x86tvOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -739,10 +741,10 @@ TEST(TBDv4, Target_i386_watchos_simulator) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4i386watchOSSim, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
EXPECT_EQ(File->getPlatforms().size(), 1U);
@ -764,10 +766,10 @@ TEST(TBDv4, Swift_1) {
"swift-abi-version: 1\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion1, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(1U, File->getSwiftABIVersion());
@ -782,9 +784,10 @@ TEST(TBDv4, Swift_2) {
"swift-abi-version: 2\n"
"...\n";
auto Result = TextAPIReader::get(MemoryBufferRef(TBDv4Swift2, "Test.tbd"));
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4Swift2, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(2U, File->getSwiftABIVersion());
@ -799,10 +802,10 @@ TEST(TBDv4, Swift_5) {
"swift-abi-version: 5\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion5, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(5U, File->getSwiftABIVersion());
@ -822,10 +825,10 @@ TEST(TBDv4, Swift_99) {
"swift-abi-version: 99\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion99, "Test.tbd"));
EXPECT_TRUE(!!Result);
auto File = std::move(Result.get());
TBDFile File = std::move(Result.get());
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
EXPECT_EQ(99U, File->getSwiftABIVersion());
@ -844,14 +847,14 @@ TEST(TBDv4, InvalidArchitecture) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4UnknownArch, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown "
"architecture\ntargets: [ foo-macos ]\n"
" ^~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv4, InvalidPlatform) {
@ -861,14 +864,14 @@ TEST(TBDv4, InvalidPlatform) {
"install-name: Test.dylib\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4FInvalidPlatform, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown platform\ntargets: "
"[ x86_64-maos ]\n"
" ^~~~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv4, MalformedFile1) {
@ -876,13 +879,13 @@ TEST(TBDv4, MalformedFile1) {
"tbd-version: 4\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile1, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
"'targets'\ntbd-version: 4\n^\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv4, MalformedFile2) {
@ -892,14 +895,14 @@ TEST(TBDv4, MalformedFile2) {
"install-name: Test.dylib\n"
"foobar: \"unsupported key\"\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile2, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
ASSERT_EQ(
"malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: "
"\"unsupported key\"\n ^~~~~~~~~~~~~~~~~\n",
errorMessage);
ErrorMessage);
}
TEST(TBDv4, MalformedFile3) {
@ -910,13 +913,13 @@ TEST(TBDv4, MalformedFile3) {
"swift-abi-version: 1.1\n"
"...\n";
auto Result =
Expected<TBDFile> Result =
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedSwift, "Test.tbd"));
EXPECT_FALSE(!!Result);
auto errorMessage = toString(Result.takeError());
std::string ErrorMessage = toString(Result.takeError());
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
"version.\nswift-abi-version: 1.1\n ^~~\n",
errorMessage);
ErrorMessage);
}
} // end namespace TBDv4