Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable tests with real source of the time on Java's Windows to preve… #3516

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kotlinx-coroutines-core/common/test/JobTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class JobTest : TestBase() {
}
assertTrue(job.isActive)
for (i in 0 until n) assertEquals(0, fireCount[i])
val tryCancel = Try { job.cancel() }
val cancelResult = runCatching { job.cancel() }
assertTrue(!job.isActive)
for (i in 0 until n) assertEquals(1, fireCount[i])
assertTrue(tryCancel.exception is CompletionHandlerException)
assertTrue(tryCancel.exception!!.cause is TestException)
assertTrue(cancelResult.exceptionOrNull() is CompletionHandlerException)
assertTrue(cancelResult.exceptionOrNull()!!.cause is TestException)
}

@Test
Expand Down
2 changes: 2 additions & 0 deletions kotlinx-coroutines-core/common/test/TestBase.common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ class BadClass {
override fun hashCode(): Int = error("hashCode")
override fun toString(): String = error("toString")
}

public expect val isJavaAndWindows: Boolean
29 changes: 0 additions & 29 deletions kotlinx-coroutines-core/common/test/Try.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class WithTimeoutOrNullDurationTest : TestBase() {

@Test
fun testOuterTimeout() = runTest {
if (isJavaAndWindows) return@runTest
var counter = 0
val result = withTimeoutOrNull(320.milliseconds) {
while (true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class WithTimeoutOrNullTest : TestBase() {

@Test
fun testOuterTimeout() = runTest {
if (isJavaAndWindows) return@runTest
var counter = 0
val result = withTimeoutOrNull(320) {
while (true) {
Expand Down
2 changes: 2 additions & 0 deletions kotlinx-coroutines-core/js/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ public actual open class TestBase actual constructor() {

private fun <T> Promise<T>.finally(block: () -> Unit): Promise<T> =
then(onFulfilled = { value -> block(); value }, onRejected = { ex -> block(); throw ex })

public actual val isJavaAndWindows: Boolean get() = false
7 changes: 7 additions & 0 deletions kotlinx-coroutines-core/jvm/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,10 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {

protected suspend fun currentDispatcher() = coroutineContext[ContinuationInterceptor]!!
}

/*
* We ignore tests that test **real** non-virtualized tests with time on Windows, because
* our CI Windows is virtualized itself (oh, the irony) and its clock resolution is dozens of ms,
* which makes such tests flaky.
*/
public actual val isJavaAndWindows: Boolean = System.getProperty("os.name")!!.contains("Windows")
2 changes: 2 additions & 0 deletions kotlinx-coroutines-core/native/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ public actual open class TestBase actual constructor() {
error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
}
}

public actual val isJavaAndWindows: Boolean get() = false