Repository: JetBrains/compose-multiplatform
File: html/compose-compiler-integration/build.gradle.kts (Kotlin)

Code before:
        if (!gradlewFile.canExecute()) {
            val isExecutable = gradlewFile.setExecutable(true)
            if (!isExecutable) {
                throw GradleException("Failed to make gradlew executable: ${gradlewFile.absolutePath}")
            }
        }
    }

    val command: List<String> = if (isWin) {
        listOf("cmd", "/c", "gradlew.bat") + arguments
    } else {
        listOf("./gradlew") + arguments
    }
    println("[compose-compiler-integration] Executing: ${command.joinToString(" ")}")

    val proc = try {
        ProcessBuilder(command)
            .directory(directory)
            .redirectOutput(ProcessBuilder.Redirect.INHERIT)
            .redirectError(ProcessBuilder.Redirect.INHERIT)
            .start()
    } catch (e: Exception) {
        throw GradleException("Failed to start Gradle process. Command: ${command.joinToString(" ")}", e)
    }

    val finished = proc.waitFor(5, TimeUnit.MINUTES)
    if (!finished) {
        proc.destroyForcibly()
        throw GradleException("Gradle process timed out for $caseName. Command: ${command.joinToString(" ")}")
    }

    // If process printed the version marker, it will already be in the console; still try to extract from stdout if available
    // Can't read inputStream when inherited; attempt only if available
    try {
        val out = proc.inputStream?.bufferedReader()?.readText()
        if (out != null) {
            "(COMPOSE_INTEGRATION_VERSION=\\[.*\\])".toRegex().find(out)?.also {
                println(it.groupValues[1])
            }
        }
    } catch (_: Throwable) {
        // ignored — streams may be redirected
    }

    if (proc.exitValue() != 0 && !failureExpected) {
        throw GradleException("Error compiling $caseName (exit code ${proc.exitValue()})")
    }

    if (failureExpected && proc.exitValue() == 0) {
        throw AssertionError("$caseName compilation did not fail!!!")
    }

