email: make EmlViewerSuccessTest awaitText step-counted
- Commit
7825901c32006cb17b043da18f9b59c7a814587f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 12:22 UTC (19 days ago)
- Parents
2fc4789
CI failed EmlViewerSuccessTest's parseable-eml-renders test. Its own class comment records the same symptom from before: in a shared class the file-backed parse intermittently never lands. awaitText bounded its wait by System.currentTimeMillis while idling the Robolectric main looper every step. That substituted clock can run far ahead of real time as the looper is pumped, so the nominal 15 seconds expired in far less real time on a loaded box, before the Dispatchers.IO parse it waits for had landed and resumed. The wait now counts 3000 steps with a real Thread.sleep(10) per step, so the budget is a real duration spent polling the same condition (the node exists in the semantics tree). Every assertion in the test is unchanged. Verified: EmlViewerSuccessTest passes directly, and :email:testDevUnitTest was green in two parallel all-module runs.
Diff
email/src/test/java/com/vayunmathur/email/ui/EmlViewerSuccessTest.kt
diff --git a/email/src/test/java/com/vayunmathur/email/ui/EmlViewerSuccessTest.kt b/email/src/test/java/com/vayunmathur/email/ui/EmlViewerSuccessTest.ktindex ff455372c0..04a3a746e9 100644--- a/email/src/test/java/com/vayunmathur/email/ui/EmlViewerSuccessTest.kt+++ b/email/src/test/java/com/vayunmathur/email/ui/EmlViewerSuccessTest.kt@@ -45,8 +45,12 @@ class EmlViewerSuccessTest { * result sat queued past the wait (see ComposerSendTest). */ private fun awaitText(text: String, substring: Boolean = false, unmerged: Boolean = false) {- val deadline = System.currentTimeMillis() + 15_000- while (System.currentTimeMillis() < deadline) {+ // Step-counted, not wall-clock: Robolectric's substituted clock+ // can run far ahead of real time while the looper is idled, so a+ // 15s deadline expired before the IO parse it waits for had run+ // on a loaded CI box. Each step sleeps real time instead.+ var step = 0+ while (step++ < 3_000) { org.robolectric.Shadows.shadowOf(android.os.Looper.getMainLooper()).idle() if (composeRule.onAllNodesWithText(text, substring = substring, useUnmergedTree = unmerged) .fetchSemanticsNodes().isNotEmpty()