From 857f704a0965c1c464eb320f63cf14fb10995bde Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Thu, 1 Dec 2022 20:23:59 +0100 Subject: [PATCH] [Gradle] Add test for KT-54634 --- .../jetbrains/kotlin/gradle/mpp/MppTestsIT.kt | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppTestsIT.kt diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppTestsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppTestsIT.kt new file mode 100644 index 00000000000..f17aabae202 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/mpp/MppTestsIT.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.gradle.mpp + +import org.gradle.api.logging.configuration.WarningMode +import org.gradle.util.GradleVersion +import org.jetbrains.kotlin.gradle.native.MPPNativeTargets +import org.jetbrains.kotlin.gradle.testbase.* +import org.junit.jupiter.api.DisplayName + +@MppGradlePluginTests +@DisplayName("Tests for multiplatform testing") +class MppTestsIT : KGPBaseTest() { + @DisplayName("KT-54634: MPP testing logic is compatible with API changes in Gradle 7.6") + // TODO: move 7.6 version to additional versions once max supported version will be 7.6 or higher + @GradleTestVersions(maxVersion = TestVersions.Gradle.G_7_6, additionalVersions = [TestVersions.Gradle.G_7_5]) + @GradleTest + fun testKt54634(gradleVersion: GradleVersion) { + project( + "new-mpp-lib-with-tests", + gradleVersion, + buildOptions = defaultBuildOptions.copy( + warningMode = WarningMode.None, // some APIs were deprecated, remove this later + freeArgs = listOf("--continue"), // to ensure that all the tests are run + ) + ) { + val nativeTarget = MPPNativeTargets.current + + build(":allTests") { + assertTasksExecuted( + ":jsNodeTest", + ":jvmWithoutJavaTest", + ":${nativeTarget}Test" + ) + } + + // break all the test tasks + kotlinSourcesDir("commonTest").resolve("TestCommonCode.kt").modify { + it.replace("expectedFun()", "assertEquals(0, 1)") + } + buildAndFail(":allTests") { + assertTasksFailed( + ":jsNodeTest", + ":jvmWithoutJavaTest", + ":${nativeTarget}Test" + ) + assertOutputDoesNotContain("does not define or inherit an implementation of the resolved method") + assertOutputDoesNotContain("NoSuchMethodError") + assertOutputContainsExactlyTimes("AssertionError:", 3) + } + } + } +} \ No newline at end of file