Harden the racy signal assertions in NoiseCancellationSignalTest - #1791
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughThe noise cancellation signal tests now record signals in a thread-safe list and poll for expected values before asserting. Four tests use the new polling helpers. ChangesNoise cancellation signal test synchronization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This test-only change makes asynchronous signal assertions thread-safe and more reliable without changing production behavior, public interfaces, security controls, or deployment configuration; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description covers the goal, implementation, UI applicability, testing, issue reference, affected file, and test results. The UI and GIF sections are appropriately addressed or non-critical for this test-only change.
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
@CodeRabbit review |
|
|
🚀 Available in v1.32.0 |



Goal
Fix the test that fails deterministically on the develop-v2 merge PR #1790:
NoiseCancellationSignalTest > a replacement session is told the current statefails there withexpected:<[true]> but was:<[]>on every attempt of the Android CI run, while it passes on develop.Resolves AND-1465.
Implementation
The failure is a race in the test, not in the production code. The
recordhelper collects the signalled states into a plainmutableListOffrom the mock'scoAnswersblock, which runs on the signal coroutine. The tests assert on that list right after acoVerify(timeout = ...). MockK records the invocation before the answer block finishes, and the list is not thread safe, so the assert can run before the append is visible to the test thread. develop's coroutines 1.9.0 happens to give the timing the test needs; develop-v2's coroutines 1.10.2 consistently does not.Changes, all in
NoiseCancellationSignalTest.kt:record()now collects into aCopyOnWriteArrayList, so writes from the signal coroutine are visible to the test thread.awaitSignalledfor the exact-content checks andawaitFinalSignalfor the "rapid changes" test where only the last state matters.No production code change.
🎨 UI Changes
Not applicable, test-only change.
Testing
--rerun-tasks): 8 tests, 0 failures each time.Summary by CodeRabbit