Test quickfixes for updating language/API version and coroutine support in Gradle projects
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
kotlin {
|
||||||
|
experimental {
|
||||||
|
coroutines "enable"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
suspend fun foo() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.apiVersion = "1.0"
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.apiVersion = "1.1"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x = <caret>"s"::length
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.languageVersion = "1.0"
|
||||||
|
kotlinOptions.apiVersion = "1.0"
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
kotlinOptions.apiVersion = "1.1"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x = <caret>"s"::length
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.languageVersion = "1.0"
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.languageVersion = "1.1"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x get() = 1
|
||||||
@@ -55,7 +55,7 @@ import java.util.List;
|
|||||||
public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
||||||
private File ourTempDir;
|
private File ourTempDir;
|
||||||
|
|
||||||
private IdeaProjectTestFixture myTestFixture;
|
protected IdeaProjectTestFixture myTestFixture;
|
||||||
|
|
||||||
protected Project myProject;
|
protected Project myProject;
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
|||||||
|
|
||||||
protected abstract String getTestsTempDir();
|
protected abstract String getTestsTempDir();
|
||||||
|
|
||||||
private void setUpFixtures() throws Exception {
|
protected void setUpFixtures() throws Exception {
|
||||||
myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()).getFixture();
|
myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()).getFixture();
|
||||||
myTestFixture.setUp();
|
myTestFixture.setUp();
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ public abstract class ExternalSystemTestCase extends UsefulTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tearDownFixtures() throws Exception {
|
protected void tearDownFixtures() throws Exception {
|
||||||
myTestFixture.tearDown();
|
myTestFixture.tearDown();
|
||||||
myTestFixture = null;
|
myTestFixture = null;
|
||||||
}
|
}
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.codeInsight.gradle
|
||||||
|
|
||||||
|
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||||
|
import com.intellij.openapi.fileEditor.impl.LoadTextUtil
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
|
import com.intellij.rt.execution.junit.FileComparisonFailure
|
||||||
|
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||||
|
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
|
import org.jetbrains.kotlin.test.testFramework.runInEdtAndWait
|
||||||
|
import org.junit.Test
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.reflect.KMutableProperty0
|
||||||
|
|
||||||
|
class GradleLanguageFeatureQuickFixTest : GradleImportingTestCase() {
|
||||||
|
private lateinit var codeInsightTestFixture: CodeInsightTestFixture
|
||||||
|
|
||||||
|
fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/gradle/languageFeature/" + getTestName(true).substringBefore('_')
|
||||||
|
|
||||||
|
override fun setUpFixtures() {
|
||||||
|
myTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName()).fixture
|
||||||
|
codeInsightTestFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(myTestFixture)
|
||||||
|
codeInsightTestFixture.setUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun tearDownFixtures() {
|
||||||
|
codeInsightTestFixture.tearDown()
|
||||||
|
(this::codeInsightTestFixture as KMutableProperty0<CodeInsightTestFixture?>).set(null)
|
||||||
|
myTestFixture = null
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testUpdateLanguageVersion() {
|
||||||
|
doTest("Set module language version to 1.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testUpdateApiVersion() {
|
||||||
|
doTest("Set module API version to 1.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testUpdateLanguageAndApiVersion() {
|
||||||
|
doTest("Set module language version to 1.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun testEnableCoroutines() {
|
||||||
|
doTest("Enable coroutine support in the current module")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doTest(intentionName: String) {
|
||||||
|
val buildGradleVFile = createProjectSubFile("build.gradle", File(getTestDataPath(), "build.gradle").readText())
|
||||||
|
importProject()
|
||||||
|
runInEdtAndWait {
|
||||||
|
val sourceVFile = createProjectSubFile("src/main/kotlin/src.kt", File(getTestDataPath(), "src.kt").readText())
|
||||||
|
codeInsightTestFixture.configureFromExistingVirtualFile(sourceVFile)
|
||||||
|
codeInsightTestFixture.launchAction(codeInsightTestFixture.findSingleIntention(intentionName))
|
||||||
|
FileDocumentManager.getInstance().saveAllDocuments()
|
||||||
|
checkResult(buildGradleVFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkResult(file: VirtualFile) {
|
||||||
|
val expectedPath = File(getTestDataPath(), "build.gradle.after")
|
||||||
|
val expectedContent = expectedPath.readText()
|
||||||
|
val actualContent = LoadTextUtil.loadText(file).toString()
|
||||||
|
if (actualContent != expectedContent) {
|
||||||
|
throw FileComparisonFailure("build.gradle doesn't match", expectedContent, actualContent, expectedPath.path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user