[Wasm] Stop supporting "_export.js" in test infra, use import/export capability in relevant tests
* It works slightly differently in SpiderMonkey. * It was a hack.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
// Char issues
|
// Char issues
|
||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// WASM_FAILS_IN: SM
|
|
||||||
|
|
||||||
// MODULE: main
|
// MODULE: main
|
||||||
// FILE: externals.js
|
// FILE: externals.js
|
||||||
@@ -241,16 +240,15 @@ fun box(): String {
|
|||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rewrite test to use module system
|
// FILE: entry.mjs
|
||||||
fun hackNonModuleExport() {
|
|
||||||
js("globalThis.main = wasmExports;")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
import main from "./index.mjs"
|
||||||
hackNonModuleExport()
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: functionTypes__after.js
|
const boxResult = main.box();
|
||||||
|
|
||||||
|
if (boxResult != "OK") {
|
||||||
|
throw `Wrong box result '${boxResult}'; Expected "OK"`;
|
||||||
|
}
|
||||||
|
|
||||||
const exportedFres = main.exportedF()(1, 20, 300)("<", ">");
|
const exportedFres = main.exportedF()(1, 20, 300)("<", ">");
|
||||||
if (exportedFres !== "<321>")
|
if (exportedFres !== "<321>")
|
||||||
|
|||||||
+2
-11
@@ -1,4 +1,3 @@
|
|||||||
// WASM_FAILS_IN: SM
|
|
||||||
// MODULE: main
|
// MODULE: main
|
||||||
// FILE: externals.kt
|
// FILE: externals.kt
|
||||||
|
|
||||||
@@ -26,17 +25,9 @@ fun anyAsEI(any: Any): EI = any as EI
|
|||||||
|
|
||||||
fun box(): String = "OK"
|
fun box(): String = "OK"
|
||||||
|
|
||||||
// TODO: Rewrite test to use module system
|
// FILE: entry.mjs
|
||||||
|
|
||||||
fun hackNonModuleExport() {
|
import main from "./index.mjs"
|
||||||
js("globalThis.main = wasmExports;")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
hackNonModuleExport()
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILE: jsExport__after.js
|
|
||||||
|
|
||||||
const c = main.makeC(300);
|
const c = main.makeC(300);
|
||||||
if (main.getX(c) !== 300) {
|
if (main.getX(c) !== 300) {
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ abstract class BasicWasmBoxTest(
|
|||||||
val languageVersionSettings = inputFiles.firstNotNullOfOrNull { it.languageVersionSettings }
|
val languageVersionSettings = inputFiles.firstNotNullOfOrNull { it.languageVersionSettings }
|
||||||
|
|
||||||
val kotlinFiles = mutableListOf<String>()
|
val kotlinFiles = mutableListOf<String>()
|
||||||
val jsFilesBefore = mutableListOf<String>()
|
val jsFiles = mutableListOf<String>()
|
||||||
val jsFilesAfter = mutableListOf<String>()
|
|
||||||
val mjsFiles = mutableListOf<String>()
|
val mjsFiles = mutableListOf<String>()
|
||||||
|
|
||||||
var entryMjs: String? = "test.mjs"
|
var entryMjs: String? = "test.mjs"
|
||||||
@@ -80,11 +79,8 @@ abstract class BasicWasmBoxTest(
|
|||||||
name.endsWith(".kt") ->
|
name.endsWith(".kt") ->
|
||||||
kotlinFiles += name
|
kotlinFiles += name
|
||||||
|
|
||||||
name.endsWith("__after.js") ->
|
|
||||||
jsFilesAfter += name
|
|
||||||
|
|
||||||
name.endsWith(".js") ->
|
name.endsWith(".js") ->
|
||||||
jsFilesBefore += name
|
jsFiles += name
|
||||||
|
|
||||||
name.endsWith(".mjs") -> {
|
name.endsWith(".mjs") -> {
|
||||||
mjsFiles += name
|
mjsFiles += name
|
||||||
@@ -98,7 +94,7 @@ abstract class BasicWasmBoxTest(
|
|||||||
|
|
||||||
val additionalJsFile = filePath.removeSuffix(".kt") + ".js"
|
val additionalJsFile = filePath.removeSuffix(".kt") + ".js"
|
||||||
if (File(additionalJsFile).exists()) {
|
if (File(additionalJsFile).exists()) {
|
||||||
jsFilesBefore += additionalJsFile
|
jsFiles += additionalJsFile
|
||||||
}
|
}
|
||||||
val additionalMjsFile = filePath.removeSuffix(".kt") + ".mjs"
|
val additionalMjsFile = filePath.removeSuffix(".kt") + ".mjs"
|
||||||
if (File(additionalMjsFile).exists()) {
|
if (File(additionalMjsFile).exists()) {
|
||||||
@@ -260,8 +256,7 @@ abstract class BasicWasmBoxTest(
|
|||||||
}
|
}
|
||||||
vm.run(
|
vm.run(
|
||||||
"./${entryMjs}",
|
"./${entryMjs}",
|
||||||
jsFilesBefore.map { File(it).absolutePath },
|
jsFiles.map { File(it).absolutePath },
|
||||||
jsFilesAfter.map { File(it).absolutePath },
|
|
||||||
workingDirectory = dir
|
workingDirectory = dir
|
||||||
)
|
)
|
||||||
if (vm.shortName in failsIn) {
|
if (vm.shortName in failsIn) {
|
||||||
|
|||||||
@@ -17,30 +17,28 @@ internal sealed class WasmVM(val shortName: String) {
|
|||||||
val name: String = javaClass.simpleName
|
val name: String = javaClass.simpleName
|
||||||
protected val tool = ExternalTool(System.getProperty("javascript.engine.path.$name"))
|
protected val tool = ExternalTool(System.getProperty("javascript.engine.path.$name"))
|
||||||
|
|
||||||
abstract fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?)
|
abstract fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?)
|
||||||
|
|
||||||
object V8 : WasmVM("V8") {
|
object V8 : WasmVM("V8") {
|
||||||
override fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?) {
|
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?) {
|
||||||
tool.run(
|
tool.run(
|
||||||
"--experimental-wasm-gc",
|
"--experimental-wasm-gc",
|
||||||
*jsFilesBefore.toTypedArray(),
|
*jsFiles.toTypedArray(),
|
||||||
"--module",
|
"--module",
|
||||||
entryMjs,
|
entryMjs,
|
||||||
*jsFilesAfter.toTypedArray(),
|
|
||||||
workingDirectory = workingDirectory
|
workingDirectory = workingDirectory
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object SpiderMonkey : WasmVM("SM") {
|
object SpiderMonkey : WasmVM("SM") {
|
||||||
override fun run(entryMjs: String, jsFilesBefore: List<String>, jsFilesAfter: List<String>, workingDirectory: File?) {
|
override fun run(entryMjs: String, jsFiles: List<String>, workingDirectory: File?) {
|
||||||
tool.run(
|
tool.run(
|
||||||
"--wasm-verbose",
|
"--wasm-verbose",
|
||||||
"--wasm-gc",
|
"--wasm-gc",
|
||||||
"--wasm-function-references",
|
"--wasm-function-references",
|
||||||
*jsFilesBefore.flatMap { listOf("-f", it) }.toTypedArray(),
|
*jsFiles.flatMap { listOf("-f", it) }.toTypedArray(),
|
||||||
"--module=$entryMjs",
|
"--module=$entryMjs",
|
||||||
*jsFilesAfter.flatMap { listOf("-f", it) }.toTypedArray(),
|
|
||||||
workingDirectory = workingDirectory
|
workingDirectory = workingDirectory
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user