JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.21k stars 1.17k forks source link

Gradle task build (allTests) fails on default web project generated by kmp.jetbrains.com #4607

Closed erikhuizinga closed 6 months ago

erikhuizinga commented 6 months ago

Describe the bug

When I run Gradle task build, eventually my build fails on the allTests task.

Gradle log:

``` 404: /absolute/var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/kotlin_skiko_mjs.js (error: /var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/kotlin_skiko_mjs.js) at __webpack_require__.f.j (/var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/runtime.js:292:29) at /var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/runtime.js:153:40 at Array.reduce () at __webpack_require__.e (/var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/runtime.js:152:67) at instantiate (~/pathToProject/build/js/packages/composeApp-test/kotlin/composeApp-test.uninstantiated.mjs:13:68 <- load.4156169130.js:47:88) at ~/pathToProject/build/js/packages/composeApp-test/kotlin/composeApp-test.mjs:3:34 <- load.4156169130.js:18:153 at __webpack_require__.a (/var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/runtime.js:83:13) at ./kotlin/composeApp-test.mjs (load.4156169130.js:10:21) at Function.__webpack_require__ (/var/folders/wr/cwkk1nld4yx87g2y0g152vqr0000gp/T/_karma_webpack_864859/runtime.js:23:41) java.lang.IllegalStateException: command '~/.gradle/nodejs/node-v18.12.1-darwin-arm64/bin/node' exited with errors (exit code: 1) > Task :composeApp:wasmJsTest > Task :composeApp:allTests FAILED ```

Affected platforms At least web (K/Wasm) - Canvas based API.

But in my private project I target Android, iOS, JS, Wasm and JVM.

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Generate a KMP project on https://kmp.jetbrains.com/ , check only the web target.
  2. Open the project in Android Studio Hedgehog | 2023.1.1 Patch 2 or Android Studio Iguana | 2023.2.1 Patch 2.
  3. In composeApp/build.gradle.kts add a line: kotlin { sourceSets { commonTest.dependencies { implementation(libs.kotlin.test) } } }
  4. Add a new file: composeApp/src/commonTest/kotlin/ExampleTest.kt containing:
    
    import kotlin.test.Test
    import kotlin.test.assertTrue

class ExampleTest { @Test fun test1() = assertTrue(false) // Note that this test deliberately should fail, just to check that tests run properly }

6. Run Gradle task `allTests`.
7. Note the failure as seen in the details above.

**Expected behavior**

The project builds and the tests run. In the example test above it's expected that 1 out of 1 test fails.

**Content of gradle/libs.versions.toml**

<details>

```toml
[versions]
compose = "1.6.2"
compose-plugin = "1.6.0"
junit = "4.13.2"
kotlin = "1.9.22"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }

[plugins]
jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }

erikhuizinga commented 6 months ago

I tried upgrading

compose = "1.6.4"
compose-plugin = "1.6.2"
kotlin = "1.9.23"

but no luck.

I tried rm -rf ~/.gradle/nodejs and running allTests again but no luck.

terrakok commented 6 months ago

It is a Kotlin issue. I filed it here: https://youtrack.jetbrains.com/issue/KT-67468

erikhuizinga commented 6 months ago

Thank you Konstantin.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.