Commit bc3bb7c
test(deflake): deterministic joins for AccountsManager/Catalog/TokenRefresh async tests
Parallel-CI-clone starvation de-flake (continuation of #1319). Under CI's 2 sim
clones, tests that poll a fire-and-forget async op on a fixed wall-clock deadline
lose the CPU race and fail all 3 retries. Convert each to a deterministic JOIN
that awaits the ACTUAL async work — no clock, cannot starve.
- AccountsManager.swift: add an XCTest-gated first-run-task registry +
`_awaitAllCrawlTasksForTesting()` join seam (mirrors the existing
`_trackCrawlTask`/`fetchFromNetworkCountForTesting` conventions). Joins ONLY the
first-run task (bundled decode → synchronous fetchFromNetwork kickoff), not the
downstream live network crawl. Lock snapshot split into a synchronous helper
(NSLock.lock/unlock are banned in async contexts under Swift 6).
- AccountsManagerFirstRunDecodeTests: 3 tests → async + await the seam (was
RunLoop/wait(for:timeout:5)).
- CatalogRepositoryStaleWhileRevalidateTests: concurrent-reads test now joins
BOTH background refreshes via _awaitAllBackgroundRefreshesForTesting() (was
racily joining only the last-scheduled handle).
- TokenRefreshAndRetryQueueTests: every fire-and-forget refresh/retry wait → a
semaphore signalled at the exact event, bridged to async off the cooperative
pool via withCheckedContinuation + DispatchQueue.global (Task.detached's
closure is itself async, so sem.wait() there is a Swift 6 error).
**Scope:** test-hermeticity + one XCTest-gated production seam on AccountsManager
(RELEASE byte-identical — the tracking arrays only populate under XCTest, the
join seam is the only consumer and production never calls it; verified
_trackCrawlTask is also XCTest-gated so the call-site swap is a no-op in RELEASE).
**Not done:** TokenRefreshInterceptorAuthCoordinatorTests (confirmed same
timing/join class, fix in a follow-up commit this session).
**Deferred:** the broader 135-file deadline-poll surface — only the observed-failing
tests are converted; more may surface per CI run and get the same treatment.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 69a3a2f commit bc3bb7c
4 files changed
Lines changed: 227 additions & 104 deletions
File tree
- PalaceTests
- Accounts
- CatalogDomain
- Network
- Palace/Accounts/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
424 | 436 | | |
425 | 437 | | |
426 | 438 | | |
| |||
453 | 465 | | |
454 | 466 | | |
455 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
456 | 525 | | |
457 | 526 | | |
458 | 527 | | |
| |||
1225 | 1294 | | |
1226 | 1295 | | |
1227 | 1296 | | |
1228 | | - | |
| 1297 | + | |
1229 | 1298 | | |
1230 | 1299 | | |
1231 | 1300 | | |
| |||
2073 | 2142 | | |
2074 | 2143 | | |
2075 | 2144 | | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
2076 | 2149 | | |
2077 | 2150 | | |
2078 | 2151 | | |
| |||
Lines changed: 23 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 132 | | |
146 | 133 | | |
147 | 134 | | |
148 | 135 | | |
149 | 136 | | |
150 | 137 | | |
151 | | - | |
| 138 | + | |
152 | 139 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 140 | + | |
160 | 141 | | |
161 | 142 | | |
162 | 143 | | |
| |||
172 | 153 | | |
173 | 154 | | |
174 | 155 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
179 | 162 | | |
180 | 163 | | |
181 | 164 | | |
| |||
190 | 173 | | |
191 | 174 | | |
192 | 175 | | |
193 | | - | |
| 176 | + | |
194 | 177 | | |
195 | 178 | | |
196 | 179 | | |
| |||
204 | 187 | | |
205 | 188 | | |
206 | 189 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
211 | 196 | | |
212 | | - | |
| 197 | + | |
213 | 198 | | |
214 | 199 | | |
215 | 200 | | |
| |||
222 | 207 | | |
223 | 208 | | |
224 | 209 | | |
225 | | - | |
| 210 | + | |
226 | 211 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 212 | + | |
233 | 213 | | |
234 | 214 | | |
235 | 215 | | |
| |||
239 | 219 | | |
240 | 220 | | |
241 | 221 | | |
242 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
243 | 227 | | |
244 | 228 | | |
245 | 229 | | |
| |||
Lines changed: 26 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| |||
369 | 372 | | |
370 | 373 | | |
371 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
372 | 385 | | |
373 | 386 | | |
374 | 387 | | |
| |||
381 | 394 | | |
382 | 395 | | |
383 | 396 | | |
384 | | - | |
| 397 | + | |
385 | 398 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
394 | 407 | | |
395 | 408 | | |
396 | 409 | | |
| |||
0 commit comments