Skip to content

Commit 54617b7

Browse files
committed
Fixed JDK16 tests & links in guide
Fixes #625
1 parent 8339511 commit 54617b7

14 files changed

+51
-49
lines changed

core/kotlinx-coroutines-core/build.gradle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,18 @@ task jdk16Test(type: Test, dependsOn: [testClasses, checkJdk16]) {
4646
executable = "$System.env.JDK_16/bin/java"
4747
exclude '**/*LinearizabilityTest.*'
4848
exclude '**/*LFTest.*'
49-
exclude '**/exceptions/.*'
49+
exclude '**/exceptions/**'
50+
exclude '**/ExceptionsGuideTest.*'
5051
}
5152

52-
// Always run those tests
53-
task moreTest(dependsOn: [lockFreedomTest])
54-
5553
// Run these tests only during nightly stress test
56-
task extraTest(dependsOn: [jdk16Test])
54+
jdk16Test.onlyIf { project.properties['stressTest'] != null }
5755

56+
// Always run those tests
57+
task moreTest(dependsOn: [lockFreedomTest, jdk16Test])
5858

5959
build.dependsOn moreTest
6060

61-
extraTest.onlyIf { project.properties['stressTest'] != null }
62-
6361
task testsJar(type: Jar, dependsOn: testClasses) {
6462
classifier = 'tests'
6563
from sourceSets.test.output

core/kotlinx-coroutines-core/test/exceptions/CoroutineExceptionHandlerJvmTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CoroutineExceptionHandlerJvmTest : TestBase() {
3535
job.join()
3636
assertTrue(caughtException is RuntimeException)
3737
assertTrue(caughtException.cause is AssertionError)
38-
assertTrue(caughtException.suppressed()[0] is TestException)
38+
assertTrue(caughtException.suppressed[0] is TestException)
3939

4040
finish(3)
4141
}

core/kotlinx-coroutines-core/test/exceptions/Exceptions.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ import kotlin.test.*
1414
* Proxy for [Throwable.getSuppressed] for tests, which are compiled for both JDK 1.6 and JDK 1.8,
1515
* but run only under JDK 1.8
1616
*/
17-
fun Throwable.suppressed(): Array<Throwable> {
17+
@Suppress("ConflictingExtensionProperty")
18+
val Throwable.suppressed: Array<Throwable> get() {
1819
val method = this::class.java.getMethod("getSuppressed") ?: error("This test can only be run using JDK 1.7")
1920
@Suppress("UNCHECKED_CAST")
2021
return method.invoke(this) as Array<Throwable>
2122
}
2223

2324
internal inline fun <reified T : Throwable> checkException(exception: Throwable): Boolean {
2425
assertTrue(exception is T)
25-
assertTrue(exception.suppressed().isEmpty())
26+
assertTrue(exception.suppressed.isEmpty())
2627
assertNull(exception.cause)
2728
return true
2829
}

core/kotlinx-coroutines-core/test/exceptions/JobBasicCancellationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ class JobBasicCancellationTest : TestBase() {
152152
val cause = deferred.getCancellationException().cause!!
153153
assertTrue(cause is IndexOutOfBoundsException)
154154
assertNull(cause.cause)
155-
assertTrue(cause.suppressed().isEmpty())
155+
assertTrue(cause.suppressed.isEmpty())
156156
}
157157
}

core/kotlinx-coroutines-core/test/exceptions/JobExceptionHandlingTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class JobExceptionHandlingTest : TestBase() {
4848
deferred.await()
4949
expectUnreached()
5050
} catch (e: IOException) {
51-
assertTrue(e.suppressed().isEmpty())
51+
assertTrue(e.suppressed.isEmpty())
5252
finish(3)
5353
}
5454
}
@@ -68,7 +68,7 @@ class JobExceptionHandlingTest : TestBase() {
6868
deferred.await()
6969
expectUnreached()
7070
} catch (e: IOException) {
71-
assertTrue(e.suppressed().isEmpty())
71+
assertTrue(e.suppressed.isEmpty())
7272
finish(3)
7373
}
7474
}
@@ -122,7 +122,7 @@ class JobExceptionHandlingTest : TestBase() {
122122
}
123123

