Skip to content

Commit c7d849c

Browse files
committed
Update smoke tests
1 parent 3293f42 commit c7d849c

File tree

10 files changed

+233
-26
lines changed

10 files changed

+233
-26
lines changed

core/build.gradle.kts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
44
*/
55

6-
import org.gradle.internal.os.OperatingSystem
7-
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
8-
96
plugins {
107
id("kotlinx-io-multiplatform")
118
id("kotlinx-io-publish")
@@ -31,18 +28,6 @@ kotlin {
3128
}
3229
}
3330
}
34-
@OptIn(ExperimentalWasmDsl::class)
35-
wasmWasi {
36-
nodejs {
37-
testTask {
38-
// fd_readdir is unsupported on Windows:
39-
// https://github.com/nodejs/node/blob/6f4d6011ea1b448cf21f5d363c44e4a4c56ca34c/deps/uvwasi/src/uvwasi.c#L19
40-
if (OperatingSystem.current().isWindows) {
41-
filter.setExcludePatterns("*SmokeFileTest.listDirectory")
42-
}
43-
}
44-
}
45-
}
4631

4732
sourceSets {
4833
commonMain.dependencies {

filesystem/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ kotlin {
2323
}
2424
}
2525
}
26+
browser {
27+
testTask {
28+
useMocha {
29+
timeout = "300s"
30+
}
31+
}
32+
}
2633
}
2734
@OptIn(ExperimentalWasmDsl::class)
2835
wasmWasi {

smoke-tests/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ tasks {
4949
if (useLocalBuild) {
5050
dependsOn(project(":kotlinx-io-core").tasks.named("publishToMavenLocal"))
5151
dependsOn(project(":kotlinx-io-bytestring").tasks.named("publishToMavenLocal"))
52+
dependsOn(project(":kotlinx-io-filesystem").tasks.named("publishToMavenLocal"))
5253
dependsOn(project(":kotlinx-io-okio").tasks.named("publishToMavenLocal"))
5354

5455
}
@@ -64,6 +65,7 @@ tasks {
6465
if (useLocalBuild) {
6566
dependsOn(project(":kotlinx-io-core").tasks.named("publishToMavenLocal"))
6667
dependsOn(project(":kotlinx-io-bytestring").tasks.named("publishToMavenLocal"))
68+
dependsOn(project(":kotlinx-io-filesystem").tasks.named("publishToMavenLocal"))
6769
dependsOn(project(":kotlinx-io-okio").tasks.named("publishToMavenLocal"))
6870

6971
}

smoke-tests/src/test/kotlin/GradleProjectsTest.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class GradleProjectsTest {
2828
private val stagingRepository: String = System.getProperty("stagingRepository")!!
2929
private val bytestringDependency: String = "org.jetbrains.kotlinx:kotlinx-io-bytestring:$kotlinxIoVersion"
3030
private val coreDependency: String = "org.jetbrains.kotlinx:kotlinx-io-core:$kotlinxIoVersion"
31+
private val fsDependency: String = "org.jetbrains.kotlinx:kotlinx-io-filesystem:$kotlinxIoVersion"
32+
3133
private val okioAdapterDependency: String = "org.jetbrains.kotlinx:kotlinx-io-okio:$kotlinxIoVersion"
3234

3335
private fun generateBuildScript(multiplatform: Boolean, dependencyName: String, isOkio: Boolean = false) {
@@ -102,6 +104,17 @@ public class GradleProjectsTest {
102104
assertTestPassed(results)
103105
}
104106

107+
@Test
108+
fun filesystemJvm() {
109+
setupTest("filesystem-jvm", false, fsDependency)
110+
val results = GradleRunner.create()
111+
.withProjectDir(projectDir.root)
112+
.withArguments(":test")
113+
.run()
114+
115+
assertTestPassed(results)
116+
}
117+
105118
@Test
106119
fun bytestringMultiplatform() {
107120
setupTest("bytestring-multiplatform", true, bytestringDependency)
@@ -124,6 +137,17 @@ public class GradleProjectsTest {
124137
assertTestPassed(results, ":allTests")
125138
}
126139

140+
@Test
141+
fun filesystemMultiplatform() {
142+
setupTest("filesystem-multiplatform", true, fsDependency)
143+
val results = GradleRunner.create()
144+
.withProjectDir(projectDir.root)
145+
.withArguments(":allTests")
146+
.run()
147+
148+
assertTestPassed(results, ":allTests")
149+
}
150+
127151
@Test
128152
fun okioJvm() {
129153
setupTest("okio", false, okioAdapterDependency)

smoke-tests/src/test/resources/gradle-projects/bytestring-multiplatform/SmokeTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
44
*/
55

6+
package org.example
7+
68
import kotlinx.io.bytestring.ByteString
79
import kotlin.test.Test
810
import kotlin.test.assertEquals

smoke-tests/src/test/resources/gradle-projects/core-multiplatform/SmokeTest.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
44
*/
55

6+
package org.example
7+
68
import kotlinx.io.Buffer
79
import kotlinx.io.bytestring.ByteString
8-
import kotlinx.io.files.Path
9-
import kotlinx.io.files.SystemFileSystem
1010
import kotlinx.io.readByteArray
1111
import kotlinx.io.readByteString
1212
import kotlinx.io.write
@@ -30,13 +30,4 @@ class SmokeTest {
3030

3131
assertEquals(ByteString(0x42), buffer.readByteString())
3232
}
33-
34-
@Test
35-
fun testUseFiles() {
36-
try {
37-
SystemFileSystem.exists(Path("."))
38-
} catch (t: Throwable) {
39-
// that's fine
40-
}
41-
}
4233
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2010-2024 JetBrains s.r.o. and respective authors and developers.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
4+
*/
5+
6+
package org.example
7+
8+
import kotlinx.io.Buffer
9+
import kotlinx.io.bytestring.ByteString
10+
import kotlinx.io.files.Path
11+
import kotlinx.io.files.SystemFileSystem
12+
import kotlinx.io.readByteArray
13+
import kotlinx.io.readByteString
14+
import kotlinx.io.write
15+
import kotlin.test.Test
16+
import kotlin.test.assertContentEquals
17+
import kotlin.test.assertEquals
18+
19+
class SmokeTest {
20+
@Test
21+
fun testCore() {
22+
val buffer = Buffer()
23+
buffer.writeLong(0)
24+
assertContentEquals(ByteArray(8), buffer.readByteArray())
25+
}
26+
27+
@Test
28+
fun testByteString() {
29+
val byteString = ByteString(0x42)
30+
val buffer = Buffer()
31+
buffer.write(byteString)
32+
33+
assertEquals(ByteString(0x42), buffer.readByteString())
34+
}
35+
36+
@Test
37+
fun testUseFiles() {
38+
try {
39+
SystemFileSystem.exists(Path("."))
40+
} catch (t: Exception) {
41+
// that's fine
42+
}
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2010-2024 JetBrains s.r.o. and respective authors and developers.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
4+
*/
5+
6+
package org.example
7+
8+
import kotlinx.io.Buffer
9+
import kotlinx.io.bytestring.ByteString
10+
import kotlinx.io.files.Path
11+
import kotlinx.io.files.SystemFileSystem
12+
import kotlinx.io.readByteArray
13+
import kotlinx.io.readByteString
14+
import kotlinx.io.write
15+
import kotlin.test.Test
16+
import kotlin.test.assertContentEquals
17+
import kotlin.test.assertEquals
18+
19+
class SmokeTest {
20+
@Test
21+
fun testCore() {
22+
val buffer = Buffer()
23+
buffer.writeLong(0)
24+
assertContentEquals(ByteArray(8), buffer.readByteArray())
25+
}
26+
27+
@Test
28+
fun testByteString() {
29+
val byteString = ByteString(0x42)
30+
val buffer = Buffer()
31+
buffer.write(byteString)
32+
33+
assertEquals(ByteString(0x42), buffer.readByteString())
34+
}
35+
36+
@Test
37+
fun testUseFiles() {
38+
try {
39+
SystemFileSystem.exists(Path("."))
40+
} catch (t: Exception) {
41+
// that's fine
42+
}
43+
}
44+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.jetbrains.kotlinx</groupId>
7+
<artifactId>kotlinx-maven-projects</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
11+
<artifactId>core-jvm</artifactId>
12+
<version>${project.parent.version}</version>
13+
14+
<name>core-jvm</name>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.source>1.8</maven.compiler.source>
19+
<maven.compiler.target>1.8</maven.compiler.target>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.jetbrains.kotlinx</groupId>
25+
<artifactId>kotlinx-io-filesystem-jvm</artifactId>
26+
<version>${kotlinx.io.version}</version>
27+
</dependency>
28+
</dependencies>
29+
30+
<build>
31+
<plugins>
32+
<plugin>
33+
<groupId>org.jetbrains.kotlin</groupId>
34+
<artifactId>kotlin-maven-plugin</artifactId>
35+
<version>${kotlin.version}</version>
36+
37+
<executions>
38+
<execution>
39+
<id>compile</id>
40+
<goals>
41+
<goal>compile</goal>
42+
</goals>
43+
<configuration>
44+
<sourceDirs>
45+
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
46+
</sourceDirs>
47+
</configuration>
48+
</execution>
49+
50+
<execution>
51+
<id>test-compile</id>
52+
<goals>
53+
<goal>test-compile</goal>
54+
</goals>
55+
<configuration>
56+
<sourceDirs>
57+
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
58+
</sourceDirs>
59+
</configuration>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
</project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
3+
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
4+
*/
5+
6+
package org.example
7+
8+
import kotlinx.io.Buffer
9+
import kotlinx.io.bytestring.ByteString
10+
import kotlinx.io.readByteArray
11+
import kotlinx.io.readByteString
12+
import kotlinx.io.write
13+
import java.lang.RuntimeException
14+
import kotlin.test.Test
15+
import kotlin.test.assertContentEquals
16+
import kotlin.test.assertEquals
17+
18+
class SmokeTest {
19+
@Test
20+
fun testCore() {
21+
val buffer = Buffer()
22+
buffer.writeLong(0)
23+
assertContentEquals(ByteArray(8), buffer.readByteArray())
24+
}
25+
26+
@Test
27+
fun testByteString() {
28+
val byteString = ByteString(0x42)
29+
val buffer = Buffer()
30+
buffer.write(byteString)
31+
32+
assertEquals(ByteString(0x42), buffer.readByteString())
33+
}
34+
35+
@Test
36+
fun testUseFiles() {
37+
try {
38+
SystemFileSystem.exists(Path("."))
39+
} catch (t: Exception) {
40+
// that's fine
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)