[Wasm] Test infra: support _commonFiles and additional .mjs
Use custom `evalToBoolean` as `eval` and `unsafeCast` are not available in Wasm stdlib
This commit is contained in:
committed by
Space Team
parent
80e07d628b
commit
fd67464d14
@@ -47,6 +47,7 @@ abstract class BasicWasmBoxTest(
|
||||
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,
|
||||
@@ -98,11 +99,18 @@ abstract class BasicWasmBoxTest(
|
||||
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 allSourceFiles = kotlinFiles + localCommonFiles
|
||||
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)
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
package testUtils
|
||||
|
||||
@JsName("eval")
|
||||
private external fun evalToBoolean(code: String): Boolean
|
||||
|
||||
fun isLegacyBackend(): Boolean =
|
||||
// Using eval to prevent DCE from thinking that following code depends on Kotlin module.
|
||||
eval("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")").unsafeCast<Boolean>()
|
||||
evalToBoolean("(typeof Kotlin != \"undefined\" && typeof Kotlin.kotlin != \"undefined\")")
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// EXPECTED_REACHABLE_NODES: 1285
|
||||
package foo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user