124124
assertTrue(exception is ArithmeticException)
125-
val suppressed = exception.suppressed()
125+
val suppressed = exception.suppressed
126126
assertEquals(2, suppressed.size)
127127
checkException<NullPointerException>(suppressed[0])
128128
checkException<IOException>(suppressed[1])
@@ -225,7 +225,7 @@ class JobExceptionHandlingTest : TestBase() {
225225

226226
assertTrue(exception is IOException)
227227
assertNull(exception.cause)
228-
val suppressed = exception.suppressed()
228+
val suppressed = exception.suppressed
229229
assertEquals(1, suppressed.size)
230230
checkException<ArithmeticException>(suppressed[0])
231231
}
@@ -266,7 +266,7 @@ class JobExceptionHandlingTest : TestBase() {
266266
}
267267

268268
assertTrue(exception is ArithmeticException)
269-
val suppressed = exception.suppressed()
269+
val suppressed = exception.suppressed
270270
assertEquals(2, suppressed.size)
271271
assertTrue(suppressed[0] is IOException)
272272
assertTrue(suppressed[1] is IllegalArgumentException)
@@ -303,7 +303,7 @@ class JobExceptionHandlingTest : TestBase() {
303303
}
304304

305305
assertTrue(exception is AssertionError)
306-
val suppressed = exception.suppressed()
306+
val suppressed = exception.suppressed
307307
assertEquals(2, suppressed.size)
308308
assertTrue(suppressed[0] is IOException)
309309
assertTrue(suppressed[1] is IllegalArgumentException)

core/kotlinx-coroutines-core/test/exceptions/JobExceptionsStressTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class JobExceptionsStressTest : TestBase() {
5353
TestException2::class,
5454
TestException3::class
5555
)
56-
val suppressedExceptions = exception.suppressed().toSet()
56+
val suppressedExceptions = exception.suppressed.toSet()
5757
assertTrue(classes.remove(exception::class),
5858
"Failed to remove ${exception::class} from $suppressedExceptions"
5959
)

core/kotlinx-coroutines-core/test/exceptions/JobNestedExceptionsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class JobNestedExceptionsTest : TestBase() {
8181
finish(5)
8282
}
8383
assertTrue(exception is ArithmeticException, "Found $exception")
84-
checkException<IOException>(exception.suppressed()[0])
84+
checkException<IOException>(exception.suppressed[0])
8585
}
8686

8787
@Test
@@ -111,10 +111,10 @@ class JobNestedExceptionsTest : TestBase() {
111111
assertEquals(1, exceptions.size, "Found $exceptions")
112112
val exception = exceptions[0]
113113
assertTrue(exception is ArithmeticException, "Exception is $exception")
114-
val suppressed = exception.suppressed()
114+
val suppressed = exception.suppressed
115115
val ioe = suppressed[0]
116116
assertTrue(ioe is IOException)
117-
checkException<NullPointerException>(ioe.suppressed()[0])
117+
checkException<NullPointerException>(ioe.suppressed[0])
118118
checkCycles(exception)
119119
}
120120
}

