Skip to content

Commit 92d67d2

Browse files
committed
Deleted old compat tests, made api dumps unversioned
1 parent 1a3d2bf commit 92d67d2

File tree

84 files changed

+6
-1133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+6
-1133
lines changed

krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/ApiTestContext.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.krpc.test.api
66

7-
import kotlinx.rpc.krpc.test.api.ApiVersioningTest.Companion.CURRENT_CLASS_DUMPS_DIR
8-
import kotlinx.rpc.krpc.test.api.ApiVersioningTest.Companion.LATEST_CLASS_DUMPS_DIR
7+
import kotlinx.rpc.krpc.test.api.ApiVersioningTest.Companion.CLASS_DUMPS_DIR
98
import kotlinx.rpc.krpc.test.api.util.StringGoldContent
109
import kotlinx.rpc.krpc.test.api.util.checkGold
1110
import kotlin.reflect.KClass
@@ -27,8 +26,8 @@ class ApiTestContext {
2726
sampled.add(clazz)
2827

2928
val log = checkGold(
30-
latestDir = LATEST_CLASS_DUMPS_DIR,
31-
currentDir = CURRENT_CLASS_DUMPS_DIR,
29+
latestDir = CLASS_DUMPS_DIR,
30+
currentDir = CLASS_DUMPS_DIR,
3231
filename = clazz.simpleName!!,
3332
content = StringGoldContent(currentContent),
3433
parseGoldFile = { StringGoldContent(it) },

krpc/krpc-test/src/jvmTest/kotlin/kotlinx/rpc/krpc/test/api/ApiVersioningTest.kt

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.krpc.test.api
66

7-
import kotlinx.coroutines.flow.toList
87
import kotlinx.rpc.krpc.internal.CancellationType
98
import kotlinx.rpc.krpc.internal.KrpcMessage
109
import kotlinx.rpc.krpc.internal.KrpcPlugin
1110
import kotlinx.rpc.krpc.internal.KrpcPluginKey
1211
import kotlinx.rpc.krpc.test.api.util.GoldUtils.NewLine
13-
import kotlinx.rpc.krpc.test.plainFlow
14-
import org.jetbrains.krpc.test.api.util.SamplingData
1512
import org.junit.Test
1613
import java.nio.file.Path
1714
import kotlin.io.path.Path
18-
import kotlin.io.path.isDirectory
19-
import kotlin.io.path.listDirectoryEntries
20-
import kotlin.io.path.name
21-
import kotlin.test.Ignore
22-
import kotlin.test.assertEquals
2315
import kotlin.test.fail
2416

2517
class ApiVersioningTest {
@@ -45,82 +37,10 @@ class ApiVersioningTest {
4537
testEnum<CancellationType>()
4638
}
4739

48-
@Test
49-
fun testEchoSampling() = wireSamplingTest("echo") {
50-
sample {
51-
val response = echo("Hello", SamplingData("data"))
52-
assertEquals(SamplingData("data"), response)
53-
}
54-
}
55-
56-
@Test
57-
@Ignore("Flow sampling tests are too unstable. Ignored until better fix")
58-
fun testClientStreamSampling() = wireSamplingTest("clientStream") {
59-
sample {
60-
val response = clientStream(plainFlow { it }).joinToString()
61-
val expected = List(5) { it }.joinToString()
62-
63-
assertEquals(expected, response)
64-
}
65-
}
66-
67-
@Test
68-
@Ignore("Flow sampling tests are too unstable. Ignored until better fix")
69-
fun testServerStreamSampling() = wireSamplingTest("serverStream") {
70-
sample {
71-
val response = serverFlow().toList().joinToString()
72-
val expected = List(5) { SamplingData("data") }.joinToString()
73-
74-
assertEquals(expected, response)
75-
}
76-
}
77-
78-
@Test
79-
fun testCallExceptionSampling() = wireSamplingTest("callException") {
80-
// ignore protobuf here, as it's hard to properly sample stacktrace
81-
// in Json we can just cut it out
82-
sample(SamplingFormat.Json) {
83-
try {
84-
callException()
85-
fail("Expected exception to be thrown")
86-
} catch (e: IllegalStateException) {
87-
assertEquals("Server exception", e.message)
88-
}
89-
}
90-
}
91-
9240
companion object {
93-
val LIBRARY_VERSION_DIR = System.getenv("LIBRARY_VERSION")?.versionToDirName()
94-
?: error("Expected LIBRARY_VERSION env variable")
41+
val CLASS_DUMPS_DIR: Path = Path("src/jvmTest/resources/class_dumps/")
9542

96-
val CURRENT_CLASS_DUMPS_DIR: Path = Path("src/jvmTest/resources/class_dumps/")
97-
.resolve(LIBRARY_VERSION_DIR)
98-
99-
val LATEST_CLASS_DUMPS_DIR: Path = Path("src/jvmTest/resources/class_dumps/")
100-
.latestVersionOrCurrent()
101-
102-
val WIRE_DUMPS_DIR: Path = Path("src/jvmTest/resources/wire_dumps/")
10343
val INDEXED_ENUM_DUMPS_DIR: Path = Path("src/jvmTest/resources/indexed_enum_dumps/")
104-
105-
private fun String.versionToDirName(): String {
106-
return replace('.', '_').replace('-', '_').substringBefore("-")
107-
}
108-
109-
fun Path.latestVersionOrCurrent(): Path {
110-
return listDirectoryEntries()
111-
.filter { it.isDirectory() }
112-
.sortedWith { a, b ->
113-
val aBeta = a.name.contains("beta")
114-
val bBeta = b.name.contains("beta")
115-
when {
116-
aBeta && bBeta -> a.compareTo(b)
117-
aBeta -> -1
118-
bBeta -> 1
119-
else -> a.name.substringBefore("-").compareTo(b.name.substringBefore("-"))
120-
}
121-
}.lastOrNull()
122-
?: resolve(LIBRARY_VERSION_DIR)
123-
}
12444
}
12545
}
12646

0 commit comments

Comments
 (0)