Skip to content

Commit 629f78f

Browse files
committed
Local TestSupport removed in favor of xemantic-kotlin-test lib providing stable file reading support in multiplatform tests
1 parent a73e686 commit 629f78f

File tree

9 files changed

+23
-134
lines changed

9 files changed

+23
-134
lines changed

build.gradle.kts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
44
import org.gradle.api.tasks.testing.logging.TestLogEvent
5+
import org.gradle.kotlin.dsl.withType
56
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
67
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
78
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
89
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
910
import org.jetbrains.kotlin.gradle.swiftexport.ExperimentalSwiftExportDsl
11+
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
1012
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
1113
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
1214

@@ -44,6 +46,21 @@ println("""
4446
"""
4547
)
4648

49+
val gradleRootDir: String = rootDir.absolutePath
50+
51+
tasks.withType<KotlinJvmTest>().configureEach {
52+
environment("GRADLE_ROOT_DIR", gradleRootDir)
53+
}
54+
55+
tasks.withType<KotlinJsTest>().configureEach {
56+
environment("GRADLE_ROOT_DIR", gradleRootDir)
57+
}
58+
59+
tasks.withType<KotlinNativeTest>().configureEach {
60+
environment("GRADLE_ROOT_DIR", gradleRootDir)
61+
environment("SIMCTL_CHILD_GRADLE_ROOT_DIR", gradleRootDir)
62+
}
63+
4764
repositories {
4865
mavenCentral()
4966
}
@@ -301,12 +318,3 @@ if (isReleaseBuild) {
301318
}
302319

303320
}
304-
305-
tasks.withType<KotlinJvmTest>().configureEach {
306-
environment("GRADLE_PROJECT_ROOT", rootDir)
307-
}
308-
309-
tasks.withType<KotlinNativeTest>().configureEach {
310-
environment("SIMCTL_CHILD_GRADLE_PROJECT_ROOT", rootDir)
311-
environment("GRADLE_PROJECT_ROOT", rootDir)
312-
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ javaTarget = "17"
55
kotlin = "2.1.0"
66
kotlinxIo = "0.6.0"
77

8-
xemanticKotlinTest = "1.0"
8+
xemanticKotlinTest = "1.1"
99

1010
versionsPlugin = "0.51.0"
1111
dokkaPlugin = "2.0.0"

src/commonTest/kotlin/MediaTypeTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import com.xemantic.ai.file.magic.test.MINIMAL_JPEG
2121
import com.xemantic.ai.file.magic.test.MINIMAL_PDF
2222
import com.xemantic.ai.file.magic.test.MINIMAL_PNG
2323
import com.xemantic.ai.file.magic.test.MINIMAL_WEBP
24-
import com.xemantic.ai.file.magic.test.isBrowserTest
2524
import com.xemantic.ai.file.magic.test.testDataDir
2625
import com.xemantic.kotlin.test.assert
26+
import com.xemantic.kotlin.test.isBrowserPlatform
2727
import kotlinx.io.files.Path
2828
import kotlin.test.Test
2929

@@ -42,7 +42,7 @@ class MediaTypeTest {
4242

4343
@Test
4444
fun `Should detect MediaTypes of Paths`() {
45-
if (isBrowserTest) return // we don't have file access in the browser, but we do have with node.js
45+
if (isBrowserPlatform) return // we don't have file access in the browser, but we do have with node.js
4646
assert(Path(testDataDir, "minimal.gif").detectMediaType() == MediaType.GIF)
4747
assert(Path(testDataDir, "minimal.jpeg").detectMediaType() == MediaType.JPEG)
4848
assert(Path(testDataDir, "minimal.pdf").detectMediaType() == MediaType.PDF)
@@ -52,7 +52,7 @@ class MediaTypeTest {
5252

5353
@Test
5454
fun `Should not detect MediaTypes of a Path with empty file`() {
55-
if (isBrowserTest) return // we don't have file access in the browser, but we do have with node.js
55+
if (isBrowserPlatform) return // we don't have file access in the browser, but we do have with node.js
5656
assert(Path(testDataDir, "zero.txt").detectMediaType() == null)
5757
}
5858

src/commonTest/kotlin/test/TestSupport.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package com.xemantic.ai.file.magic.test
1818

19+
import com.xemantic.kotlin.test.gradleRootDir
1920
import kotlinx.io.files.Path
2021

21-
val testDataDir: Path = Path(gradleProjectRoot, "test-data")
22-
23-
expect val gradleProjectRoot: String
24-
25-
expect val isBrowserTest: Boolean
22+
val testDataDir: Path = Path(gradleRootDir, "test-data")

src/jsTest/kotlin/JsTestSupport.kt

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/jvmTest/kotlin/JvmTestSupport.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/nativeTest/kotlin/NativeTestSupport.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/wasmJsTest/kotlin/WasmJsTestSupport.kt

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/wasmWasiTest/kotlin/WasmWasiTestSupport.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)