[WASM] Fix Kotlin.Test box tests
This commit is contained in:
@@ -12,10 +12,7 @@ import org.jetbrains.kotlin.js.test.*
|
|||||||
import org.jetbrains.kotlin.js.test.ir.*
|
import org.jetbrains.kotlin.js.test.ir.*
|
||||||
import org.jetbrains.kotlin.js.testOld.AbstractDceTest
|
import org.jetbrains.kotlin.js.testOld.AbstractDceTest
|
||||||
import org.jetbrains.kotlin.js.testOld.compatibility.binary.AbstractJsKlibBinaryCompatibilityTest
|
import org.jetbrains.kotlin.js.testOld.compatibility.binary.AbstractJsKlibBinaryCompatibilityTest
|
||||||
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractIrCodegenBoxInlineWasmTest
|
import org.jetbrains.kotlin.js.testOld.wasm.semantics.*
|
||||||
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractIrCodegenBoxWasmTest
|
|
||||||
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractIrCodegenWasmJsInteropWasmTest
|
|
||||||
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractJsTranslatorWasmTest
|
|
||||||
import org.jetbrains.kotlin.test.TargetBackend
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrJsTextTest
|
import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrJsTextTest
|
||||||
|
|
||||||
@@ -33,10 +30,13 @@ fun main(args: Array<String>) {
|
|||||||
testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") {
|
testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") {
|
||||||
testClass<AbstractJsTranslatorWasmTest> {
|
testClass<AbstractJsTranslatorWasmTest> {
|
||||||
model("box/main", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
model("box/main", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
||||||
model("box/kotlin.test/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
|
||||||
model("box/native/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
model("box/native/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractJsTranslatorUnitWasmTest> {
|
||||||
|
model("box/kotlin.test/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
|
||||||
|
}
|
||||||
|
|
||||||
testClass<AbstractDceTest> {
|
testClass<AbstractDceTest> {
|
||||||
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
|
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ import java.io.File
|
|||||||
abstract class BasicWasmBoxTest(
|
abstract class BasicWasmBoxTest(
|
||||||
private val pathToTestDir: String,
|
private val pathToTestDir: String,
|
||||||
testGroupOutputDirPrefix: String,
|
testGroupOutputDirPrefix: String,
|
||||||
pathToRootOutputDir: String = TEST_DATA_DIR_PATH
|
pathToRootOutputDir: String = TEST_DATA_DIR_PATH,
|
||||||
|
private val startUnitTests: Boolean = false
|
||||||
) : KotlinTestWithEnvironment() {
|
) : KotlinTestWithEnvironment() {
|
||||||
private val testGroupOutputDirForCompilation = File(pathToRootOutputDir + "out/" + testGroupOutputDirPrefix)
|
private val testGroupOutputDirForCompilation = File(pathToRootOutputDir + "out/" + testGroupOutputDirPrefix)
|
||||||
|
|
||||||
@@ -147,12 +148,14 @@ abstract class BasicWasmBoxTest(
|
|||||||
generateWat = generateWat,
|
generateWat = generateWat,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val startUnitTests = if (startUnitTests) "exports.startUnitTests?.();\n" else ""
|
||||||
|
|
||||||
val testJsQuiet = """
|
val testJsQuiet = """
|
||||||
import exports from './index.mjs';
|
import exports from './index.mjs';
|
||||||
|
|
||||||
let actualResult
|
let actualResult
|
||||||
try {
|
try {
|
||||||
actualResult = exports.box();
|
${startUnitTests}actualResult = exports.box();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log('Failed with exception!')
|
console.log('Failed with exception!')
|
||||||
console.log('Message: ' + e.message)
|
console.log('Message: ' + e.message)
|
||||||
|
|||||||
+6
@@ -26,3 +26,9 @@ abstract class AbstractJsTranslatorWasmTest : BasicWasmBoxTest(
|
|||||||
TEST_DATA_DIR_PATH + "box/",
|
TEST_DATA_DIR_PATH + "box/",
|
||||||
"js.translator/wasmBox"
|
"js.translator/wasmBox"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
abstract class AbstractJsTranslatorUnitWasmTest : BasicWasmBoxTest(
|
||||||
|
TEST_DATA_DIR_PATH + "box/",
|
||||||
|
"js.translator/wasmBox",
|
||||||
|
startUnitTests = true
|
||||||
|
)
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.js.testOld.wasm.semantics;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("js/js.translator/testData/box/kotlin.test")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class JsTranslatorUnitWasmTestGenerated extends AbstractJsTranslatorUnitWasmTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInKotlin_test() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beforeAfter.kt")
|
||||||
|
public void testBeforeAfter() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/beforeAfter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ignore.kt")
|
||||||
|
public void testIgnore() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/ignore.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("illegalParameters.kt")
|
||||||
|
public void testIllegalParameters() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/illegalParameters.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("incremental.kt")
|
||||||
|
public void testIncremental() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/incremental.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inherited.kt")
|
||||||
|
public void testInherited() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/inherited.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mpp.kt")
|
||||||
|
public void testMpp() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/mpp.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nested.kt")
|
||||||
|
public void testNested() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/nested.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("returnTestResult.kt")
|
||||||
|
public void testReturnTestResult() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/returnTestResult.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/kotlin.test/simple.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
-58
@@ -73,64 +73,6 @@ public class JsTranslatorWasmTestGenerated extends AbstractJsTranslatorWasmTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("js/js.translator/testData/box/kotlin.test")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public static class Kotlin_test extends AbstractJsTranslatorWasmTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInKotlin_test() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("beforeAfter.kt")
|
|
||||||
public void testBeforeAfter() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/beforeAfter.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("ignore.kt")
|
|
||||||
public void testIgnore() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/ignore.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("illegalParameters.kt")
|
|
||||||
public void testIllegalParameters() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/illegalParameters.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("incremental.kt")
|
|
||||||
public void testIncremental() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/incremental.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("inherited.kt")
|
|
||||||
public void testInherited() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/inherited.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("mpp.kt")
|
|
||||||
public void testMpp() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/mpp.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
|
||||||
public void testNested() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/nested.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("returnTestResult.kt")
|
|
||||||
public void testReturnTestResult() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/returnTestResult.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("simple.kt")
|
|
||||||
public void testSimple() throws Exception {
|
|
||||||
runTest("js/js.translator/testData/box/kotlin.test/simple.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("js/js.translator/testData/box/native")
|
@TestMetadata("js/js.translator/testData/box/native")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+1
-1
@@ -1951,7 +1951,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
assertFileExists(jsOutput + "redefined-js-module-name.js")
|
assertFileExists(jsOutput + "redefined-js-module-name.js")
|
||||||
|
|
||||||
val wasmOutput = outputPrefix + "redefined-wasm-module-name/kotlin/"
|
val wasmOutput = outputPrefix + "redefined-wasm-module-name/kotlin/"
|
||||||
assertFileExists(wasmOutput + "redefined-wasm-module-name.js")
|
assertFileExists(wasmOutput + "redefined-wasm-module-name.mjs")
|
||||||
assertFileExists(wasmOutput + "redefined-wasm-module-name.wasm")
|
assertFileExists(wasmOutput + "redefined-wasm-module-name.wasm")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ repositories {
|
|||||||
kotlin {
|
kotlin {
|
||||||
wasm {
|
wasm {
|
||||||
moduleName = "redefined-wasm-module-name"
|
moduleName = "redefined-wasm-module-name"
|
||||||
browser {
|
d8 {
|
||||||
}
|
}
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user