Skip to content

Commit

Permalink
Increase the deprecation levels for the old test framework API (#4198)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb authored Aug 12, 2024
1 parent 5c8e650 commit f0bdf00
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 679 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ suspend fun main() = coroutineScope {
* Integration with `Window` via [Window.asCoroutineDispatcher], etc.
* [test](kotlinx-coroutines-test/README.md) — test utilities for coroutines:
* [Dispatchers.setMain] to override [Dispatchers.Main] in tests;
* [TestCoroutineScope] to test suspending functions and coroutines.
* [runTest] and [TestScope] to test suspending functions and coroutines.
* [debug](kotlinx-coroutines-debug/README.md) — debug utilities for coroutines:
* [DebugProbes] API to probe, keep track of, print and dump active coroutines;
* [CoroutinesTimeout] test rule to automatically dump coroutines on test timeout.
Expand Down Expand Up @@ -240,7 +240,8 @@ See [Contributing Guidelines](CONTRIBUTING.md).
<!--- INDEX kotlinx.coroutines.test -->

[Dispatchers.setMain]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/set-main.html
[TestCoroutineScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scope/index.html
[runTest]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-test.html
[TestScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-scope/index.html

<!--- MODULE kotlinx-coroutines-debug -->
<!--- INDEX kotlinx.coroutines.debug -->
Expand Down
42 changes: 5 additions & 37 deletions kotlinx-coroutines-test/api/kotlinx-coroutines-test.api
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
public abstract interface class kotlinx/coroutines/test/DelayController {
public abstract fun advanceTimeBy (J)J
public abstract fun advanceUntilIdle ()J
public abstract fun cleanupTestCoroutines ()V
public abstract fun getCurrentTime ()J
public abstract fun pauseDispatcher ()V
public abstract fun pauseDispatcher (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun resumeDispatcher ()V
public abstract fun runCurrent ()V
}

public final class kotlinx/coroutines/test/TestBuildersKt {
public static final fun runBlockingTest (Lkotlin/coroutines/CoroutineContext;Lkotlin/jvm/functions/Function2;)V
public static final fun runBlockingTest (Lkotlinx/coroutines/test/TestCoroutineDispatcher;Lkotlin/jvm/functions/Function2;)V
Expand All @@ -31,21 +20,17 @@ public final class kotlinx/coroutines/test/TestBuildersKt {
public static synthetic fun runTestWithLegacyScope$default (Lkotlin/coroutines/CoroutineContext;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
}

public final class kotlinx/coroutines/test/TestCoroutineDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay, kotlinx/coroutines/test/SchedulerAsDelayController {
public final class kotlinx/coroutines/test/TestCoroutineDispatcher : kotlinx/coroutines/test/TestDispatcher, kotlinx/coroutines/Delay {
public fun <init> ()V
public fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;)V
public synthetic fun <init> (Lkotlinx/coroutines/test/TestCoroutineScheduler;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun advanceTimeBy (J)J
public fun advanceUntilIdle ()J
public fun cleanupTestCoroutines ()V
public final fun advanceUntilIdle ()J
public final fun cleanupTestCoroutines ()V
public fun dispatch (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
public fun dispatchYield (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Runnable;)V
public fun getCurrentTime ()J
public final fun getCurrentTime ()J
public fun getScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
public fun pauseDispatcher ()V
public fun pauseDispatcher (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun resumeDispatcher ()V
public fun runCurrent ()V
public final fun runCurrent ()V
public fun toString ()Ljava/lang/String;
}

Expand All @@ -56,13 +41,6 @@ public final class kotlinx/coroutines/test/TestCoroutineDispatchersKt {
public static synthetic fun UnconfinedTestDispatcher$default (Lkotlinx/coroutines/test/TestCoroutineScheduler;Ljava/lang/String;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestDispatcher;
}

public final class kotlinx/coroutines/test/TestCoroutineExceptionHandler : kotlin/coroutines/AbstractCoroutineContextElement, kotlinx/coroutines/CoroutineExceptionHandler, kotlinx/coroutines/test/UncaughtExceptionCaptor {
public fun <init> ()V
public fun cleanupTestCoroutines ()V
public fun getUncaughtExceptions ()Ljava/util/List;
public fun handleException (Lkotlin/coroutines/CoroutineContext;Ljava/lang/Throwable;)V
}

public final class kotlinx/coroutines/test/TestCoroutineScheduler : kotlin/coroutines/AbstractCoroutineContextElement, kotlin/coroutines/CoroutineContext$Element {
public static final field Key Lkotlinx/coroutines/test/TestCoroutineScheduler$Key;
public fun <init> ()V
Expand All @@ -85,15 +63,10 @@ public abstract interface class kotlinx/coroutines/test/TestCoroutineScope : kot
public final class kotlinx/coroutines/test/TestCoroutineScopeKt {
public static final fun TestCoroutineScope (Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/test/TestCoroutineScope;
public static synthetic fun TestCoroutineScope$default (Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestCoroutineScope;
public static final fun advanceTimeBy (Lkotlinx/coroutines/test/TestCoroutineScope;J)V
public static final fun advanceUntilIdle (Lkotlinx/coroutines/test/TestCoroutineScope;)V
public static final fun createTestCoroutineScope (Lkotlin/coroutines/CoroutineContext;)Lkotlinx/coroutines/test/TestCoroutineScope;
public static synthetic fun createTestCoroutineScope$default (Lkotlin/coroutines/CoroutineContext;ILjava/lang/Object;)Lkotlinx/coroutines/test/TestCoroutineScope;
public static final fun getCurrentTime (Lkotlinx/coroutines/test/TestCoroutineScope;)J
public static final fun getUncaughtExceptions (Lkotlinx/coroutines/test/TestCoroutineScope;)Ljava/util/List;
public static final fun pauseDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;)V
public static final fun pauseDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun resumeDispatcher (Lkotlinx/coroutines/test/TestCoroutineScope;)V
public static final fun runCurrent (Lkotlinx/coroutines/test/TestCoroutineScope;)V
}

Expand Down Expand Up @@ -128,8 +101,3 @@ public final class kotlinx/coroutines/test/TestScopeKt {
public static final fun setCatchNonTestRelatedExceptions (Z)V
}

public abstract interface class kotlinx/coroutines/test/UncaughtExceptionCaptor {
public abstract fun cleanupTestCoroutines ()V
public abstract fun getUncaughtExceptions ()Ljava/util/List;
}

206 changes: 0 additions & 206 deletions kotlinx-coroutines-test/jvm/src/migration/DelayController.kt

This file was deleted.

30 changes: 15 additions & 15 deletions kotlinx-coroutines-test/jvm/src/migration/TestBuildersDeprecated.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
@file:JvmName("TestBuildersKt")
@file:JvmMultifileClass

Expand Down Expand Up @@ -51,9 +51,9 @@ import kotlin.time.Duration.Companion.milliseconds
"Use `runTest` instead to support completing from other dispatchers. " +
"Please see the migration guide for details: " +
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun runBlockingTest(
context: CoroutineContext = EmptyCoroutineContext,
testBody: suspend TestCoroutineScope.() -> Unit
Expand All @@ -73,8 +73,8 @@ public fun runBlockingTest(
/**
* A version of [runBlockingTest] that works with [TestScope].
*/
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.WARNING)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
@Deprecated("Use `runTest` instead to support completing from other dispatchers.", level = DeprecationLevel.ERROR)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun runBlockingTestOnTestScope(
context: CoroutineContext = EmptyCoroutineContext,
testBody: suspend TestScope.() -> Unit
Expand Down Expand Up @@ -121,17 +121,17 @@ public fun runBlockingTestOnTestScope(
"Use `runTest` instead to support completing from other dispatchers. " +
"Please see the migration guide for details: " +
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun TestCoroutineScope.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
runBlockingTest(coroutineContext, block)

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

Expand All @@ -147,18 +147,18 @@ public fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit): Unit
"Use `runTest` instead to support completing from other dispatchers. " +
"Please see the migration guide for details: " +
"https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun TestCoroutineDispatcher.runBlockingTest(block: suspend TestCoroutineScope.() -> Unit): Unit =
runBlockingTest(this, block)

/**
* This is an overload of [runTest] that works with [TestCoroutineScope].
*/
@ExperimentalCoroutinesApi
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.WARNING)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
@Deprecated("Use `runTest` instead.", level = DeprecationLevel.ERROR)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun runTestWithLegacyScope(
context: CoroutineContext = EmptyCoroutineContext,
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
Expand Down Expand Up @@ -196,8 +196,8 @@ public fun runTestWithLegacyScope(
* immediately from the test body. See the docs for [TestResult] for details.
*/
@ExperimentalCoroutinesApi
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.WARNING)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.8.0 and removed as experimental in 1.9.0
@Deprecated("Use `TestScope.runTest` instead.", level = DeprecationLevel.ERROR)
// Since 1.6.0, kept as warning in 1.7.0, ERROR in 1.9.0 and removed as experimental later
public fun TestCoroutineScope.runTest(
dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS,
block: suspend TestCoroutineScope.() -> Unit
Expand Down
Loading

0 comments on commit f0bdf00

Please sign in to comment.