core/kotlinx-coroutines-core/test/exceptions/ProduceExceptionsTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ProduceExceptionsTest : TestBase() {
3333

3434
@Test
3535
fun testSuppressedExceptionUncaught() =
36-
runTest(unhandled = listOf({ e -> e is TestException && e.suppressed()[0] is TestException2 })) {
36+
runTest(unhandled = listOf({ e -> e is TestException && e.suppressed[0] is TestException2 })) {
3737
val produce = produce<Int>(Job()) {
3838
launch(start = CoroutineStart.ATOMIC) {
3939
throw TestException()
@@ -66,7 +66,7 @@ class ProduceExceptionsTest : TestBase() {
6666
produce.receive()
6767
expectUnreached()
6868
} catch (e: TestException) {
69-
assertTrue(e.suppressed()[0] is TestException2)
69+
assertTrue(e.suppressed[0] is TestException2)
7070
}
7171
}
7272

@@ -89,7 +89,7 @@ class ProduceExceptionsTest : TestBase() {
8989
try {
9090
channel.receive()
9191
} catch (e: ClosedReceiveChannelException) {
92-
assertTrue(e.suppressed().isEmpty())
92+
assertTrue(e.suppressed.isEmpty())
9393
finish(4)
9494
}
9595
}
@@ -114,7 +114,7 @@ class ProduceExceptionsTest : TestBase() {
114114
try {
115115
channel.receive()
116116
} catch (e: TestException) {
117-
assertTrue(e.suppressed().isEmpty())
117+
assertTrue(e.suppressed.isEmpty())
118118
finish(4)
119119
}
120120
}
@@ -138,7 +138,7 @@ class ProduceExceptionsTest : TestBase() {
138138
try {
139139
channel.receive()
140140
} catch (e: CancellationException) {
141-
assertTrue(e.suppressed().isEmpty())
141+
assertTrue(e.suppressed.isEmpty())
142142
finish(4)
143143
}
144144
}

core/kotlinx-coroutines-core/test/exceptions/SuppresionTests.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SuppresionTests : TestBase() {
2626
try {
2727
deferred.await()
2828
} catch (e: IOException) {
29-
checkException<ArithmeticException>(e.suppressed()[0])
29+
checkException<ArithmeticException>(e.suppressed[0])
3030
finish(3)
3131
}
3232
}
@@ -42,7 +42,7 @@ class SuppresionTests : TestBase() {
4242

4343
override fun onCancellation(cause: Throwable?) {
4444
assertTrue(cause is ArithmeticException)
45-
assertTrue(cause!!.suppressed().isEmpty())
45+
assertTrue(cause!!.suppressed.isEmpty())
4646
expect(5)
4747
}
4848

@@ -52,20 +52,20 @@ class SuppresionTests : TestBase() {
5252

5353
override fun onCompletedExceptionally(exception: Throwable) {
5454
assertTrue(exception is ArithmeticException)
55-
checkException<IOException>(exception.suppressed()[0])
55+
checkException<IOException>(exception.suppressed[0])
5656
expect(9)
5757
}
5858
}
5959

6060
coroutine.invokeOnCompletion(onCancelling = true) {
6161
assertTrue(it is ArithmeticException)
62-
assertTrue(it!!.suppressed().isEmpty())
62+
assertTrue(it!!.suppressed.isEmpty())
6363
expect(6)
6464
}
6565

6666
coroutine.invokeOnCompletion {
6767
assertTrue(it is ArithmeticException)
68-
checkException<IOException>(it!!.suppressed()[0])
68+
checkException<IOException>(it!!.suppressed[0])
6969
expect(8)
7070
}
7171

core/kotlinx-coroutines-core/test/WithContextCancellationStressTest.kt renamed to core/kotlinx-coroutines-core/test/exceptions/WithContextCancellationStressTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
package kotlinx.coroutines.experimental
5+
package kotlinx.coroutines.experimental.exceptions
66

7-
import kotlinx.coroutines.experimental.exceptions.*
7+
import kotlinx.coroutines.experimental.*
88
import org.junit.*
99
import org.junit.Test
1010
import java.io.*
@@ -92,7 +92,7 @@ class WithContextCancellationStressTest : TestBase() {
9292
aeException: Boolean = false,
9393
aioobException: Boolean = false
9494
) {
95-
val suppressed = suppressed()
95+
val suppressed: Array<Throwable> = suppressed
9696

9797
try {
9898
if (ioException) {

0 commit comments

Comments
 (0)