@@ -1132,6 +1132,71 @@ TEST_F(CoreAPIsStandardTest, SimpleAsynchronousGeneratorTest) {
11321132 EXPECT_TRUE (LookupCompleted);
11331133}
11341134
1135+ TEST_F (CoreAPIsStandardTest, ErrorFromSuspendedAsynchronousGeneratorTest) {
1136+
1137+ auto &G = JD.addGenerator (std::make_unique<SimpleAsyncGenerator>());
1138+
1139+ bool LookupCompleted = false ;
1140+
1141+ ES.lookup (
1142+ LookupKind::Static, makeJITDylibSearchOrder (&JD), SymbolLookupSet (Foo),
1143+ SymbolState::Ready,
1144+ [&](Expected<SymbolMap> Result) {
1145+ LookupCompleted = true ;
1146+ EXPECT_THAT_EXPECTED (Result, Failed ());
1147+ },
1148+ NoDependenciesToRegister);
1149+
1150+ EXPECT_FALSE (LookupCompleted);
1151+
1152+ G.takeLookup ().LS .continueLookup (
1153+ make_error<StringError>(" boom" , inconvertibleErrorCode ()));
1154+
1155+ EXPECT_TRUE (LookupCompleted);
1156+ }
1157+
1158+ TEST_F (CoreAPIsStandardTest, ErrorFromAutoSuspendedAsynchronousGeneratorTest) {
1159+
1160+ auto &G = JD.addGenerator (std::make_unique<SimpleAsyncGenerator>());
1161+
1162+ std::atomic_size_t LookupsCompleted = 0 ;
1163+
1164+ ES.lookup (
1165+ LookupKind::Static, makeJITDylibSearchOrder (&JD), SymbolLookupSet (Foo),
1166+ SymbolState::Ready,
1167+ [&](Expected<SymbolMap> Result) {
1168+ ++LookupsCompleted;
1169+ EXPECT_THAT_EXPECTED (Result, Failed ());
1170+ },
1171+ NoDependenciesToRegister);
1172+
1173+ EXPECT_EQ (LookupsCompleted, 0 );
1174+
1175+ // Suspend the first lookup.
1176+ auto LS1 = std::move (G.takeLookup ().LS );
1177+
1178+ // Start a second lookup that should be auto-suspended.
1179+ ES.lookup (
1180+ LookupKind::Static, makeJITDylibSearchOrder (&JD), SymbolLookupSet (Foo),
1181+ SymbolState::Ready,
1182+ [&](Expected<SymbolMap> Result) {
1183+ ++LookupsCompleted;
1184+ EXPECT_THAT_EXPECTED (Result, Failed ());
1185+ },
1186+ NoDependenciesToRegister);
1187+
1188+ EXPECT_EQ (LookupsCompleted, 0 );
1189+
1190+ // Unsuspend the first lookup.
1191+ LS1.continueLookup (make_error<StringError>(" boom" , inconvertibleErrorCode ()));
1192+
1193+ // Unsuspend the second.
1194+ G.takeLookup ().LS .continueLookup (
1195+ make_error<StringError>(" boom" , inconvertibleErrorCode ()));
1196+
1197+ EXPECT_EQ (LookupsCompleted, 2 );
1198+ }
1199+
11351200TEST_F (CoreAPIsStandardTest, BlockedGeneratorAutoSuspensionTest) {
11361201 // Test that repeated lookups while a generator is in use cause automatic
11371202 // lookup suspension / resumption.
0 commit comments