commit | 81072ac9b498c5fbe3d4e30b83a650723e1e0811 | [log] [tgz] |
---|---|---|
author | Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com> | Thu Feb 02 16:37:32 2023 +0000 |
committer | Space Team <noreply@jetbrains.team> | Thu Feb 02 16:37:32 2023 +0000 |
tree | faea2609e418f3da94abf3010307f6c745cce597 | |
parent | bc612fa1c62e1a3a2cca31b35401e77cb9a5fe69 [diff] |
[Wasm] Fix parsing D8 CLI arguments in kotlin.test `@JsFun("code")` is now executed inside a JS function which brings its `arguments` into the scope shadowing D8's CLI `arguments`. Accessing arguments through `globalThis` fixes the problem. Merge-request: KT-MR-8630 Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
diff --git a/libraries/kotlin.test/wasm/src/main/kotlin/kotlin/test/TeamcityAdapter.kt b/libraries/kotlin.test/wasm/src/main/kotlin/kotlin/test/TeamcityAdapter.kt index 51d3938..09ced3e 100644 --- a/libraries/kotlin.test/wasm/src/main/kotlin/kotlin/test/TeamcityAdapter.kt +++ b/libraries/kotlin.test/wasm/src/main/kotlin/kotlin/test/TeamcityAdapter.kt
@@ -9,7 +9,8 @@ import kotlin.math.abs import kotlin.js.* -@JsFun("() => (typeof arguments !== 'undefined' && typeof arguments.join !== 'undefined') ? arguments.join(' ') : '' ") +// Using 'globalThis.arguments' because 'arguments' can refer to current JS function arguments +@JsFun("() => globalThis.arguments?.join?.(' ') ?? ''") private external fun d8Arguments(): String @JsFun("() => (typeof process != 'undefined' && typeof process.argv != 'undefined') ? process.argv.slice(2).join(' ') : ''") private external fun nodeArguments(): String
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts index 5bb5f26..ddbd160 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/build.gradle.kts
@@ -32,7 +32,13 @@ kotlin { wasm { - <JsEngine>() + <JsEngine> { + testTask { + filter.apply { + excludeTest("WasmTest", "testShouldBeExcluded") + } + } + } <ApplyBinaryen> }
diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/src/wasmTest/kotlin/Test.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/src/wasmTest/kotlin/Test.kt index 6c14125..8f96d41 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/src/wasmTest/kotlin/Test.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-wasm-test/src/wasmTest/kotlin/Test.kt
@@ -27,4 +27,9 @@ @Test fun test6() = assertEquals(foo(), 3) } + + @Test + fun testShouldBeExcluded() { + error("This test should be excluded") + } } \ No newline at end of file