[WASM] Kotlin gradle plugin tests for Wasm nodejs and d8 support
This commit is contained in:
+25
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_SHORT_NAME
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_UNIQUE_NAME
|
||||
import org.junit.Assert
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
import java.util.jar.JarFile
|
||||
@@ -1955,6 +1956,30 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun testWasmTest(engine: String, name: String) = with(
|
||||
Project("new-mpp-wasm-test", gradleVersionRequirement = GradleVersionRequired.AtLeast(TestVersions.Gradle.G_7_0))
|
||||
) {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify {
|
||||
transformBuildScriptWithPluginsDsl(it)
|
||||
.replace("<JsEngine>", engine)
|
||||
}
|
||||
build(":wasm${name}Test") {
|
||||
assertTasksExecuted(":compileKotlinWasm")
|
||||
assertTasksFailed(":wasm${name}Test")
|
||||
assertTestResults(
|
||||
"testProject/new-mpp-wasm-test/TEST-${engine}.xml",
|
||||
"wasm${name}Test"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWasmNodeTest() = testWasmTest("nodejs", "Node")
|
||||
|
||||
@Test
|
||||
fun testWasmD8Test() = testWasmTest("d8", "D8")
|
||||
|
||||
@Test
|
||||
fun testResolveMetadataCompileClasspathKt50925() {
|
||||
Project("lib", directoryPrefix = "kt-50925-resolve-metadata-compile-classpath").apply {
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="my.pack.name.WasmTest" tests="3" skipped="1" failures="2" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="test1[wasm, d8]" classname="my.pack.name.WasmTest" time="...">
|
||||
<failure message="..." type="AssertionError">...</failure>
|
||||
</testcase>
|
||||
<testcase name="test2[wasm, d8]" classname="my.pack.name.WasmTest" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test3[wasm, d8]" classname="my.pack.name.WasmTest" time="...">
|
||||
<failure message="..." type="AssertionError">...</failure>
|
||||
</testcase>
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="my.pack.name.WasmTest.InnerIgnored" tests="3" skipped="3" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="test4[wasm, d8]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test5[wasm, d8]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test6[wasm, d8]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
</results>
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="my.pack.name.WasmTest" tests="3" skipped="1" failures="2" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="test1[wasm, node]" classname="my.pack.name.WasmTest" time="...">
|
||||
<failure message="..." type="AssertionError">...</failure>
|
||||
</testcase>
|
||||
<testcase name="test2[wasm, node]" classname="my.pack.name.WasmTest" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test3[wasm, node]" classname="my.pack.name.WasmTest" time="...">
|
||||
<failure message="..." type="AssertionError">...</failure>
|
||||
</testcase>
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="my.pack.name.WasmTest.InnerIgnored" tests="3" skipped="3" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="test4[wasm, node]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test5[wasm, node]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<testcase name="test6[wasm, node]" classname="my.pack.name.WasmTest.InnerIgnored" time="...">
|
||||
<skipped />
|
||||
</testcase>
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
</results>
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
kotlin("multiplatform").version("<pluginMarkerVersion>")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
with(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin.apply(rootProject)) {
|
||||
//nightly nodejs that supports wasm M5
|
||||
nodeVersion = "19.0.0-nightly202206017ad5b420ae"
|
||||
nodeDownloadBaseUrl = "https://nodejs.org/download/nightly/"
|
||||
}
|
||||
|
||||
with(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin.apply(rootProject)) {
|
||||
//A little hacky way to disable yarn for unsupported nightly node version
|
||||
command = "echo"
|
||||
download = false
|
||||
}
|
||||
|
||||
tasks.named<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockCopyTask>("kotlinStoreYarnLock") {
|
||||
//A little hacky way to make yarn results
|
||||
inputFile.fileValue(projectDir.resolve("yarnLockStub"))
|
||||
}
|
||||
|
||||
kotlin {
|
||||
wasm {
|
||||
<JsEngine>()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-test")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "new-mpp-wasm-node-test"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package my.pack.name
|
||||
|
||||
fun foo(): Int = 2
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package my.pack.name
|
||||
|
||||
import kotlin.test.Ignore
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class WasmTest {
|
||||
@Test
|
||||
fun test1() = assertEquals(foo(), 1)
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun test2() = assertEquals(foo(), 2)
|
||||
|
||||
@Test
|
||||
fun test3() = assertEquals(foo(), 3)
|
||||
|
||||
@Ignore
|
||||
class InnerIgnored {
|
||||
@Test
|
||||
fun test4() = assertEquals(foo(), 1)
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun test5() = assertEquals(foo(), 2)
|
||||
|
||||
@Test
|
||||
fun test6() = assertEquals(foo(), 3)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user