Review comment (bug):
I still have this task failed on Windows:
```
D:\Work\compose-multiplatform\html>gradlew checkComposeCases -Pcompose.version=1.10.0+dev2995
[build] compose core version: 1.10.0+dev2995

> Configure project :buildSrc
Writing kotlin.version=2.2.10 into D:\Work\compose-multiplatform\html\buildSrc\build\kotlin.version

> Task :compose-compiler-integration:checkComposeCases
Running check for MutableStateDestructuringDeclarartion.kt, expectCompilationError = true, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-MutableStateDestructuringDeclarartion.kt
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for CompanionGetValueOperatorComposable.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-CompanionGetValueOperatorComposable.kt
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for ComposableWithDefaultValuesDefinedByOtherParams.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-ComposableWithDefaultValuesDefinedByOtherParams.kt
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for ComposableWithNullableTypeParameter.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-ComposableWithNullableTypeParameter.kt
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for ComposableWithParamsWithDefaultValues.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-ComposableWithParamsWithDefaultValues.kt
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for ComposableWithTypedDefaultValues.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-ComposableWithTypedDefaultValues.kt                                                                                                     
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for ComposableWithTypeParams.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-ComposableWithTypeParams.kt                                                                                                             
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for InstanceGetValueOperatorComposable.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-InstanceGetValueOperatorComposable.kt                                                                                                   
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for PassingComposableToConstructor.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-PassingComposableToConstructor.kt                                                                                                       
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
Running check for WithComposableBlockUsingTypeParameterAndDefaultValue.kt, expectCompilationError = false, composeVersion = 1.10.0+dev2995
[compose-compiler-integration] Working directory: D:\Work\compose-multiplatform\html\compose-compiler-integration\build\temp\cloned-WithComposableBlockUsingTypeParameterAndDefaultValue.kt                                                                                 
[compose-compiler-integration] Executing: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
MutableStateDestructuringDeclarartion.kt : org.gradle.api.GradleException: Gradle process timed out for MutableStateDestructuringDeclarartion.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
##teamcity[testStarted name='compileTestCase_MutableStateDestructuringDeclarartion.kt']
##teamcity[testFailed name='compileTestCase_MutableStateDestructuringDeclarartion.kt']
##teamcity[testFinished name='compileTestCase_MutableStateDestructuringDeclarartion.kt']
CompanionGetValueOperatorComposable.kt : org.gradle.api.GradleException: Gradle process timed out for CompanionGetValueOperatorComposable.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
ComposableWithDefaultValuesDefinedByOtherParams.kt : org.gradle.api.GradleException: Gradle process timed out for ComposableWithDefaultValuesDefinedByOtherParams.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
ComposableWithNullableTypeParameter.kt : org.gradle.api.GradleException: Gradle process timed out for ComposableWithNullableTypeParameter.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
ComposableWithParamsWithDefaultValues.kt : org.gradle.api.GradleException: Gradle process timed out for ComposableWithParamsWithDefaultValues.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
ComposableWithTypedDefaultValues.kt : org.gradle.api.GradleException: Gradle process timed out for ComposableWithTypedDefaultValues.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info 
ComposableWithTypeParams.kt : org.gradle.api.GradleException: Gradle process timed out for ComposableWithTypeParams.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
InstanceGetValueOperatorComposable.kt : org.gradle.api.GradleException: Gradle process timed out for InstanceGetValueOperatorComposable.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
PassingComposableToConstructor.kt : org.gradle.api.GradleException: Gradle process timed out for PassingComposableToConstructor.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info     
WithComposableBlockUsingTypeParameterAndDefaultValue.kt : org.gradle.api.GradleException: Gradle process timed out for WithComposableBlockUsingTypeParameterAndDefaultValue.kt. Command: cmd /c gradlew.bat build jsNodeDevelopmentRun -Pcompose.version=1.10.0+dev2995 -Pkotlin.version=2.2.10 --stacktrace --info
```

~~As I see, each `gradlew` call is very long. Maybe we should set `10` minutes?~~

It seems every test fails with timeout

Code after:
        if (!gradlewFile.canExecute()) {
            val isExecutable = gradlewFile.setExecutable(true)
            if (!isExecutable) {
                throw GradleException("Failed to make gradlew executable: ${gradlewFile.absolutePath}")
            }
        }
    }

    val command: List<String> = if (isWin) {
        listOf("cmd", "/c", "gradlew.bat") + arguments
    } else {
        listOf("./gradlew") + arguments
    }
    println("[compose-compiler-integration] Executing: ${command.joinToString(" ")}")

    val proc = try {
        ProcessBuilder(command)
            .directory(directory)
            .redirectOutput(ProcessBuilder.Redirect.INHERIT)
            .redirectError(ProcessBuilder.Redirect.INHERIT)
            .start()
    } catch (e: Exception) {
        throw GradleException("Failed to start Gradle process. Command: ${command.joinToString(" ")}", e)
    }

    val finished = proc.waitFor(10, TimeUnit.MINUTES)
    if (!finished) {
        proc.destroyForcibly()
        throw GradleException("Gradle process timed out for $caseName. Command: ${command.joinToString(" ")}")
    }

    if (proc.exitValue() != 0 && !failureExpected) {
        throw GradleException("Error compiling $caseName (exit code ${proc.exitValue()})")
    }

    if (failureExpected && proc.exitValue() == 0) {
        throw AssertionError("$caseName compilation did not fail!!!")
    }
}

data class RunChecksResult(
    val cases: Map<String, Throwable?>
) {
    val totalCount = cases.size
    val failedCount = cases.filter { it.value != null }.size
    val hasFailed = failedCount > 0

    fun printResults() {
        cases.forEach { (name, throwable) ->
            println(name + " : " + (throwable ?: "OK"))
        }