1 //===-- TextStubV2Tests.cpp - TBD V2 File Test ----------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===-----------------------------------------------------------------------===/ 8 #include "TextStubHelpers.h" 9 #include "llvm/TextAPI/MachO/InterfaceFile.h" 10 #include "llvm/TextAPI/MachO/TextAPIReader.h" 11 #include "llvm/TextAPI/MachO/TextAPIWriter.h" 12 #include "gtest/gtest.h" 13 #include <string> 14 #include <vector> 15 16 using namespace llvm; 17 using namespace llvm::MachO; 18 19 static ExportedSymbol TBDv2Symbols[] = { 20 {SymbolKind::GlobalSymbol, "$ld$hide$os9.0$_sym1", false, false}, 21 {SymbolKind::GlobalSymbol, "_sym1", false, false}, 22 {SymbolKind::GlobalSymbol, "_sym2", false, false}, 23 {SymbolKind::GlobalSymbol, "_sym3", false, false}, 24 {SymbolKind::GlobalSymbol, "_sym4", false, false}, 25 {SymbolKind::GlobalSymbol, "_sym5", false, false}, 26 {SymbolKind::GlobalSymbol, "_tlv1", false, true}, 27 {SymbolKind::GlobalSymbol, "_tlv2", false, true}, 28 {SymbolKind::GlobalSymbol, "_tlv3", false, true}, 29 {SymbolKind::GlobalSymbol, "_weak1", true, false}, 30 {SymbolKind::GlobalSymbol, "_weak2", true, false}, 31 {SymbolKind::GlobalSymbol, "_weak3", true, false}, 32 {SymbolKind::ObjectiveCClass, "class1", false, false}, 33 {SymbolKind::ObjectiveCClass, "class2", false, false}, 34 {SymbolKind::ObjectiveCClass, "class3", false, false}, 35 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar1", false, false}, 36 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar2", false, false}, 37 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar3", false, false}, 38 }; 39 40 namespace TBDv2 { 41 42 TEST(TBDv2, ReadFile) { 43 static const char tbd_v2_file1[] = 44 "--- !tapi-tbd-v2\n" 45 "archs: [ armv7, armv7s, armv7k, arm64 ]\n" 46 "platform: ios\n" 47 "flags: [ installapi ]\n" 48 "install-name: Test.dylib\n" 49 "current-version: 2.3.4\n" 50 "compatibility-version: 1.0\n" 51 "swift-version: 1.1\n" 52 "parent-umbrella: Umbrella.dylib\n" 53 "exports:\n" 54 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 55 " allowable-clients: [ clientA ]\n" 56 " re-exports: [ /usr/lib/libfoo.dylib ]\n" 57 " symbols: [ _sym1, _sym2, _sym3, _sym4, $ld$hide$os9.0$_sym1 ]\n" 58 " objc-classes: [ _class1, _class2 ]\n" 59 " objc-ivars: [ _class1._ivar1, _class1._ivar2 ]\n" 60 " weak-def-symbols: [ _weak1, _weak2 ]\n" 61 " thread-local-symbols: [ _tlv1, _tlv2 ]\n" 62 " - archs: [ armv7, armv7s, armv7k ]\n" 63 " symbols: [ _sym5 ]\n" 64 " objc-classes: [ _class3 ]\n" 65 " objc-ivars: [ _class1._ivar3 ]\n" 66 " weak-def-symbols: [ _weak3 ]\n" 67 " thread-local-symbols: [ _tlv3 ]\n" 68 "...\n"; 69 70 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file1, "Test.tbd")); 71 EXPECT_TRUE(!!Result); 72 auto File = std::move(Result.get()); 73 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 74 auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64; 75 auto Platform = PlatformKind::iOS; 76 TargetList Targets; 77 for (auto &&arch : Archs) 78 Targets.emplace_back(Target(arch, Platform)); 79 EXPECT_EQ(Archs, File->getArchitectures()); 80 EXPECT_EQ(File->getPlatforms().size(), 1U); 81 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 82 EXPECT_EQ(std::string("Test.dylib"), File->getInstallName()); 83 EXPECT_EQ(PackedVersion(2, 3, 4), File->getCurrentVersion()); 84 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion()); 85 EXPECT_EQ(2U, File->getSwiftABIVersion()); 86 EXPECT_EQ(ObjCConstraintType::Retain_Release, File->getObjCConstraint()); 87 EXPECT_TRUE(File->isTwoLevelNamespace()); 88 EXPECT_TRUE(File->isApplicationExtensionSafe()); 89 EXPECT_TRUE(File->isInstallAPI()); 90 InterfaceFileRef client("clientA", Targets); 91 InterfaceFileRef reexport("/usr/lib/libfoo.dylib", Targets); 92 EXPECT_EQ(1U, File->allowableClients().size()); 93 EXPECT_EQ(client, File->allowableClients().front()); 94 EXPECT_EQ(1U, File->reexportedLibraries().size()); 95 EXPECT_EQ(reexport, File->reexportedLibraries().front()); 96 97 ExportedSymbolSeq Exports; 98 for (const auto *Sym : File->symbols()) { 99 EXPECT_FALSE(Sym->isWeakReferenced()); 100 EXPECT_FALSE(Sym->isUndefined()); 101 Exports.emplace_back( 102 ExportedSymbol{Sym->getKind(), std::string(Sym->getName()), 103 Sym->isWeakDefined(), Sym->isThreadLocalValue()}); 104 } 105 llvm::sort(Exports.begin(), Exports.end()); 106 107 EXPECT_EQ(sizeof(TBDv2Symbols) / sizeof(ExportedSymbol), Exports.size()); 108 EXPECT_TRUE( 109 std::equal(Exports.begin(), Exports.end(), std::begin(TBDv2Symbols))); 110 } 111 112 TEST(TBDv2, ReadFile2) { 113 static const char tbd_v2_file2[] = 114 "--- !tapi-tbd-v2\n" 115 "archs: [ armv7, armv7s, armv7k, arm64 ]\n" 116 "platform: ios\n" 117 "flags: [ flat_namespace, not_app_extension_safe ]\n" 118 "install-name: Test.dylib\n" 119 "swift-version: 1.1\n" 120 "exports:\n" 121 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 122 " symbols: [ _sym1, _sym2, _sym3, _sym4, $ld$hide$os9.0$_sym1 ]\n" 123 " objc-classes: [ _class1, _class2 ]\n" 124 " objc-ivars: [ _class1._ivar1, _class1._ivar2 ]\n" 125 " weak-def-symbols: [ _weak1, _weak2 ]\n" 126 " thread-local-symbols: [ _tlv1, _tlv2 ]\n" 127 " - archs: [ armv7, armv7s, armv7k ]\n" 128 " symbols: [ _sym5 ]\n" 129 " objc-classes: [ _class3 ]\n" 130 " objc-ivars: [ _class1._ivar3 ]\n" 131 " weak-def-symbols: [ _weak3 ]\n" 132 " thread-local-symbols: [ _tlv3 ]\n" 133 "undefineds:\n" 134 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 135 " symbols: [ _undefSym1, _undefSym2, _undefSym3 ]\n" 136 " objc-classes: [ _undefClass1, _undefClass2 ]\n" 137 " objc-ivars: [ _undefClass1._ivar1, _undefClass1._ivar2 ]\n" 138 " weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n" 139 "...\n"; 140 141 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_file2, "Test.tbd")); 142 EXPECT_TRUE(!!Result); 143 auto File = std::move(Result.get()); 144 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 145 auto Archs = AK_armv7 | AK_armv7s | AK_armv7k | AK_arm64; 146 auto Platform = PlatformKind::iOS; 147 TargetList Targets; 148 for (auto &&arch : Archs) 149 Targets.emplace_back(Target(arch, Platform)); 150 EXPECT_EQ(Archs, File->getArchitectures()); 151 EXPECT_EQ(File->getPlatforms().size(), 1U); 152 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 153 EXPECT_EQ(std::string("Test.dylib"), File->getInstallName()); 154 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCurrentVersion()); 155 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion()); 156 EXPECT_EQ(2U, File->getSwiftABIVersion()); 157 EXPECT_EQ(ObjCConstraintType::Retain_Release, File->getObjCConstraint()); 158 EXPECT_FALSE(File->isTwoLevelNamespace()); 159 EXPECT_FALSE(File->isApplicationExtensionSafe()); 160 EXPECT_FALSE(File->isInstallAPI()); 161 EXPECT_EQ(0U, File->allowableClients().size()); 162 EXPECT_EQ(0U, File->reexportedLibraries().size()); 163 } 164 165 TEST(TBDv2, WriteFile) { 166 static const char tbd_v2_file3[] = 167 "--- !tapi-tbd-v2\n" 168 "archs: [ i386, x86_64 ]\n" 169 "platform: macosx\n" 170 "install-name: '/usr/lib/libfoo.dylib'\n" 171 "current-version: 1.2.3\n" 172 "compatibility-version: 0\n" 173 "swift-version: 5\n" 174 "exports:\n" 175 " - archs: [ i386 ]\n" 176 " symbols: [ _sym1 ]\n" 177 " weak-def-symbols: [ _sym2 ]\n" 178 " thread-local-symbols: [ _sym3 ]\n" 179 " - archs: [ x86_64 ]\n" 180 " allowable-clients: [ clientA ]\n" 181 " re-exports: [ '/usr/lib/libfoo.dylib' ]\n" 182 " symbols: [ '_OBJC_EHTYPE_$_Class1' ]\n" 183 " objc-classes: [ _Class1 ]\n" 184 " objc-ivars: [ _Class1._ivar1 ]\n" 185 "...\n"; 186 187 InterfaceFile File; 188 TargetList Targets; 189 for (auto &&arch : AK_i386 | AK_x86_64) 190 Targets.emplace_back(Target(arch, PlatformKind::macOS)); 191 File.setPath("libfoo.dylib"); 192 File.setInstallName("/usr/lib/libfoo.dylib"); 193 File.setFileType(FileType::TBD_V2); 194 File.addTargets(Targets); 195 File.setCurrentVersion(PackedVersion(1, 2, 3)); 196 File.setTwoLevelNamespace(); 197 File.setApplicationExtensionSafe(); 198 File.setSwiftABIVersion(5); 199 File.setObjCConstraint(ObjCConstraintType::Retain_Release); 200 File.addAllowableClient("clientA", Targets[1]); 201 File.addReexportedLibrary("/usr/lib/libfoo.dylib", Targets[1]); 202 File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", {Targets[0]}); 203 File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", {Targets[0]}, 204 SymbolFlags::WeakDefined); 205 File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", {Targets[0]}, 206 SymbolFlags::ThreadLocalValue); 207 File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", {Targets[1]}); 208 File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1", {Targets[1]}); 209 File.addSymbol(SymbolKind::ObjectiveCInstanceVariable, "Class1._ivar1", 210 {Targets[1]}); 211 212 SmallString<4096> Buffer; 213 raw_svector_ostream OS(Buffer); 214 auto Result = TextAPIWriter::writeToStream(OS, File); 215 EXPECT_FALSE(Result); 216 EXPECT_STREQ(tbd_v2_file3, Buffer.c_str()); 217 } 218 219 TEST(TBDv2, Platform_macOS) { 220 static const char tbd_v2_platform_macos[] = "--- !tapi-tbd-v2\n" 221 "archs: [ x86_64 ]\n" 222 "platform: macosx\n" 223 "install-name: Test.dylib\n" 224 "...\n"; 225 226 auto Result = 227 TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_macos, "Test.tbd")); 228 EXPECT_TRUE(!!Result); 229 auto File = std::move(Result.get()); 230 auto Platform = PlatformKind::macOS; 231 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 232 EXPECT_EQ(File->getPlatforms().size(), 1U); 233 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 234 } 235 236 TEST(TBDv2, Platform_iOS) { 237 static const char tbd_v2_platform_ios[] = "--- !tapi-tbd-v2\n" 238 "archs: [ arm64 ]\n" 239 "platform: ios\n" 240 "install-name: Test.dylib\n" 241 "...\n"; 242 243 auto Result = 244 TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_ios, "Test.tbd")); 245 EXPECT_TRUE(!!Result); 246 auto Platform = PlatformKind::iOS; 247 auto File = std::move(Result.get()); 248 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 249 EXPECT_EQ(File->getPlatforms().size(), 1U); 250 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 251 } 252 253 TEST(TBDv2, Platform_watchOS) { 254 static const char tbd_v2_platform_watchos[] = "--- !tapi-tbd-v2\n" 255 "archs: [ armv7k ]\n" 256 "platform: watchos\n" 257 "install-name: Test.dylib\n" 258 "...\n"; 259 260 auto Result = 261 TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_watchos, "Test.tbd")); 262 EXPECT_TRUE(!!Result); 263 auto Platform = PlatformKind::watchOS; 264 auto File = std::move(Result.get()); 265 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 266 EXPECT_EQ(File->getPlatforms().size(), 1U); 267 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 268 } 269 270 TEST(TBDv2, Platform_tvOS) { 271 static const char tbd_v2_platform_tvos[] = "--- !tapi-tbd-v2\n" 272 "archs: [ arm64 ]\n" 273 "platform: tvos\n" 274 "install-name: Test.dylib\n" 275 "...\n"; 276 277 auto Result = 278 TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_tvos, "Test.tbd")); 279 EXPECT_TRUE(!!Result); 280 auto Platform = PlatformKind::tvOS; 281 auto File = std::move(Result.get()); 282 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 283 EXPECT_EQ(File->getPlatforms().size(), 1U); 284 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 285 } 286 287 TEST(TBDv2, Platform_bridgeOS) { 288 static const char tbd_v2_platform_bridgeos[] = "--- !tapi-tbd-v2\n" 289 "archs: [ armv7k ]\n" 290 "platform: bridgeos\n" 291 "install-name: Test.dylib\n" 292 "...\n"; 293 294 auto Result = 295 TextAPIReader::get(MemoryBufferRef(tbd_v2_platform_bridgeos, "Test.tbd")); 296 EXPECT_TRUE(!!Result); 297 auto Platform = PlatformKind::bridgeOS; 298 auto File = std::move(Result.get()); 299 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 300 EXPECT_EQ(File->getPlatforms().size(), 1U); 301 EXPECT_EQ(Platform, *File->getPlatforms().begin()); 302 } 303 304 TEST(TBDv2, Swift_1_0) { 305 static const char tbd_v2_swift_1_0[] = "--- !tapi-tbd-v2\n" 306 "archs: [ arm64 ]\n" 307 "platform: ios\n" 308 "install-name: Test.dylib\n" 309 "swift-version: 1.0\n" 310 "...\n"; 311 312 auto Result = 313 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_1_0, "Test.tbd")); 314 EXPECT_TRUE(!!Result); 315 auto File = std::move(Result.get()); 316 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 317 EXPECT_EQ(1U, File->getSwiftABIVersion()); 318 } 319 320 TEST(TBDv2, Swift_1_1) { 321 static const char tbd_v2_swift_1_1[] = "--- !tapi-tbd-v2\n" 322 "archs: [ arm64 ]\n" 323 "platform: ios\n" 324 "install-name: Test.dylib\n" 325 "swift-version: 1.1\n" 326 "...\n"; 327 328 auto Result = 329 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_1_1, "Test.tbd")); 330 EXPECT_TRUE(!!Result); 331 auto File = std::move(Result.get()); 332 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 333 EXPECT_EQ(2U, File->getSwiftABIVersion()); 334 } 335 336 TEST(TBDv2, Swift_2_0) { 337 static const char tbd_v2_swift_2_0[] = "--- !tapi-tbd-v2\n" 338 "archs: [ arm64 ]\n" 339 "platform: ios\n" 340 "install-name: Test.dylib\n" 341 "swift-version: 2.0\n" 342 "...\n"; 343 344 auto Result = 345 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_2_0, "Test.tbd")); 346 EXPECT_TRUE(!!Result); 347 auto File = std::move(Result.get()); 348 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 349 EXPECT_EQ(3U, File->getSwiftABIVersion()); 350 } 351 352 TEST(TBDv2, Swift_3_0) { 353 static const char tbd_v2_swift_3_0[] = "--- !tapi-tbd-v2\n" 354 "archs: [ arm64 ]\n" 355 "platform: ios\n" 356 "install-name: Test.dylib\n" 357 "swift-version: 3.0\n" 358 "...\n"; 359 360 auto Result = 361 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_3_0, "Test.tbd")); 362 EXPECT_TRUE(!!Result); 363 auto File = std::move(Result.get()); 364 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 365 EXPECT_EQ(4U, File->getSwiftABIVersion()); 366 } 367 368 TEST(TBDv2, Swift_4_0) { 369 static const char tbd_v2_swift_4_0[] = "--- !tapi-tbd-v2\n" 370 "archs: [ arm64 ]\n" 371 "platform: ios\n" 372 "install-name: Test.dylib\n" 373 "swift-version: 4.0\n" 374 "...\n"; 375 376 auto Result = 377 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_4_0, "Test.tbd")); 378 EXPECT_FALSE(!!Result); 379 auto errorMessage = toString(Result.takeError()); 380 EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI " 381 "version.\nswift-version: 4.0\n ^~~\n", 382 errorMessage); 383 } 384 385 TEST(TBDv2, Swift_5) { 386 static const char tbd_v2_swift_5[] = "--- !tapi-tbd-v2\n" 387 "archs: [ arm64 ]\n" 388 "platform: ios\n" 389 "install-name: Test.dylib\n" 390 "swift-version: 5\n" 391 "...\n"; 392 393 auto Result = TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_5, "Test.tbd")); 394 EXPECT_TRUE(!!Result); 395 auto File = std::move(Result.get()); 396 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 397 EXPECT_EQ(5U, File->getSwiftABIVersion()); 398 } 399 400 TEST(TBDv2, Swift_99) { 401 static const char tbd_v2_swift_99[] = "--- !tapi-tbd-v2\n" 402 "archs: [ arm64 ]\n" 403 "platform: ios\n" 404 "install-name: Test.dylib\n" 405 "swift-version: 99\n" 406 "...\n"; 407 408 auto Result = 409 TextAPIReader::get(MemoryBufferRef(tbd_v2_swift_99, "Test.tbd")); 410 EXPECT_TRUE(!!Result); 411 auto File = std::move(Result.get()); 412 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 413 EXPECT_EQ(99U, File->getSwiftABIVersion()); 414 } 415 416 TEST(TBDv2, UnknownArchitecture) { 417 static const char tbd_v2_file_unknown_architecture[] = 418 "--- !tapi-tbd-v2\n" 419 "archs: [ foo ]\n" 420 "platform: macosx\n" 421 "install-name: Test.dylib\n" 422 "...\n"; 423 auto Result = TextAPIReader::get( 424 MemoryBufferRef(tbd_v2_file_unknown_architecture, "Test.tbd")); 425 EXPECT_TRUE(!!Result); 426 } 427 428 TEST(TBDv2, UnknownPlatform) { 429 static const char tbd_v2_file_unknown_platform[] = "--- !tapi-tbd-v2\n" 430 "archs: [ i386 ]\n" 431 "platform: newOS\n" 432 "...\n"; 433 434 auto Result = TextAPIReader::get( 435 MemoryBufferRef(tbd_v2_file_unknown_platform, "Test.tbd")); 436 EXPECT_FALSE(!!Result); 437 auto errorMessage = toString(Result.takeError()); 438 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: " 439 "newOS\n ^~~~~\n", 440 errorMessage); 441 } 442 443 TEST(TBDv2, InvalidPlatform) { 444 static const char tbd_v2_file_invalid_platform[] = 445 "--- !tapi-tbd-v2\n" 446 "archs: [ i386 ]\n" 447 "platform: iosmac\n" 448 "install-name: Test.dylib\n" 449 "...\n"; 450 451 auto Result = TextAPIReader::get( 452 MemoryBufferRef(tbd_v2_file_invalid_platform, "Test.tbd")); 453 EXPECT_FALSE(!!Result); 454 auto errorMessage = toString(Result.takeError()); 455 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: invalid platform\nplatform: " 456 "iosmac\n ^~~~~~\n", 457 errorMessage); 458 } 459 460 TEST(TBDv2, MalformedFile1) { 461 static const char malformed_file1[] = "--- !tapi-tbd-v2\n" 462 "archs: [ arm64 ]\n" 463 "foobar: \"Unsupported key\"\n" 464 "...\n"; 465 466 auto Result = 467 TextAPIReader::get(MemoryBufferRef(malformed_file1, "Test.tbd")); 468 EXPECT_FALSE(!!Result); 469 auto errorMessage = toString(Result.takeError()); 470 ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key " 471 "'platform'\narchs: [ arm64 ]\n^\n", 472 errorMessage); 473 } 474 475 TEST(TBDv2, MalformedFile2) { 476 static const char malformed_file2[] = "--- !tapi-tbd-v2\n" 477 "archs: [ arm64 ]\n" 478 "platform: ios\n" 479 "install-name: Test.dylib\n" 480 "foobar: \"Unsupported key\"\n" 481 "...\n"; 482 483 auto Result = 484 TextAPIReader::get(MemoryBufferRef(malformed_file2, "Test.tbd")); 485 EXPECT_FALSE(!!Result); 486 auto errorMessage = toString(Result.takeError()); 487 ASSERT_EQ( 488 "malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: " 489 "\"Unsupported key\"\n ^~~~~~~~~~~~~~~~~\n", 490 errorMessage); 491 } 492 493 } // namespace TBDv2 494