1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.coroutines.debug.junit4 6 7 import kotlinx.coroutines.* 8 import org.junit.* 9 import org.junit.runners.model.* 10 11 class CoroutinesTimeoutDisabledTracesTest : TestBase(disableOutCheck = true) { 12 13 @Rule 14 @JvmField 15 public val validation = TestFailureValidation( 16 500, true, false, 17 TestResultSpec( 18 "hangingTest", expectedOutParts = listOf( 19 "Coroutines dump", 20 "Test hangingTest timed out after 500 milliseconds", 21 "BlockingCoroutine{Active}", 22 "at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutDisabledTracesTest.hangForever", 23 "at kotlinx.coroutines.debug.junit4.CoroutinesTimeoutDisabledTracesTest.waitForHangJob" 24 ), 25 notExpectedOutParts = listOf("_COROUTINE._CREATION._"), 26 error = TestTimedOutException::class.java 27 ) 28 ) 29 <lambda>null30 private val job = GlobalScope.launch(Dispatchers.Unconfined) { hangForever() } 31 hangForevernull32 private suspend fun hangForever() { 33 suspendCancellableCoroutine<Unit> { } 34 expectUnreached() 35 } 36 37 @Test <lambda>null38 fun hangingTest() = runBlocking<Unit> { 39 waitForHangJob() 40 expectUnreached() 41 } 42 waitForHangJobnull43 private suspend fun waitForHangJob() { 44 job.join() 45 expectUnreached() 46 } 47 } 48