[WASM] Fix Kotlin.Test box tests

This commit is contained in:
Igor Yakovlev
2022-06-07 15:34:58 +02:00
committed by teamcity
parent f996278171
commit 3abcd84802
7 changed files with 95 additions and 67 deletions
@@ -12,10 +12,7 @@ import org.jetbrains.kotlin.js.test.*
import org.jetbrains.kotlin.js.test.ir.*
import org.jetbrains.kotlin.js.testOld.AbstractDceTest
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.AbstractIrCodegenBoxWasmTest
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractIrCodegenWasmJsInteropWasmTest
import org.jetbrains.kotlin.js.testOld.wasm.semantics.AbstractJsTranslatorWasmTest
import org.jetbrains.kotlin.js.testOld.wasm.semantics.*
import org.jetbrains.kotlin.test.TargetBackend
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") {
testClass<AbstractJsTranslatorWasmTest> {
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)
}
testClass<AbstractJsTranslatorUnitWasmTest> {
model("box/kotlin.test/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
}
testClass<AbstractDceTest> {
model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS)
}
@@ -39,7 +39,8 @@ import java.io.File
abstract class BasicWasmBoxTest(
private val pathToTestDir: String,
testGroupOutputDirPrefix: String,
pathToRootOutputDir: String = TEST_DATA_DIR_PATH
pathToRootOutputDir: String = TEST_DATA_DIR_PATH,
private val startUnitTests: Boolean = false
) : KotlinTestWithEnvironment() {
private val testGroupOutputDirForCompilation = File(pathToRootOutputDir + "out/" + testGroupOutputDirPrefix)
@@ -147,12 +148,14 @@ abstract class BasicWasmBoxTest(
generateWat = generateWat,
)
val startUnitTests = if (startUnitTests) "exports.startUnitTests?.();\n" else ""
val testJsQuiet = """
import exports from './index.mjs';
let actualResult
try {
actualResult = exports.box();
${startUnitTests}actualResult = exports.box();
} catch(e) {
console.log('Failed with exception!')
console.log('Message: ' + e.message)
@@ -26,3 +26,9 @@ abstract class AbstractJsTranslatorWasmTest : BasicWasmBoxTest(
TEST_DATA_DIR_PATH + "box/",
"js.translator/wasmBox"
)
abstract class AbstractJsTranslatorUnitWasmTest : BasicWasmBoxTest(
TEST_DATA_DIR_PATH + "box/",
"js.translator/wasmBox",
startUnitTests = true
)
@@ -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");
}
}
@@ -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")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1951,7 +1951,7 @@ class NewMultiplatformIT : BaseGradleIT() {
assertFileExists(jsOutput + "redefined-js-module-name.js")
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")
}
}
@@ -10,7 +10,7 @@ repositories {
kotlin {
wasm {
moduleName = "redefined-wasm-module-name"
browser {
d8 {
}
binaries.executable()
}