Skip to content

Commit 8fa07b5

Browse files
ndkovalelizarov
authored andcommitted
Make isStressTest and the related properties top-level
1 parent 216828a commit 8fa07b5

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

kotlinx-coroutines-core/common/test/TestBase.common.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import kotlinx.coroutines.flow.*
1010
import kotlin.coroutines.*
1111
import kotlin.test.*
1212

13-
public expect open class TestBase constructor() {
14-
public val isStressTest: Boolean
15-
public val stressTestMultiplier: Int
13+
public expect val isStressTest: Boolean
14+
public expect val stressTestMultiplier: Int
1615

16+
public expect open class TestBase constructor() {
1717
public fun error(message: Any, cause: Throwable? = null): Nothing
1818
public fun expect(index: Int)
1919
public fun expectUnreached()

kotlinx-coroutines-core/js/test/TestBase.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ package kotlinx.coroutines
66

77
import kotlin.js.*
88

9-
public actual open class TestBase actual constructor() {
10-
public actual val isStressTest: Boolean = false
11-
public actual val stressTestMultiplier: Int = 1
9+
public actual val isStressTest: Boolean = false
10+
public actual val stressTestMultiplier: Int = 1
1211

12+
public actual open class TestBase actual constructor() {
1313
private var actionIndex = 0
1414
private var finished = false
1515
private var error: Throwable? = null

kotlinx-coroutines-core/jvm/test/TestBase.kt

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ import kotlin.test.*
1414

1515
private val VERBOSE = systemProp("test.verbose", false)
1616

17+
/**
18+
* Is `true` when running in a nightly stress test mode.
19+
*/
20+
public actual val isStressTest = System.getProperty("stressTest")?.toBoolean() ?: false
21+
22+
public val stressTestMultiplierSqrt = if (isStressTest) 5 else 1
23+
24+
/**
25+
* Multiply various constants in stress tests by this factor, so that they run longer during nightly stress test.
26+
*/
27+
public actual val stressTestMultiplier = stressTestMultiplierSqrt * stressTestMultiplierSqrt
28+
1729
/**
1830
* Base class for tests, so that tests for predictable scheduling of actions in multiple coroutines sharing a single
1931
* thread can be written. Use it like this:
@@ -34,18 +46,6 @@ private val VERBOSE = systemProp("test.verbose", false)
3446
* ```
3547
*/
3648
public actual open class TestBase actual constructor() {
37-
/**
38-
* Is `true` when running in a nightly stress test mode.
39-
*/
40-
public actual val isStressTest = System.getProperty("stressTest")?.toBoolean() ?: false
41-
42-
public val stressTestMultiplierSqrt = if (isStressTest) 5 else 1
43-
44-
/**
45-
* Multiply various constants in stress tests by this factor, so that they run longer during nightly stress test.
46-
*/
47-
public actual val stressTestMultiplier = stressTestMultiplierSqrt * stressTestMultiplierSqrt
48-
4949
private var actionIndex = AtomicInteger()
5050
private var finished = AtomicBoolean()
5151
private var error = AtomicReference<Throwable>()

kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListAtomicLFStressTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package kotlinx.coroutines.internal
66

77
import kotlinx.atomicfu.LockFreedomTestEnvironment
8-
import kotlinx.coroutines.TestBase
8+
import kotlinx.coroutines.stressTestMultiplier
99
import org.junit.Assert.*
1010
import org.junit.Test
1111
import java.util.*
@@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicReference
1616
* This stress test has 4 threads adding randomly to the list and them immediately undoing
1717
* this addition by remove, and 4 threads trying to remove nodes from two lists simultaneously (atomically).
1818
*/
19-
class LockFreeLinkedListAtomicLFStressTest : TestBase() {
19+
class LockFreeLinkedListAtomicLFStressTest {
2020
private val env = LockFreedomTestEnvironment("LockFreeLinkedListAtomicLFStressTest")
2121

2222
data class IntNode(val i: Int) : LockFreeLinkedListNode()

kotlinx-coroutines-core/jvm/test/internal/SegmentQueueTest.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package kotlinx.coroutines.internal
22

3-
import kotlinx.coroutines.TestBase
3+
import kotlinx.coroutines.stressTestMultiplier
44
import org.junit.Test
55
import java.util.*
66
import java.util.concurrent.CyclicBarrier
@@ -9,12 +9,11 @@ import kotlin.concurrent.thread
99
import kotlin.random.Random
1010
import kotlin.test.assertEquals
1111

12-
class SegmentQueueTest : TestBase() {
13-
12+
class SegmentQueueTest {
1413
@Test
1514
fun simpleTest() {
1615
val q = SegmentBasedQueue<Int>()
17-
assertEquals( 1, q.numberOfSegments)
16+
assertEquals(1, q.numberOfSegments)
1817
assertEquals(null, q.dequeue())
1918
q.enqueue(1)
2019
assertEquals(1, q.numberOfSegments)

kotlinx-coroutines-core/native/test/TestBase.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
package kotlinx.coroutines
66

7-
public actual open class TestBase actual constructor() {
8-
public actual val isStressTest: Boolean = false
9-
public actual val stressTestMultiplier: Int = 1
7+
public actual val isStressTest: Boolean = false
8+
public actual val stressTestMultiplier: Int = 1
109

10+
public actual open class TestBase actual constructor() {
1111
private var actionIndex = 0
1212
private var finished = false
1313
private var error: Throwable? = null

0 commit comments

Comments
 (0)