Skip to content

Commit b8d2794

Browse files
authored
Promote the test module deprecation levels for 1.7.0 (#3655)
1 parent 2a05088 commit b8d2794

10 files changed

+44
-43
lines changed

kotlinx-coroutines-test/jvm/src/migration/DelayController.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4-
@file:Suppress("DEPRECATION")
4+
@file:Suppress("DEPRECATION_ERROR")
55

66
package kotlinx.coroutines.test
77

@@ -21,7 +21,7 @@ import kotlinx.coroutines.*
2121
@ExperimentalCoroutinesApi
2222
@Deprecated(
2323
"Use `TestCoroutineScheduler` to control virtual time.",
24-
level = DeprecationLevel.WARNING
24+
level = DeprecationLevel.ERROR
2525
)
2626
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
2727
public interface DelayController {
@@ -111,7 +111,7 @@ public interface DelayController {
111111
*/
112112
@Deprecated(
113113
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
114-
level = DeprecationLevel.WARNING
114+
level = DeprecationLevel.ERROR
115115
)
116116
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
117117
public suspend fun pauseDispatcher(block: suspend () -> Unit)
@@ -124,7 +124,7 @@ public interface DelayController {
124124
*/
125125
@Deprecated(
126126
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
127-
level = DeprecationLevel.WARNING
127+
level = DeprecationLevel.ERROR
128128
)
129129
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
130130
public fun pauseDispatcher()
@@ -138,7 +138,7 @@ public interface DelayController {
138138
*/
139139
@Deprecated(
140140
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
141-
level = DeprecationLevel.WARNING
141+
level = DeprecationLevel.ERROR
142142
)
143143
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
144144
public fun resumeDispatcher()
@@ -151,7 +151,7 @@ internal interface SchedulerAsDelayController : DelayController {
151151
@Deprecated(
152152
"This property delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
153153
ReplaceWith("this.scheduler.currentTime"),
154-
level = DeprecationLevel.WARNING
154+
level = DeprecationLevel.ERROR
155155
)
156156
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
157157
override val currentTime: Long
@@ -162,7 +162,7 @@ internal interface SchedulerAsDelayController : DelayController {
162162
@Deprecated(
163163
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
164164
ReplaceWith("this.scheduler.apply { advanceTimeBy(delayTimeMillis); runCurrent() }"),
165-
level = DeprecationLevel.WARNING
165+
level = DeprecationLevel.ERROR
166166
)
167167
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
168168
override fun advanceTimeBy(delayTimeMillis: Long): Long {
@@ -176,7 +176,7 @@ internal interface SchedulerAsDelayController : DelayController {
176176
@Deprecated(
177177
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
178178
ReplaceWith("this.scheduler.advanceUntilIdle()"),
179-
level = DeprecationLevel.WARNING
179+
level = DeprecationLevel.ERROR
180180
)
181181
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
182182
override fun advanceUntilIdle(): Long {
@@ -189,7 +189,7 @@ internal interface SchedulerAsDelayController : DelayController {
189189
@Deprecated(
190190
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
191191
ReplaceWith("this.scheduler.runCurrent()"),
192-
level = DeprecationLevel.WARNING
192+
level = DeprecationLevel.ERROR
193193
)
194194
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
195195
override fun runCurrent(): Unit = scheduler.runCurrent()

kotlinx-coroutines-test/jvm/src/migration/TestBuildersDeprecated.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import kotlin.time.Duration.Companion.milliseconds
5656
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
5757
level = DeprecationLevel.WARNING
5858
)
59-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
59+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
6060
public fun runBlockingTest(
6161
context: CoroutineContext = EmptyCoroutineContext,
6262
testBody: suspend TestCoroutineScope.() -> Unit
@@ -77,7 +77,7 @@ public fun runBlockingTest(
7777
* A version of [runBlockingTest] that works with [TestScope].
7878
*/
7979
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
80-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
80+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
8181
public fun runBlockingTestOnTestScope(
8282
context: CoroutineContext = EmptyCoroutineContext,
8383
testBody: suspend TestScope.() -> Unit
@@ -126,15 +126,15 @@ public fun runBlockingTestOnTestScope(
126126
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
127127
level = DeprecationLevel.WARNING
128128
)
129-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
129+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
130130
public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
131131
runBlockingTest(coroutineContext, block)
132132

133133
/**
134134
* Convenience method for calling [runBlockingTestOnTestScope] on an existing [TestScope].
135135
*/
136136
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
137-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
137+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
138138
public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit =
139139
runBlockingTestOnTestScope(coroutineContext, block)
140140

@@ -152,7 +152,7 @@ public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit
152152
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
153153
level = DeprecationLevel.WARNING
154154
)
155-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
155+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
156156
public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
157157
runBlockingTest(this, block)
158158

@@ -161,7 +161,7 @@ public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineS
161161
*/
162162
@ExperimentalCoroutinesApi
163163
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.WARNING)
164-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
164+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
165165
public fun runTestWithLegacyScope(
166166
context: CoroutineContext = EmptyCoroutineContext,
167167
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
@@ -200,7 +200,7 @@ public fun runTestWithLegacyScope(
200200
*/
201201
@ExperimentalCoroutinesApi
202202
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.WARNING)
203-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
203+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
204204
public fun TestCoroutineScope.runTest(
205205
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
206206
block: suspend TestCoroutineScope.() -> Unit

kotlinx-coroutines-test/jvm/src/migration/TestCoroutineDispatcher.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import kotlin.coroutines.*
2424
@Deprecated("The execution order of `TestCoroutineDispatcher` can be confusing, and the mechanism of " +
2525
"pausing is typically misunderstood. Please use `StandardTestDispatcher` or `UnconfinedTestDispatcher` instead.",
2626
level = DeprecationLevel.WARNING)
27-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
27+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
2828
public class TestCoroutineDispatcher(public override val scheduler: TestCoroutineScheduler = TestCoroutineScheduler()):
2929
TestDispatcher(), Delay, SchedulerAsDelayController
3030
{
@@ -63,7 +63,7 @@ public class TestCoroutineDispatcher(public override val scheduler: TestCoroutin
6363
/** @suppress */
6464
@Deprecated(
6565
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
66-
level = DeprecationLevel.WARNING
66+
level = DeprecationLevel.ERROR
6767
)
6868
override suspend fun pauseDispatcher(block: suspend () -> Unit) {
6969
val previous = dispatchImmediately
@@ -78,7 +78,7 @@ public class TestCoroutineDispatcher(public override val scheduler: TestCoroutin
7878
/** @suppress */
7979
@Deprecated(
8080
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
81-
level = DeprecationLevel.WARNING
81+
level = DeprecationLevel.ERROR
8282
)
8383
override fun pauseDispatcher() {
8484
dispatchImmediately = false
@@ -87,7 +87,7 @@ public class TestCoroutineDispatcher(public override val scheduler: TestCoroutin
8787
/** @suppress */
8888
@Deprecated(
8989
"Please use a dispatcher that is paused by default, like `StandardTestDispatcher`.",
90-
level = DeprecationLevel.WARNING
90+
level = DeprecationLevel.ERROR
9191
)
9292
override fun resumeDispatcher() {
9393
dispatchImmediately = true

kotlinx-coroutines-test/jvm/src/migration/TestCoroutineExceptionHandler.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.coroutines.*
1616
"Consider whether the default mechanism of handling uncaught exceptions is sufficient. " +
1717
"If not, try writing your own `CoroutineExceptionHandler` and " +
1818
"please report your use case at https://github.com/Kotlin/kotlinx.coroutines/issues.",
19-
level = DeprecationLevel.WARNING
19+
level = DeprecationLevel.ERROR
2020
)
2121
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
2222
public interface UncaughtExceptionCaptor {
@@ -42,11 +42,11 @@ public interface UncaughtExceptionCaptor {
4242
/**
4343
* An exception handler that captures uncaught exceptions in tests.
4444
*/
45-
@Suppress("DEPRECATION")
45+
@Suppress("DEPRECATION_ERROR")
4646
@Deprecated(
4747
"Deprecated for removal without a replacement. " +
4848
"It may be to define one's own `CoroutineExceptionHandler` if you just need to handle '" +
49-
"uncaught exceptions without a special `TestCoroutineScope` integration.", level = DeprecationLevel.WARNING
49+
"uncaught exceptions without a special `TestCoroutineScope` integration.", level = DeprecationLevel.ERROR
5050
)
5151
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
5252
public class TestCoroutineExceptionHandler :

kotlinx-coroutines-test/jvm/src/migration/TestCoroutineScope.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4-
@file:Suppress("DEPRECATION")
4+
@file:Suppress("DEPRECATION_ERROR", "DEPRECATION")
55

66
package kotlinx.coroutines.test
77

@@ -22,7 +22,7 @@ import kotlin.coroutines.*
2222
"Please see the migration guide for details: " +
2323
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
2424
level = DeprecationLevel.WARNING)
25-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
25+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
2626
public interface TestCoroutineScope : CoroutineScope {
2727
/**
2828
* Called after the test completes.
@@ -45,7 +45,7 @@ public interface TestCoroutineScope : CoroutineScope {
4545
*/
4646
@ExperimentalCoroutinesApi
4747
@Deprecated("Please call `runTest`, which automatically performs the cleanup, instead of using this function.")
48-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
48+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
4949
public fun cleanupTestCoroutines()
5050

5151
/**
@@ -139,7 +139,7 @@ internal fun CoroutineContext.activeJobs(): Set<Job> {
139139
),
140140
level = DeprecationLevel.WARNING
141141
)
142-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
142+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
143143
public fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope {
144144
val scheduler = context[TestCoroutineScheduler] ?: TestCoroutineScheduler()
145145
return createTestCoroutineScope(TestCoroutineDispatcher(scheduler) + TestCoroutineExceptionHandler() + context)
@@ -181,7 +181,7 @@ public fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext)
181181
"Please use TestScope() construction instead, or just runTest(), without creating a scope.",
182182
level = DeprecationLevel.WARNING
183183
)
184-
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
184+
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
185185
public fun createTestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope {
186186
val ctxWithDispatcher = context.withDelaySkipping()
187187
var scope: TestCoroutineScopeImpl? = null
@@ -239,7 +239,7 @@ public val TestCoroutineScope.currentTime: Long
239239
"The name of this function is misleading: it not only advances the time, but also runs the tasks " +
240240
"scheduled *at* the ending moment.",
241241
ReplaceWith("this.testScheduler.apply { advanceTimeBy(delayTimeMillis); runCurrent() }"),
242-
DeprecationLevel.WARNING
242+
DeprecationLevel.ERROR
243243
)
244244
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
245245
public fun TestCoroutineScope.advanceTimeBy(delayTimeMillis: Long): Unit =
@@ -283,7 +283,7 @@ public fun TestCoroutineScope.runCurrent() {
283283
"(this.coroutineContext[ContinuationInterceptor]!! as DelayController).pauseDispatcher(block)",
284284
"kotlin.coroutines.ContinuationInterceptor"
285285
),
286-
DeprecationLevel.WARNING
286+
DeprecationLevel.ERROR
287287
)
288288
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
289289
public suspend fun TestCoroutineScope.pauseDispatcher(block: suspend () -> Unit) {
@@ -299,7 +299,7 @@ public suspend fun TestCoroutineScope.pauseDispatcher(block: suspend () -> Unit)
299299
"(this.coroutineContext[ContinuationInterceptor]!! as DelayController).pauseDispatcher()",
300300
"kotlin.coroutines.ContinuationInterceptor"
301301
),
302-
level = DeprecationLevel.WARNING
302+
level = DeprecationLevel.ERROR
303303
)
304304
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
305305
public fun TestCoroutineScope.pauseDispatcher() {
@@ -315,7 +315,7 @@ public fun TestCoroutineScope.pauseDispatcher() {
315315
"(this.coroutineContext[ContinuationInterceptor]!! as DelayController).resumeDispatcher()",
316316
"kotlin.coroutines.ContinuationInterceptor"
317317
),
318-
level = DeprecationLevel.WARNING
318+
level = DeprecationLevel.ERROR
319319
)
320320
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
321321
public fun TestCoroutineScope.resumeDispatcher() {
@@ -335,8 +335,9 @@ public fun TestCoroutineScope.resumeDispatcher() {
335335
"easily misused. It is only present for backward compatibility and will be removed in the subsequent " +
336336
"releases. If you need to check the list of exceptions, please consider creating your own " +
337337
"`CoroutineExceptionHandler`.",
338-
level = DeprecationLevel.WARNING
338+
level = DeprecationLevel.ERROR
339339
)
340+
// Since 1.6.0, ERROR in 1.7.0 and removed as experimental in 1.8.0
340341
public val TestCoroutineScope.uncaughtExceptions: List<Throwable>
341342
get() = (coroutineContext[CoroutineExceptionHandler] as? UncaughtExceptionCaptor)?.uncaughtExceptions
342343
?: emptyList()

kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kotlinx.coroutines.*
88
import kotlin.coroutines.*
99
import kotlin.test.*
1010

11-
@Suppress("DEPRECATION")
11+
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
1212
class TestBuildersTest {
1313

1414
@Test
@@ -129,4 +129,4 @@ class TestBuildersTest {
129129

130130
assertEquals(4, calls)
131131
}
132-
}
132+
}

kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kotlinx.atomicfu.*
88
import kotlinx.coroutines.*
99
import kotlin.test.*
1010

11-
@Suppress("DEPRECATION")
11+
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
1212
class TestCoroutineDispatcherOrderTest: OrderedExecutionTestBase() {
1313

1414
@Test
@@ -40,4 +40,4 @@ class TestCoroutineDispatcherOrderTest: OrderedExecutionTestBase() {
4040
scope.cleanupTestCoroutines()
4141
finish(9)
4242
}
43-
}
43+
}

kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.test
77
import kotlinx.coroutines.*
88
import kotlin.test.*
99

10-
@Suppress("DEPRECATION")
10+
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
1111
class TestCoroutineDispatcherTest {
1212
@Test
1313
fun whenDispatcherPaused_doesNotAutoProgressCurrent() {
@@ -74,4 +74,4 @@ class TestCoroutineDispatcherTest {
7474
assertFailsWith<UncompletedCoroutinesError> { subject.cleanupTestCoroutines() }
7575
}
7676

77-
}
77+
}

kotlinx-coroutines-test/jvm/test/migration/TestCoroutineExceptionHandlerTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package kotlinx.coroutines.test
66

77
import kotlin.test.*
88

9-
@Suppress("DEPRECATION")
9+
@Suppress("DEPRECATION_ERROR")
1010
class TestCoroutineExceptionHandlerTest {
1111
@Test
1212
fun whenExceptionsCaught_availableViaProperty() {
@@ -15,4 +15,4 @@ class TestCoroutineExceptionHandlerTest {
1515
subject.handleException(subject, expected)
1616
assertEquals(listOf(expected), subject.uncaughtExceptions)
1717
}
18-
}
18+
}

kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package kotlinx.coroutines.test
77
import kotlinx.coroutines.*
88
import kotlin.test.*
99

10-
@Suppress("DEPRECATION")
10+
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
1111
class TestRunBlockingTest {
1212

1313
@Test
@@ -437,4 +437,4 @@ class TestRunBlockingTest {
437437
}
438438
}
439439
}
440-
}
440+
}

0 commit comments

Comments
 (0)