From 86540bdbb4b0dc8cb450b90b3e72a4f0b3717ba1 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Wed, 12 Apr 2023 17:35:25 +0200 Subject: [PATCH] [Gradle] Fix flaky test Commonizer may run first and produce compiler arguments output as well in test output. --- .../org/jetbrains/kotlin/gradle/CompilerOptionsIT.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CompilerOptionsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CompilerOptionsIT.kt index e54eb7f37a0..0aa2d480e36 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CompilerOptionsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/CompilerOptionsIT.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments import org.jetbrains.kotlin.gradle.testbase.* import org.jetbrains.kotlin.gradle.util.parseCompilerArguments +import org.jetbrains.kotlin.gradle.util.parseCompilerArgumentsFromBuildOutput import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.fail import kotlin.io.path.appendText @@ -223,7 +224,10 @@ internal class CompilerOptionsIT : KGPBaseTest() { fun combinesOptInFromLanguageSettingsNative(gradleVersion: GradleVersion) { project( projectName = "new-mpp-lib-and-app/sample-lib", - gradleVersion = gradleVersion + gradleVersion = gradleVersion, + // We need to get specific task output as commonizer may run first producing + // arguments as well in output + buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG) ) { buildGradle.appendText( //language=Groovy @@ -251,7 +255,8 @@ internal class CompilerOptionsIT : KGPBaseTest() { build("compileNativeMainKotlinMetadata") { assertTasksExecuted(":compileNativeMainKotlinMetadata") - val arguments = parseCompilerArguments() + val taskOutput = getOutputForTask("compileNativeMainKotlinMetadata") + val arguments = parseCompilerArgumentsFromBuildOutput(K2NativeCompilerArguments::class, taskOutput) assertEquals( setOf("another.custom.UnderOptIn", "my.custom.OptInAnnotation"), arguments.optIn?.toSet(), "Arguments optIn does not match '-opt-in=another.custom.UnderOptIn, -opt-in=my.custom.OptInAnnotation'" @@ -260,7 +265,8 @@ internal class CompilerOptionsIT : KGPBaseTest() { build("compileKotlinLinux64") { assertTasksExecuted(":compileKotlinLinux64") - val arguments = parseCompilerArguments() + val taskOutput = getOutputForTask("compileKotlinLinux64") + val arguments = parseCompilerArgumentsFromBuildOutput(K2NativeCompilerArguments::class, taskOutput) assertEquals( setOf("another.custom.UnderOptIn", "my.custom.OptInAnnotation"), arguments.optIn?.toSet(), "Arguments optIn does not match '-opt-in=another.custom.UnderOptIn, -opt-in=my.custom.OptInAnnotation'"