diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/MasterPluginVersionGradleImportingTestCase.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/MasterPluginVersionGradleImportingTestCase.kt new file mode 100644 index 00000000000..0433c7a64b8 --- /dev/null +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/MasterPluginVersionGradleImportingTestCase.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2020 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. + */ + +/** + * This TestCase implements possibility to test import with different versions of gradle and master + * version of gradle kotlin plugin + */ +package org.jetbrains.kotlin.idea.codeInsight.gradle + +import org.junit.runners.Parameterized + +abstract class MasterPluginVersionGradleImportingTestCase : MultiplePluginVersionGradleImportingTestCase() { + + companion object { + @JvmStatic + @Parameterized.Parameters(name = "{index}: Gradle-{0}, KotlinGradlePlugin-{1}") + fun data(): Collection> { + return (AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS).map { gradleVersion -> + arrayOf( + gradleVersion[0], + LATEST_SUPPORTED_VERSION + ) + }.toList() + } + } +} + diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/NativeRunConfigurationTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/NativeRunConfigurationTest.kt index 1c0605f32ba..348d61429e6 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/NativeRunConfigurationTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/NativeRunConfigurationTest.kt @@ -9,49 +9,28 @@ import com.intellij.codeInsight.daemon.LineMarkerInfo import com.intellij.execution.PsiLocation import com.intellij.execution.actions.ConfigurationContext import com.intellij.execution.actions.ConfigurationFromContext -import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.gradle.GradleDaemonAnalyzerTestCase import org.jetbrains.kotlin.test.TagsTestDataUtil import org.jetbrains.plugins.gradle.service.execution.GradleRunConfiguration +import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions import org.junit.Test -import org.junit.runners.Parameterized -import java.net.URL -import java.util.* -class NativeRunConfigurationTest : GradleImportingTestCase() { - private companion object { - private const val DEFAULT_PLUGIN_VERSION = "1.4-M2" - private val latestPluginVersion by lazy { - PluginVersionDownloader.getLatestDevVersion() ?: DEFAULT_PLUGIN_VERSION - } - - @JvmStatic - @Parameterized.Parameters(name = "{index}: Gradle-{0}, KotlinGradlePlugin-{1}") - fun data(): Collection> = listOf(arrayOf("6.0.1", latestPluginVersion)) - } +class NativeRunConfigurationTest : MasterPluginVersionGradleImportingTestCase() { override fun testDataDirName(): String = "nativeRunConfiguration" - @JvmField - @Parameterized.Parameter(1) - var kotlinGradlePluginVersion: String = DEFAULT_PLUGIN_VERSION - @Test + @TargetVersions("6.0+") fun multiplatformNativeRunGutter() { doTest() } @Test + @TargetVersions("6.0+") fun customEntryPointWithoutRunGutter() { doTest() } - override fun configureByFiles(properties: Map?): List { - val unitedProperties = HashMap(properties ?: emptyMap()) - unitedProperties["kotlin_plugin_version"] = kotlinGradlePluginVersion - return super.configureByFiles(unitedProperties) - } - private fun doTest() { val files = importProjectFromTestData() val project = myTestFixture.project @@ -84,20 +63,4 @@ class NativeRunConfigurationTest : GradleImportingTestCase() { val emptyContext = ConfigurationContext.createEmptyContextForLocation(location) return emptyContext.configurationsFromContext.orEmpty() } -} - -object PluginVersionDownloader { - fun getLatestEapVersion() = downloadVersions(EAP_URL).lastOrNull() - fun getLatestDevVersion() = downloadVersions(DEV_URL).lastOrNull() - - private fun downloadVersions(url: String): List { - return versionRegexp.findAll(URL(url).readText()) - .map { it.groupValues[1].removeSuffix("/") } - .filter { it.isNotEmpty() && it[0].isDigit() } - .toList() - } - - private const val EAP_URL = "https://dl.bintray.com/kotlin/kotlin-eap/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/" - private const val DEV_URL = "https://dl.bintray.com/kotlin/kotlin-dev/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/" - private val versionRegexp = """href="([^"\\]+)"""".toRegex() } \ No newline at end of file