From 5511377c2cf1de79fb3dd95dc50debe01100197f Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Tue, 8 Nov 2022 23:04:45 +0100 Subject: [PATCH] [Wasm, tests] Cleanup and improvements in wasm test infra - Remove no longer necessary separate generation to run inside browsers - Generate index.html in DEBUG mode instead of SUPER_DEBUG - Print link to index.html using IDEA builtin server (0.0.0.0:63342) - Small improvements in generated index.html --- .../kotlin/js/testOld/BasicWasmBoxTest.kt | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testOld/BasicWasmBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testOld/BasicWasmBoxTest.kt index 0a8e5c90efd..87d79475b0b 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testOld/BasicWasmBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/testOld/BasicWasmBoxTest.kt @@ -173,14 +173,41 @@ abstract class BasicWasmBoxTest( val testJs = if (debugMode >= DebugMode.DEBUG) testJsVerbose else testJsQuiet - fun compileAndRunD8Test(name: String, res: WasmCompilerResult) { + fun writeToFilesAndRunD8Test(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 Wat file://$path/index.wat") + println(" ------ $name Wasm file://$path/index.wasm") 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") + + File(dir, "index.html").writeText( + """ + + + + UNKNOWN + + + + """.trimIndent() + ) } writeCompilationResult(res, dir) @@ -196,36 +223,8 @@ abstract class BasicWasmBoxTest( ) } - compileAndRunD8Test("d8", compilerResult) - compileAndRunD8Test("d8-dce", compilerResultWithDCE) - - if (debugMode >= DebugMode.SUPER_DEBUG) { - fun writeBrowserTest(name: String, res: WasmCompilerResult) { - val dir = File(outputDirBase, name) - writeCompilationResult(res, dir) - File(dir, "test.mjs").writeText(testJsVerbose) - File(dir, "index.html").writeText( - """ - - - - - - - """.trimIndent() - ) - val path = dir.absolutePath - println(" ------ $name WAT file://$path/index.wat") - println(" ------ $name WASM file://$path/index.wasm") - println(" ------ $name JS file://$path/index.mjs") - println(" ------ $name TEST file://$path/test.mjs") - println(" ------ $name HTML file://$path/index.html") - } - - writeBrowserTest("browser", compilerResult) - writeBrowserTest("browser-dce", compilerResultWithDCE) - } - + writeToFilesAndRunD8Test("d8", compilerResult) + writeToFilesAndRunD8Test("d8-dce", compilerResultWithDCE) } }