mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Kotlin] Added and fixed tests for updating Kotlin language version in Gradle projects
KTIJ-25700 GitOrigin-RevId: 11b65ac516b2e6836d6e5922b26a335dbf65c29c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
50e4931ee8
commit
f1b3b73d49
+56
-7
@@ -45,9 +45,51 @@ class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("4.7 <=> 6.0")
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateExistingLanguageVersion() {
|
||||
doTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateExistingLanguageVersionKts() {
|
||||
doTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateExistingLanguageVersionKMP() {
|
||||
doKMPTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateExistingLanguageVersionKMPKts() {
|
||||
doKMPTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateLanguageVersion() {
|
||||
doTest("Set module language version to 1.1")
|
||||
doTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateLanguageVersionKts() {
|
||||
doTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateLanguageVersionKMP() {
|
||||
doKMPTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@TargetVersions("7.0 <=> 9.0")
|
||||
fun testUpdateLanguageVersionKMPKts() {
|
||||
doKMPTest("Set module language version to 1.9")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,9 +113,16 @@ class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() {
|
||||
doTest("Add 'kotlin-reflect.jar' to the classpath")
|
||||
}
|
||||
|
||||
private fun doTest(intentionName: String) {
|
||||
val buildGradleVFile = createProjectSubFile("build.gradle", File(getTestDataDirectory(), "build.gradle").readText())
|
||||
val sourceVFile = createProjectSubFile("src/main/kotlin/src.kt", File(getTestDataDirectory(), "src.kt").readText())
|
||||
private fun doKMPTest(intentionName: String) = doTest(intentionName, "src/jvmMain/kotlin/src.kt")
|
||||
|
||||
private fun doTest(intentionName: String, srcFilePath: String = "src/main/kotlin/src.kt") {
|
||||
var gradleKtsFile = File(getTestDataDirectory(), "build.gradle.kts")
|
||||
val buildGradleVFile = if (gradleKtsFile.exists()) {
|
||||
createProjectSubFile("build.gradle.kts", gradleKtsFile.readText())
|
||||
} else {
|
||||
createProjectSubFile("build.gradle", File(getTestDataDirectory(), "build.gradle").readText())
|
||||
}
|
||||
val sourceVFile = createProjectSubFile(srcFilePath, File(getTestDataDirectory(), "src.kt").readText())
|
||||
importProject()
|
||||
runInEdtAndWait {
|
||||
codeInsightTestFixture.configureFromExistingVirtualFile(sourceVFile)
|
||||
@@ -84,11 +133,11 @@ class GradleUpdateConfigurationQuickFixTest : GradleImportingTestCase() {
|
||||
}
|
||||
|
||||
private fun checkResult(file: VirtualFile) {
|
||||
val expectedPath = File(getTestDataDirectory(), "build.gradle.after")
|
||||
val expectedPath = File(getTestDataDirectory(), file.name + ".after")
|
||||
val expectedContent = StringUtil.convertLineSeparators(expectedPath.readText())
|
||||
val actualContent = StringUtil.convertLineSeparators(LoadTextUtil.loadText(file).toString())
|
||||
if (actualContent != expectedContent) {
|
||||
throw FileComparisonFailedError("build.gradle doesn't match", expectedContent, actualContent, expectedPath.path)
|
||||
throw FileComparisonFailedError("${file.name} doesn't match", expectedContent, actualContent, expectedPath.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
|
||||
}
|
||||
|
||||
group = 'org.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.8"
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
|
||||
}
|
||||
|
||||
group = 'org.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.8.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.8.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.8.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.8.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "org.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
val compileKotlin: KotlinCompile by tasks
|
||||
compileKotlin.kotlinOptions {
|
||||
languageVersion = "1.8"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "org.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
val compileKotlin: KotlinCompile by tasks
|
||||
compileKotlin.kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+6
-18
@@ -1,22 +1,10 @@
|
||||
group 'Again'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||
}
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
group = 'org.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.languageVersion = "1.0"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
+9
-16
@@ -1,22 +1,15 @@
|
||||
group 'Again'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||
}
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.0'
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
group = 'org.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.languageVersion = "1.1"
|
||||
kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
val x get() = 1
|
||||
data object Test
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.8.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version '1.8.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
jvmMain {
|
||||
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.8.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.8.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
sourceSets {
|
||||
val jvmMain by getting {
|
||||
}
|
||||
all {
|
||||
languageSettings {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "org.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.8.0"
|
||||
}
|
||||
|
||||
group = "org.example"
|
||||
version = "1.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
val compileKotlin: KotlinCompile by tasks
|
||||
compileKotlin.kotlinOptions {
|
||||
languageVersion = "1.9"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
data object Test
|
||||
Reference in New Issue
Block a user