From 5a2a78d87d5c050f9d4ccbf970a93c38c84b5711 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Tue, 18 Feb 2025 13:46:32 -0500 Subject: [PATCH] Widen test bound to avoid flakiness (#708) --- .../jakewharton/mosaic/terminal/PlatformInputTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mosaic-terminal/src/commonTest/kotlin/com/jakewharton/mosaic/terminal/PlatformInputTest.kt b/mosaic-terminal/src/commonTest/kotlin/com/jakewharton/mosaic/terminal/PlatformInputTest.kt index bf921b24..1b96f726 100644 --- a/mosaic-terminal/src/commonTest/kotlin/com/jakewharton/mosaic/terminal/PlatformInputTest.kt +++ b/mosaic-terminal/src/commonTest/kotlin/com/jakewharton/mosaic/terminal/PlatformInputTest.kt @@ -80,21 +80,21 @@ class PlatformInputTest { } @Test fun readWithTimeoutReturnsZeroOnTimeout() { - // The timeouts passed are slightly higher than those validated thanks to Windows which - // can return _slightly_ early. Usually it's around .1ms, but we go 10ms to be sure. + // Windows appears to be happy to return a few milliseconds early, so we just validate a + // conservative lower bound which indicates that there was at least _some_ waiting. val readA: Int val tookA = measureTime { - readA = input.readWithTimeout(ByteArray(10), 0, 10, 110) + readA = input.readWithTimeout(ByteArray(10), 0, 10, 100) } assertThat(readA).isZero() - assertThat(tookA).isGreaterThan(100.milliseconds) + assertThat(tookA).isGreaterThan(50.milliseconds) val readB: Int val tookB = measureTime { - readB = input.readWithTimeout(ByteArray(10), 0, 10, 110) + readB = input.readWithTimeout(ByteArray(10), 0, 10, 100) } assertThat(readB).isZero() - assertThat(tookB).isGreaterThan(100.milliseconds) + assertThat(tookB).isGreaterThan(50.milliseconds) } }