Skip to content

Commit c45f5fa

Browse files
committed
IO: Use TestBase in all tests and fix leaking threads in tests
1 parent f29203c commit c45f5fa

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/ContentByteBufferTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package kotlinx.coroutines.experimental.io
22

3-
import kotlinx.coroutines.experimental.runBlocking
3+
import kotlinx.coroutines.experimental.*
44
import org.junit.Test
55
import java.util.*
66
import kotlin.test.assertEquals
77
import kotlin.test.assertFalse
88
import kotlin.test.assertTrue
99

10-
class ContentByteBufferTest {
10+
class ContentByteBufferTest : TestBase() {
1111
@Test
1212
fun testEmptyContent() = runBlocking {
1313
val ch = ByteReadChannel(ByteArray(0))

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/JavaIOTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.io.*
88
import java.nio.channels.*
99
import kotlin.test.*
1010

11-
class JavaIOTest {
11+
class JavaIOTest : TestBase() {
1212
private val channel = ByteChannel()
1313

1414
@Test
@@ -177,6 +177,8 @@ class JavaIOTest {
177177
for (i in 1..numberOfLines) {
178178
assertEquals("OK $i", channel2.readUTF8Line())
179179
}
180+
181+
exec.close()
180182
}
181183

182184
@Test
@@ -203,5 +205,6 @@ class JavaIOTest {
203205

204206
pipe.source().close()
205207
pipe.sink().close()
208+
exec.close()
206209
}
207210
}

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/PooledBufferTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package kotlinx.coroutines.experimental.io
22

3+
import kotlinx.coroutines.experimental.*
34
import kotlinx.coroutines.experimental.io.internal.ReadWriteBufferState
4-
import kotlinx.coroutines.experimental.runBlocking
55
import kotlinx.io.pool.*
66
import org.junit.After
77
import org.junit.Test
@@ -12,7 +12,7 @@ import kotlin.test.assertEquals
1212
import kotlin.test.assertTrue
1313
import kotlin.test.fail
1414

15-
class PooledBufferTest {
15+
class PooledBufferTest : TestBase() {
1616
private val allocated = CopyOnWriteArrayList<ByteBuffer>()
1717

1818
private inner class TestPool : ObjectPool<ReadWriteBufferState.Initial> {

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/StateMachineChecker.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package kotlinx.coroutines.experimental.io
22

3+
import kotlinx.coroutines.experimental.*
34
import org.objectweb.asm.*
45
import java.io.*
56

6-
class StateMachineChecker {
7+
class StateMachineChecker : TestBase() {
78
private interface Filter {
89
fun nonSuspend(className: String, methodName: String): Boolean
910
fun suspend(className: String, methodName: String, hasStateMachine: Boolean): Boolean

core/kotlinx-coroutines-io/src/test/kotlin/kotlinx/coroutines/experimental/io/StringsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlin.test.assertNotEquals
1111
import kotlin.test.assertNull
1212
import kotlin.test.fail
1313

14-
class StringsTest {
14+
class StringsTest : TestBase() {
1515
@get:Rule
1616
val timeout = Timeout(10, TimeUnit.SECONDS)
1717

0 commit comments

Comments
 (0)