[Wasm] Move compiler tests to :wasm:wasm.tests module

They don't belong in K/JS test module.
This commit is contained in:
Svyatoslav Kuzmich
2023-01-24 12:08:18 +01:00
committed by teamcity
parent 46c8cbe1bb
commit bebb9b1392
21 changed files with 224 additions and 144 deletions
-77
View File
@@ -1,6 +1,4 @@
import com.github.gradle.node.npm.task.NpmTask
import de.undercouch.gradle.tasks.download.Download
import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin
@@ -13,7 +11,6 @@ plugins {
kotlin("plugin.serialization")
id("jps-compatible")
id("com.github.node-gradle.node") version "3.2.1"
id("de.undercouch.download")
}
val nodeDir = buildDir.resolve("node")
@@ -48,7 +45,6 @@ dependencies {
testCompileOnly(project(":compiler:util"))
testCompileOnly(intellijCore())
testApi(project(":compiler:backend.js"))
testApi(project(":compiler:backend.wasm"))
testApi(project(":js:js.translator"))
testApi(project(":js:js.serializer"))
testApi(project(":js:js.dce"))
@@ -106,59 +102,8 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
}
}
enum class OsName { WINDOWS, MAC, LINUX, UNKNOWN }
enum class OsArch { X86_32, X86_64, ARM64, UNKNOWN }
data class OsType(val name: OsName, val arch: OsArch)
abstract class MochaTestTask : NpmTask(), VerificationTask
val currentOsType = run {
val gradleOs = OperatingSystem.current()
val osName = when {
gradleOs.isMacOsX -> OsName.MAC
gradleOs.isWindows -> OsName.WINDOWS
gradleOs.isLinux -> OsName.LINUX
else -> OsName.UNKNOWN
}
val osArch = when (providers.systemProperty("sun.arch.data.model").forUseAtConfigurationTime().get()) {
"32" -> OsArch.X86_32
"64" -> when (providers.systemProperty("os.arch").forUseAtConfigurationTime().get().toLowerCase()) {
"aarch64" -> OsArch.ARM64
else -> OsArch.X86_64
}
else -> OsArch.UNKNOWN
}
OsType(osName, osArch)
}
val jsShellDirectory = "https://archive.mozilla.org/pub/firefox/nightly/2023/01/2023-01-23-09-44-44-mozilla-central"
val jsShellSuffix = when (currentOsType) {
OsType(OsName.LINUX, OsArch.X86_32) -> "linux-i686"
OsType(OsName.LINUX, OsArch.X86_64) -> "linux-x86_64"
OsType(OsName.MAC, OsArch.X86_64),
OsType(OsName.MAC, OsArch.ARM64) -> "mac"
OsType(OsName.WINDOWS, OsArch.X86_32) -> "win32"
OsType(OsName.WINDOWS, OsArch.X86_64) -> "win64"
else -> error("unsupported os type $currentOsType")
}
val jsShellLocation = "$jsShellDirectory/jsshell-$jsShellSuffix.zip"
val downloadedTools = File(buildDir, "tools")
val downloadJsShell by task<Download> {
src(jsShellLocation)
dest(File(downloadedTools, "jsshell-$jsShellSuffix.zip"))
overwrite(false)
}
val unzipJsShell by task<Copy> {
dependsOn(downloadJsShell)
from(zipTree(downloadJsShell.get().dest))
val unpackedDir = File(downloadedTools, "jsshell-$jsShellSuffix")
into(unpackedDir)
}
val testDataDir = project(":js:js.translator").projectDir.resolve("testData")
val typescriptTestsDir = testDataDir.resolve("typescript-export")
@@ -262,12 +207,6 @@ fun Test.setupNodeJs() {
)
}
fun Test.setupSpiderMonkey() {
dependsOn(unzipJsShell)
val jsShellExecutablePath = File(unzipJsShell.get().destinationDir, "js").absolutePath
systemProperty("javascript.engine.path.SpiderMonkey", jsShellExecutablePath)
}
val d8Plugin = D8RootPlugin.apply(rootProject)
d8Plugin.version = v8Version
@@ -318,7 +257,6 @@ fun Test.setUpJsBoxTests(jsEnabled: Boolean, jsIrEnabled: Boolean, firEnabled: B
inputs.dir(rootDir.resolve("libraries/kotlin.test/js-ir/build/classes/kotlin/js/main"))
}
exclude("org/jetbrains/kotlin/js/testOld/wasm/semantics/*")
exclude("org/jetbrains/kotlin/js/testOld/api/*")
if (jsEnabled && !jsIrEnabled) {
@@ -485,21 +423,6 @@ val runMocha by tasks.registering {
finalizedBy(mochaTest)
}
projectTest("wasmTest", true) {
setupV8()
setupSpiderMonkey()
include("org/jetbrains/kotlin/js/testOld/wasm/semantics/*")
dependsOn(":kotlin-stdlib-wasm:compileKotlinWasm")
systemProperty("kotlin.wasm.stdlib.path", "libraries/stdlib/wasm/build/classes/kotlin/wasm/main")
dependsOn(":kotlin-test:kotlin-test-wasm:compileKotlinWasm")
systemProperty("kotlin.wasm.kotlin.test.path", "libraries/kotlin.test/wasm/build/classes/kotlin/wasm/main")
setUpBoxTests()
}
projectTest("invalidationTest", jUnitMode = JUnitMode.JUnit4) {
setupV8()
workingDir = rootDir
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5
import org.jetbrains.kotlin.generators.impl.generateTestGroupSuite
import org.jetbrains.kotlin.incremental.AbstractInvalidationTest
import org.jetbrains.kotlin.incremental.AbstractJsIrES6InvalidationTest
import org.jetbrains.kotlin.incremental.AbstractJsIrInvalidationTest
import org.jetbrains.kotlin.js.test.*
@@ -15,7 +14,6 @@ import org.jetbrains.kotlin.js.test.fir.*
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.*
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrJsTextTest
@@ -33,24 +31,6 @@ fun main(args: Array<String>) {
generateTestGroupSuite(args) {
testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") {
testClass<AbstractJsTranslatorWasmTest> {
model("box/main", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
model("box/native/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM)
model("box/esModules/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM,
excludeDirs = listOf(
// JsExport is not supported for classes
"jsExport", "native", "export",
// Multimodal infra is not supported. Also, we don't use ES modules for cross-module refs in Wasm
"crossModuleRef", "crossModuleRefPerFile", "crossModuleRefPerModule"
)
)
model("box/jsQualifier/", 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)
}
@@ -77,22 +57,6 @@ fun main(args: Array<String>) {
}
}
testGroup("js/js.tests/tests-gen", "compiler/testData", testRunnerMethodName = "runTest0") {
testClass<AbstractIrCodegenBoxWasmTest> {
model(
"codegen/box", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.WASM, excludeDirs = jvmOnlyBoxTests
)
}
testClass<AbstractIrCodegenBoxInlineWasmTest> {
model("codegen/boxInline", targetBackend = TargetBackend.WASM)
}
testClass<AbstractIrCodegenWasmJsInteropWasmTest> {
model("codegen/boxWasmJsInterop", targetBackend = TargetBackend.WASM)
}
}
testGroup("js/js.tests/tests-gen", "compiler/testData/binaryCompatibility", testRunnerMethodName = "runTest0") {
testClass<AbstractJsKlibBinaryCompatibilityTest> {
model("klibEvolution", targetBackend = TargetBackend.JS_IR)
@@ -1,365 +0,0 @@
/*
* 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
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiManager
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.common.phaser.toPhaseMap
import org.jetbrains.kotlin.backend.wasm.*
import org.jetbrains.kotlin.backend.wasm.dce.eliminateDeadDeclarations
import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.ir.backend.js.prepareAnalyzedSourceModule
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.facade.TranslationUnit
import org.jetbrains.kotlin.js.testOld.engines.WasmVM
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.resolve.CompilerEnvironment
import org.jetbrains.kotlin.serialization.js.ModuleKind
import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.util.KtTestUtil
import java.io.Closeable
import java.io.File
abstract class BasicWasmBoxTest(
private val pathToTestDir: String,
testGroupOutputDirPrefix: String,
private val startUnitTests: Boolean = false
) : KotlinTestWithEnvironment() {
private val pathToRootOutputDir: String = System.getProperty("kotlin.js.test.root.out.dir") ?: error("'kotlin.js.test.root.out.dir' is not set")
private val testGroupOutputDirForCompilation = File(pathToRootOutputDir + "out/" + testGroupOutputDirPrefix)
private val COMMON_FILES_NAME = "_common"
private val COMMON_FILES_DIR = "_commonFiles"
private val extraLanguageFeatures = mapOf(
LanguageFeature.JsAllowImplementingFunctionInterface to LanguageFeature.State.ENABLED,
)
fun doTest(filePath: String) = doTestWithTransformer(filePath) { it }
fun doTestWithTransformer(filePath: String, transformer: java.util.function.Function<String, String>) {
val file = File(filePath)
val outputDirBase = File(getOutputDir(file), getTestName(true))
val fileContent = transformer.apply(KtTestUtil.doLoadFile(file))
TestFileFactoryImpl().use { testFactory ->
val inputFiles: MutableList<TestFile> = TestFiles.createTestFiles(file.name, fileContent, testFactory, true)
val testPackage = testFactory.testPackage
val languageVersionSettings = inputFiles.firstNotNullOfOrNull { it.languageVersionSettings }
val kotlinFiles = mutableListOf<String>()
val jsFilesBefore = mutableListOf<String>()
val jsFilesAfter = mutableListOf<String>()
val mjsFiles = mutableListOf<String>()
var entryMjs: String? = "test.mjs"
inputFiles.forEach {
val name = it.fileName
when {
name.endsWith(".kt") ->
kotlinFiles += name
name.endsWith("__after.js") ->
jsFilesAfter += name
name.endsWith(".js") ->
jsFilesBefore += name
name.endsWith(".mjs") -> {
mjsFiles += name
val fileName = File(name).name
if (fileName == "entry.mjs") {
entryMjs = fileName
}
}
}
}
val additionalJsFile = filePath.removeSuffix(".kt") + ".js"
if (File(additionalJsFile).exists()) {
jsFilesBefore += additionalJsFile
}
val additionalMjsFile = filePath.removeSuffix(".kt") + ".mjs"
if (File(additionalMjsFile).exists()) {
mjsFiles += additionalMjsFile
}
val localCommonFile = file.parent + "/" + COMMON_FILES_NAME + "." + KotlinFileType.EXTENSION
val localCommonFiles = if (File(localCommonFile).exists()) listOf(localCommonFile) else emptyList()
val globalCommonFilesDir = File(File(pathToTestDir).parent, COMMON_FILES_DIR)
val globalCommonFiles = globalCommonFilesDir.listFiles().orEmpty().map { it.absolutePath }
val allSourceFiles = kotlinFiles + localCommonFiles + globalCommonFiles
val psiFiles = createPsiFiles(allSourceFiles.map { File(it).canonicalPath }.sorted())
val config = createConfig(languageVersionSettings)
val filesToCompile = psiFiles.map { TranslationUnit.SourceFile(it).file }
val debugMode = DebugMode.fromSystemProperty("kotlin.wasm.debugMode")
val phaseConfig = if (debugMode >= DebugMode.SUPER_DEBUG) {
val dumpOutputDir = File(outputDirBase, "irdump")
println("\n ------ Dumping phases to file://${dumpOutputDir.absolutePath}")
PhaseConfig(
wasmPhases,
dumpToDirectory = dumpOutputDir.path,
toDumpStateAfter = wasmPhases.toPhaseMap().values.toSet(),
)
} else {
PhaseConfig(wasmPhases)
}
if (debugMode >= DebugMode.DEBUG) {
println(" ------ KT file://${file.absolutePath}")
}
val sourceModule = prepareAnalyzedSourceModule(
config.project,
filesToCompile,
config.configuration,
// TODO: Bypass the resolver fow wasm.
listOf(System.getProperty("kotlin.wasm.stdlib.path")!!, System.getProperty("kotlin.wasm.kotlin.test.path")!!),
emptyList(),
AnalyzerWithCompilerReport(config.configuration)
)
val (allModules, backendContext) = compileToLoweredIr(
depsDescriptors = sourceModule,
phaseConfig = phaseConfig,
irFactory = IrFactoryImpl,
exportedDeclarations = setOf(FqName.fromSegments(listOfNotNull(testPackage, TEST_FUNCTION))),
propertyLazyInitialization = true,
)
val generateWat = debugMode >= DebugMode.DEBUG
val baseFileName = "index"
val compilerResult = compileWasm(
allModules = allModules,
backendContext = backendContext,
baseFileName = baseFileName,
emitNameSection = true,
allowIncompleteImplementations = false,
generateWat = generateWat,
)
eliminateDeadDeclarations(allModules, backendContext)
val compilerResultWithDCE = compileWasm(
allModules = allModules,
backendContext = backendContext,
baseFileName = baseFileName,
emitNameSection = true,
allowIncompleteImplementations = true,
generateWat = generateWat,
)
val testJsQuiet = """
let actualResult;
try {
// Use "dynamic import" to catch exception happened during JS & Wasm modules initialization
let jsModule = await import('./index.mjs');
let wasmExports = jsModule.default;
${if (startUnitTests) "wasmExports.startUnitTests();" else ""}
actualResult = wasmExports.box();
} catch(e) {
console.log('Failed with exception!')
console.log('Message: ' + e.message)
console.log('Name: ' + e.name)
console.log('Stack:')
console.log(e.stack)
}
if (actualResult !== "OK")
throw `Wrong box result '${'$'}{actualResult}'; Expected "OK"`;
""".trimIndent()
val testJsVerbose = testJsQuiet + """
console.log('test passed');
""".trimIndent()
val testJs = if (debugMode >= DebugMode.DEBUG) testJsVerbose else testJsQuiet
fun writeToFilesAndRunTest(name: String, res: WasmCompilerResult) {
val dir = File(outputDirBase, name)
dir.mkdirs()
if (debugMode >= DebugMode.DEBUG) {
val path = dir.absolutePath
println(" ------ $name Wat file://$path/index.wat")
println(" ------ $name Wasm file://$path/index.wasm")
println(" ------ $name JS file://$path/index.uninstantiated.mjs")
println(" ------ $name JS file://$path/index.mjs")
println(" ------ $name Test file://$path/test.mjs")
val projectName = "kotlin"
println(" ------ $name HTML http://0.0.0.0:63342/$projectName/${dir.path}/index.html")
for (mjsPath: String in mjsFiles) {
println(" ------ $name External ESM file://$path/${File(mjsPath).name}")
}
File(dir, "index.html").writeText(
"""
<!DOCTYPE html>
<html lang="en">
<body>
<span id="test">UNKNOWN</span>
<script type="module">
let test = document.getElementById("test")
try {
await import("./test.mjs");
test.style.backgroundColor = "#0f0";
test.textContent = "OK"
} catch(e) {
test.style.backgroundColor = "#f00";
test.textContent = "NOT OK"
throw e;
}
</script>
</body>
</html>
""".trimIndent()
)
}
writeCompilationResult(res, dir, baseFileName)
File(dir, "test.mjs").writeText(testJs)
for (mjsPath: String in mjsFiles) {
val mjsFile = File(mjsPath)
File(dir, mjsFile.name).writeText(mjsFile.readText())
}
val failsIn = InTextDirectivesUtils.findListWithPrefixes(file.readText(), "// WASM_FAILS_IN: ")
val exceptions = listOf(WasmVM.V8, WasmVM.SpiderMonkey).mapNotNull map@{ vm ->
try {
if (debugMode >= DebugMode.DEBUG) {
println(" ------ Run in ${vm.name}" + if (vm.shortName in failsIn) " (expected to fail)" else "")
}
vm.run(
"./${entryMjs}",
jsFilesBefore.map { File(it).absolutePath },
jsFilesAfter.map { File(it).absolutePath },
workingDirectory = dir
)
if (vm.shortName in failsIn) {
return@map AssertionError("The test expected to fail in ${vm.name}. Please update the testdata.")
}
} catch (e: Throwable) {
if (vm.shortName !in failsIn) {
return@map e
}
}
null
}
when (exceptions.size) {
0 -> {} // Everything OK
1 -> {
throw exceptions.single()
}
else -> {
throw AssertionError("Failed with several exceptions. Look at suppressed exceptions below.").apply {
exceptions.forEach { addSuppressed(it) }
}
}
}
}
writeToFilesAndRunTest("dev", compilerResult)
writeToFilesAndRunTest("dce", compilerResultWithDCE)
}
}
private fun getOutputDir(file: File, testGroupOutputDir: File = testGroupOutputDirForCompilation): File {
val stopFile = File(pathToTestDir)
return generateSequence(file.parentFile) { it.parentFile }
.takeWhile { it != stopFile }
.map { it.name }
.toList().asReversed()
.fold(testGroupOutputDir, ::File)
}
private fun createConfig(languageVersionSettings: LanguageVersionSettings?): JsConfig {
val configuration = environment.configuration.copy()
configuration.put(CommonConfigurationKeys.MODULE_NAME, TEST_MODULE)
configuration.put(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, true)
configuration.put(JSConfigurationKeys.WASM_ENABLE_ASSERTS, true)
configuration.put(JSConfigurationKeys.MODULE_KIND, ModuleKind.ES)
configuration.languageVersionSettings = languageVersionSettings
?: LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, specificFeatures = extraLanguageFeatures)
return JsConfig(project, configuration, CompilerEnvironment, null, null)
}
private inner class TestFileFactoryImpl : TestFiles.TestFileFactoryNoModules<TestFile>(), Closeable {
override fun create(fileName: String, text: String, directives: Directives): TestFile {
val ktFile = KtPsiFactory(project).createFile(text)
val boxFunction = ktFile.declarations.find { it is KtNamedFunction && it.name == TEST_FUNCTION }
if (boxFunction != null) {
testPackage = ktFile.packageFqName.asString()
if (testPackage?.isEmpty() == true) {
testPackage = null
}
}
val languageVersionSettings = parseLanguageVersionSettings(directives, extraLanguageFeatures)
val temporaryFile = File(tmpDir, "WASM_TEST/$fileName")
KtTestUtil.mkdirs(temporaryFile.parentFile)
temporaryFile.writeText(text, Charsets.UTF_8)
return TestFile(temporaryFile.absolutePath, languageVersionSettings)
}
var testPackage: String? = null
val tmpDir = KtTestUtil.tmpDir("wasm-tests")
override fun close() {
FileUtil.delete(tmpDir)
}
}
private class TestFile(val fileName: String, val languageVersionSettings: LanguageVersionSettings?)
override fun createEnvironment() =
KotlinCoreEnvironment.createForTests(testRootDisposable, CompilerConfiguration(), EnvironmentConfigFiles.JS_CONFIG_FILES)
private fun KotlinTestWithEnvironment.createPsiFile(fileName: String): KtFile {
val psiManager = PsiManager.getInstance(project)
val fileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
val file = fileSystem.findFileByPath(fileName) ?: error("File not found: $fileName")
return psiManager.findFile(file) as KtFile
}
private fun KotlinTestWithEnvironment.createPsiFiles(fileNames: List<String>): List<KtFile> {
return fileNames.map { this@createPsiFiles.createPsiFile(it) }
}
companion object {
const val TEST_DATA_DIR_PATH = "js/js.translator/testData/"
const val TEST_MODULE = "main"
private const val TEST_FUNCTION = "box"
}
}
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.js.engine.ScriptEngineV8
import org.jetbrains.kotlin.js.engine.loadFiles
import org.junit.Assert
internal const val TEST_DATA_DIR_PATH = "js/js.translator/testData/"
private const val DIST_DIR_JS_PATH = "dist/js/"
private const val ESM_EXTENSION = ".mjs"
@@ -172,7 +173,7 @@ object NashornJsTestChecker : AbstractNashornJsTestChecker() {
}
override val preloadedScripts = listOf(
BasicWasmBoxTest.TEST_DATA_DIR_PATH + "nashorn-polyfills.js",
TEST_DATA_DIR_PATH + "nashorn-polyfills.js",
DIST_DIR_JS_PATH + "kotlin.js",
DIST_DIR_JS_PATH + "kotlin-test.js"
)
@@ -188,7 +189,7 @@ object NashornJsTestChecker : AbstractNashornJsTestChecker() {
object NashornIrJsTestChecker : AbstractNashornJsTestChecker() {
override val preloadedScripts = listOf(
BasicWasmBoxTest.TEST_DATA_DIR_PATH + "nashorn-polyfills.js",
TEST_DATA_DIR_PATH + "nashorn-polyfills.js",
"libraries/stdlib/js-v1/src/js/polyfills.js"
)
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.js.backend.ast.*
import org.jetbrains.kotlin.js.inline.clean.renameLabels
import org.jetbrains.kotlin.js.inline.clean.resolveTemporaryNames
import org.jetbrains.kotlin.js.parser.parse
import org.jetbrains.kotlin.js.testOld.BasicWasmBoxTest
import org.jetbrains.kotlin.js.testOld.TEST_DATA_DIR_PATH
import org.junit.Assert.assertEquals
import org.junit.Assert.fail
import org.junit.Rule
@@ -50,7 +50,7 @@ class NameResolutionTest {
private fun doTest() {
val methodName = testName.methodName
val baseName = "${BasicWasmBoxTest.TEST_DATA_DIR_PATH}/js-name-resolution/"
val baseName = "${TEST_DATA_DIR_PATH}/js-name-resolution/"
val originalName = "$baseName/$methodName.original.js"
val expectedName = "$baseName/$methodName.expected.js"
@@ -1,85 +0,0 @@
/*
* Copyright 2010-2019 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.engines
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader
import java.lang.Boolean.getBoolean
import kotlin.test.fail
private val toolLogsEnabled: Boolean = getBoolean("kotlin.js.test.verbose")
internal sealed class WasmVM(val shortName: String) {
val name: String = javaClass.simpleName
protected val tool = ExternalTool(System.getProperty("javascript.engine.path.$name"))
abstract fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?)
object V8 : WasmVM("V8") {
override fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?) {
tool.run(
"--experimental-wasm-gc",
*jsFilesBefore.toTypedArray(),
"--module",
entryMjs,
*jsFilesAfter.toTypedArray(),
workingDirectory = workingDirectory
)
}
}
object SpiderMonkey : WasmVM("SM") {
override fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?) {
tool.run(
"--wasm-verbose",
"--wasm-gc",
"--wasm-function-references",
*jsFilesBefore.flatMap { listOf("-f", it) }.toTypedArray(),
"--module=$entryMjs",
*jsFilesAfter.flatMap { listOf("-f", it) }.toTypedArray(),
workingDirectory = workingDirectory
)
}
}
}
internal class ExternalTool(val path: String) {
fun run(vararg arguments: String, workingDirectory: File? = null) {
val command = arrayOf(path, *arguments)
val processBuilder = ProcessBuilder(*command).redirectErrorStream(true)
if (workingDirectory != null) {
processBuilder.directory(workingDirectory)
}
val process = processBuilder.start()
val commandString = command.joinToString(" ") { escapeShellArgument(it) }
if (toolLogsEnabled) {
println(
if (workingDirectory != null) {
"(cd '$workingDirectory' && $commandString)"
} else {
commandString
}
)
}
// Print process output
val input = BufferedReader(InputStreamReader(process.inputStream))
while (true) println(input.readLine() ?: break)
val exitValue = process.waitFor()
if (exitValue != 0) {
fail("Command \"$commandString\" terminated with exit code $exitValue")
}
}
}
private fun escapeShellArgument(arg: String): String =
"'${arg.replace("'", "'\\''")}'"
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.js.backend.ast.*
import org.jetbrains.kotlin.js.backend.ast.metadata.synthetic
import org.jetbrains.kotlin.js.inline.clean.FunctionPostProcessor
import org.jetbrains.kotlin.js.parser.parse
import org.jetbrains.kotlin.js.testOld.BasicWasmBoxTest
import org.jetbrains.kotlin.js.testOld.TEST_DATA_DIR_PATH
import org.jetbrains.kotlin.js.testOld.createScriptEngine
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.js.util.TextOutputImpl
@@ -29,7 +29,7 @@ abstract class BasicOptimizerTest(private var basePath: String) {
protected fun box() {
val methodName = testName.methodName
val baseName = "${BasicWasmBoxTest.TEST_DATA_DIR_PATH}/js-optimizer/$basePath"
val baseName = "${TEST_DATA_DIR_PATH}/js-optimizer/$basePath"
val unoptimizedName = "$baseName/$methodName.original.js"
val optimizedName = "$baseName/$methodName.optimized.js"
@@ -1,34 +0,0 @@
/*
* Copyright 2010-2019 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 org.jetbrains.kotlin.js.testOld.BasicWasmBoxTest
abstract class AbstractIrCodegenBoxWasmTest : BasicWasmBoxTest(
"compiler/testData/codegen/box/",
"codegen/wasmBox/"
)
abstract class AbstractIrCodegenBoxInlineWasmTest : BasicWasmBoxTest(
"compiler/testData/codegen/boxInline/",
"codegen/wasmBoxInline/"
)
abstract class AbstractIrCodegenWasmJsInteropWasmTest : BasicWasmBoxTest(
"compiler/testData/codegen/wasmJsInterop",
"codegen/wasmJsInteropJs"
)
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
)
@@ -1,127 +0,0 @@
/*
* Copyright 2010-2023 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.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWasmJsInterop")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IrCodegenWasmJsInteropWasmTestGenerated extends AbstractIrCodegenWasmJsInteropWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInBoxWasmJsInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxWasmJsInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("callingWasmDirectly.kt")
public void testCallingWasmDirectly() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/callingWasmDirectly.kt");
}
@TestMetadata("defaultValues.kt")
public void testDefaultValues() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/defaultValues.kt");
}
@TestMetadata("externalTypeOperators.kt")
public void testExternalTypeOperators() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt");
}
@TestMetadata("externals.kt")
public void testExternals() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externals.kt");
}
@TestMetadata("functionTypes.kt")
public void testFunctionTypes() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/functionTypes.kt");
}
@TestMetadata("imperativeWrapperInitialised.kt")
public void testImperativeWrapperInitialised() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/imperativeWrapperInitialised.kt");
}
@TestMetadata("imperativeWrapperUninitialised.kt")
public void testImperativeWrapperUninitialised() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/imperativeWrapperUninitialised.kt");
}
@TestMetadata("jsExport.kt")
public void testJsExport() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsExport.kt");
}
@TestMetadata("jsModule.kt")
public void testJsModule() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsModule.kt");
}
@TestMetadata("jsModuleWithQualifier.kt")
public void testJsModuleWithQualifier() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsModuleWithQualifier.kt");
}
@TestMetadata("jsQualifier.kt")
public void testJsQualifier() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsQualifier.kt");
}
@TestMetadata("jsToKotlinAdapters.kt")
public void testJsToKotlinAdapters() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsToKotlinAdapters.kt");
}
@TestMetadata("kotlinToJsAdapters.kt")
public void testKotlinToJsAdapters() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/kotlinToJsAdapters.kt");
}
@TestMetadata("longStrings.kt")
public void testLongStrings() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
}
@TestMetadata("nameClash.kt")
public void testNameClash() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/nameClash.kt");
}
@TestMetadata("nullableExternRefs.kt")
public void testNullableExternRefs() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/nullableExternRefs.kt");
}
@TestMetadata("types.kt")
public void testTypes() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/types.kt");
}
@TestMetadata("vararg.kt")
public void testVararg() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/vararg.kt");
}
@TestMetadata("wasmImport.kt")
public void testWasmImport() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/wasmImport.kt");
}
}
@@ -1,77 +0,0 @@
/*
* Copyright 2010-2023 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.GenerateJsTestsKt}. 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");
}
}
@@ -1,366 +0,0 @@
/*
* Copyright 2010-2023 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.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@RunWith(JUnit3RunnerWithInners.class)
public class JsTranslatorWasmTestGenerated extends AbstractJsTranslatorWasmTest {
@TestMetadata("js/js.translator/testData/box/main")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Main extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInMain() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/main"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("differentMains.kt")
public void testDifferentMains() throws Exception {
runTest("js/js.translator/testData/box/main/differentMains.kt");
}
@TestMetadata("incremental.kt")
public void testIncremental() throws Exception {
runTest("js/js.translator/testData/box/main/incremental.kt");
}
@TestMetadata("noArgs.kt")
public void testNoArgs() throws Exception {
runTest("js/js.translator/testData/box/main/noArgs.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/main/simple.kt");
}
@TestMetadata("suspendMain.kt")
public void testSuspendMain() throws Exception {
runTest("js/js.translator/testData/box/main/suspendMain.kt");
}
@TestMetadata("suspendMainNoArgs.kt")
public void testSuspendMainNoArgs() throws Exception {
runTest("js/js.translator/testData/box/main/suspendMainNoArgs.kt");
}
@TestMetadata("suspendMainThrows.kt")
public void testSuspendMainThrows() throws Exception {
runTest("js/js.translator/testData/box/main/suspendMainThrows.kt");
}
@TestMetadata("twoMains.kt")
public void testTwoMains() throws Exception {
runTest("js/js.translator/testData/box/main/twoMains.kt");
}
}
@TestMetadata("js/js.translator/testData/box/native")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Native extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
@TestMetadata("accessToCompanionObjectFromInlineFun.kt")
public void testAccessToCompanionObjectFromInlineFun() throws Exception {
runTest("js/js.translator/testData/box/native/accessToCompanionObjectFromInlineFun.kt");
}
public void testAllFilesPresentInNative() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/native"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("castToNativeClassChecked.kt")
public void testCastToNativeClassChecked() throws Exception {
runTest("js/js.translator/testData/box/native/castToNativeClassChecked.kt");
}
@TestMetadata("castToNativeInterface.kt")
public void testCastToNativeInterface() throws Exception {
runTest("js/js.translator/testData/box/native/castToNativeInterface.kt");
}
@TestMetadata("castToNativeInterfaceChecked.kt")
public void testCastToNativeInterfaceChecked() throws Exception {
runTest("js/js.translator/testData/box/native/castToNativeInterfaceChecked.kt");
}
@TestMetadata("castToNullableNativeInterface.kt")
public void testCastToNullableNativeInterface() throws Exception {
runTest("js/js.translator/testData/box/native/castToNullableNativeInterface.kt");
}
@TestMetadata("castToTypeParamBoundedByNativeInterface.kt")
public void testCastToTypeParamBoundedByNativeInterface() throws Exception {
runTest("js/js.translator/testData/box/native/castToTypeParamBoundedByNativeInterface.kt");
}
@TestMetadata("class.kt")
public void testClass() throws Exception {
runTest("js/js.translator/testData/box/native/class.kt");
}
@TestMetadata("classObject.kt")
public void testClassObject() throws Exception {
runTest("js/js.translator/testData/box/native/classObject.kt");
}
@TestMetadata("externalValWithOverridenVar.kt")
public void testExternalValWithOverridenVar() throws Exception {
runTest("js/js.translator/testData/box/native/externalValWithOverridenVar.kt");
}
@TestMetadata("kt2209.kt")
public void testKt2209() throws Exception {
runTest("js/js.translator/testData/box/native/kt2209.kt");
}
@TestMetadata("nestedElements.kt")
public void testNestedElements() throws Exception {
runTest("js/js.translator/testData/box/native/nestedElements.kt");
}
@TestMetadata("objectFunWithVararg.kt")
public void testObjectFunWithVararg() throws Exception {
runTest("js/js.translator/testData/box/native/objectFunWithVararg.kt");
}
@TestMetadata("passExtLambdaToNative.kt")
public void testPassExtLambdaToNative() throws Exception {
runTest("js/js.translator/testData/box/native/passExtLambdaToNative.kt");
}
@TestMetadata("passMemberOrExtFromNative.kt")
public void testPassMemberOrExtFromNative() throws Exception {
runTest("js/js.translator/testData/box/native/passMemberOrExtFromNative.kt");
}
@TestMetadata("passMemberOrExtToNative.kt")
public void testPassMemberOrExtToNative() throws Exception {
runTest("js/js.translator/testData/box/native/passMemberOrExtToNative.kt");
}
@TestMetadata("passTopLevelFunctionFromNative.kt")
public void testPassTopLevelFunctionFromNative() throws Exception {
runTest("js/js.translator/testData/box/native/passTopLevelFunctionFromNative.kt");
}
@TestMetadata("passTopLevelOrLocalFunctionToNative.kt")
public void testPassTopLevelOrLocalFunctionToNative() throws Exception {
runTest("js/js.translator/testData/box/native/passTopLevelOrLocalFunctionToNative.kt");
}
@TestMetadata("privateExternal.kt")
public void testPrivateExternal() throws Exception {
runTest("js/js.translator/testData/box/native/privateExternal.kt");
}
@TestMetadata("safeCastToNativeInterface.kt")
public void testSafeCastToNativeInterface() throws Exception {
runTest("js/js.translator/testData/box/native/safeCastToNativeInterface.kt");
}
@TestMetadata("secondaryConstructor.kt")
public void testSecondaryConstructor() throws Exception {
runTest("js/js.translator/testData/box/native/secondaryConstructor.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/native/simple.kt");
}
@TestMetadata("simpleUndefined.kt")
public void testSimpleUndefined() throws Exception {
runTest("js/js.translator/testData/box/native/simpleUndefined.kt");
}
@TestMetadata("useClassFromInlineFun.kt")
public void testUseClassFromInlineFun() throws Exception {
runTest("js/js.translator/testData/box/native/useClassFromInlineFun.kt");
}
@TestMetadata("vararg.kt")
public void testVararg() throws Exception {
runTest("js/js.translator/testData/box/native/vararg.kt");
}
}
@TestMetadata("js/js.translator/testData/box/esModules")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class EsModules extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInEsModules() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true, "jsExport", "native", "export", "crossModuleRef", "crossModuleRefPerFile", "crossModuleRefPerModule");
}
@TestMetadata("js/js.translator/testData/box/esModules/incremental")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Incremental extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInIncremental() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("jsModule.kt")
public void testJsModule() throws Exception {
runTest("js/js.translator/testData/box/esModules/incremental/jsModule.kt");
}
}
@TestMetadata("js/js.translator/testData/box/esModules/inline")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Inline extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInInline() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
}
@TestMetadata("js/js.translator/testData/box/esModules/jsModule")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JsModule extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInJsModule() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("externalClass.kt")
public void testExternalClass() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalClass.kt");
}
@TestMetadata("externalClassNameClash.kt")
public void testExternalClassNameClash() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalClassNameClash.kt");
}
@TestMetadata("externalFunction.kt")
public void testExternalFunction() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunction.kt");
}
@TestMetadata("externalFunctionNameClash.kt")
public void testExternalFunctionNameClash() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunctionNameClash.kt");
}
@TestMetadata("externalObject.kt")
public void testExternalObject() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalObject.kt");
}
@TestMetadata("externalPackage.kt")
public void testExternalPackage() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackage.kt");
}
@TestMetadata("externalPackageInDifferentFile.kt")
public void testExternalPackageInDifferentFile() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackageInDifferentFile.kt");
}
@TestMetadata("externalProperty.kt")
public void testExternalProperty() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/externalProperty.kt");
}
@TestMetadata("interfaces.kt")
public void testInterfaces() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/interfaces.kt");
}
@TestMetadata("topLevelVarargFun.kt")
public void testTopLevelVarargFun() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsModule/topLevelVarargFun.kt");
}
}
@TestMetadata("js/js.translator/testData/box/esModules/jsName")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JsName extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInJsName() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("defaultJsName.kt")
public void testDefaultJsName() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsName/defaultJsName.kt");
}
@TestMetadata("jsTopLevelClashes.kt")
public void testJsTopLevelClashes() throws Exception {
runTest("js/js.translator/testData/box/esModules/jsName/jsTopLevelClashes.kt");
}
}
}
@TestMetadata("js/js.translator/testData/box/jsQualifier")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JsQualifier extends AbstractJsTranslatorWasmTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
public void testAllFilesPresentInJsQualifier() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/jsQualifier"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("classes.kt")
public void testClasses() throws Exception {
runTest("js/js.translator/testData/box/jsQualifier/classes.kt");
}
@TestMetadata("interfaces.kt")
public void testInterfaces() throws Exception {
runTest("js/js.translator/testData/box/jsQualifier/interfaces.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/jsQualifier/simple.kt");
}
}
}