Extract inspection names from GradleInspectionTest into testData
This commit is contained in:
+22
-28
@@ -20,20 +20,17 @@ import com.intellij.codeInspection.LocalInspectionTool
|
|||||||
import com.intellij.codeInspection.ProblemDescriptorBase
|
import com.intellij.codeInspection.ProblemDescriptorBase
|
||||||
import com.intellij.openapi.util.Ref
|
import com.intellij.openapi.util.Ref
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import org.jetbrains.kotlin.idea.inspections.gradle.DeprecatedGradleDependencyInspection
|
|
||||||
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentKotlinGradleVersionInspection
|
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentKotlinGradleVersionInspection
|
||||||
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentStdlibGradleVersionInspection
|
|
||||||
import org.jetbrains.kotlin.idea.inspections.gradle.GradleKotlinxCoroutinesDeprecationInspection
|
|
||||||
import org.jetbrains.kotlin.idea.inspections.runInspection
|
import org.jetbrains.kotlin.idea.inspections.runInspection
|
||||||
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
|
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class GradleInspectionTest : GradleImportingTestCase() {
|
class GradleInspectionTest : GradleImportingTestCase() {
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibGradleVersion() {
|
fun testDifferentStdlibGradleVersion() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
||||||
@@ -41,8 +38,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibGradleVersionWithImplementation() {
|
fun testDifferentStdlibGradleVersionWithImplementation() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
Assert.assertEquals("Plugin version (1.0.2) is not the same as library version (1.0.3)", problems.single())
|
||||||
@@ -50,8 +46,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibJre7GradleVersion() {
|
fun testDifferentStdlibJre7GradleVersion() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals("Plugin version (1.1.0-beta-17) is not the same as library version (1.1.0-beta-22)", problems.single())
|
Assert.assertEquals("Plugin version (1.1.0-beta-17) is not the same as library version (1.1.0-beta-22)", problems.single())
|
||||||
@@ -59,8 +54,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibJdk7GradleVersion() {
|
fun testDifferentStdlibJdk7GradleVersion() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals("Plugin version (1.1.0-beta-17) is not the same as library version (1.1.0-beta-22)", problems.single())
|
Assert.assertEquals("Plugin version (1.1.0-beta-17) is not the same as library version (1.1.0-beta-22)", problems.single())
|
||||||
@@ -68,8 +62,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDifferentStdlibGradleVersionWithVariables() {
|
fun testDifferentStdlibGradleVersionWithVariables() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals("Plugin version (1.0.1) is not the same as library version (1.0.3)", problems.single())
|
Assert.assertEquals("Plugin version (1.0.1) is not the same as library version (1.0.3)", problems.single())
|
||||||
@@ -90,16 +83,14 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testJreInOldVersion() {
|
fun testJreInOldVersion() {
|
||||||
val tool = DeprecatedGradleDependencyInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.isEmpty())
|
Assert.assertTrue(problems.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testJreIsDeprecated() {
|
fun testJreIsDeprecated() {
|
||||||
val tool = DeprecatedGradleDependencyInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
@@ -110,8 +101,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testJreIsDeprecatedWithImplementation() {
|
fun testJreIsDeprecatedWithImplementation() {
|
||||||
val tool = DeprecatedGradleDependencyInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
@@ -123,8 +113,7 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
@TargetVersions("4.9+")
|
@TargetVersions("4.9+")
|
||||||
@Test
|
@Test
|
||||||
fun testJreIsDeprecatedWithoutImplicitVersion() {
|
fun testJreIsDeprecatedWithoutImplicitVersion() {
|
||||||
val tool = DeprecatedGradleDependencyInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
@@ -135,24 +124,21 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNoDifferentStdlibCommonGradleVersion() {
|
fun testNoDifferentStdlibCommonGradleVersion() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.toString(), problems.isEmpty())
|
Assert.assertTrue(problems.toString(), problems.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNoDifferentStdlibJdk7GradleVersion() {
|
fun testNoDifferentStdlibJdk7GradleVersion() {
|
||||||
val tool = DifferentStdlibGradleVersionInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.toString(), problems.isEmpty())
|
Assert.assertTrue(problems.toString(), problems.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testObsoleteCoroutinesUsage() {
|
fun testObsoleteCoroutinesUsage() {
|
||||||
val tool = GradleKotlinxCoroutinesDeprecationInspection()
|
val problems = getInspectionResultFromTestDataProject()
|
||||||
val problems = getInspectionResultFromTestDataProject(tool)
|
|
||||||
|
|
||||||
Assert.assertTrue(problems.size == 1)
|
Assert.assertTrue(problems.size == 1)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
@@ -161,8 +147,12 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInspectionResultFromTestDataProject(tool: LocalInspectionTool): List<String> {
|
private fun getInspectionResultFromTestDataProject(explicitTool: LocalInspectionTool? = null): List<String> {
|
||||||
val buildGradle = importProjectFromTestData().find { it.name == "build.gradle" }!!
|
val buildGradle = importProjectFromTestData().find { it.name == "build.gradle" }!!
|
||||||
|
val tool = explicitTool ?: run {
|
||||||
|
val toolName = File(buildGradle.path).readLines().find { it.startsWith(TOOL) }!!.substring(TOOL.length)
|
||||||
|
Class.forName("org.jetbrains.kotlin.idea.inspections.gradle.$toolName").newInstance() as LocalInspectionTool
|
||||||
|
}
|
||||||
return getInspectionResult(tool, buildGradle)
|
return getInspectionResult(tool, buildGradle)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,4 +175,8 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
override fun testDataDirName(): String {
|
override fun testDataDirName(): String {
|
||||||
return "inspections"
|
return "inspections"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TOOL = "// TOOL: "
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentKotlinGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DeprecatedGradleDependencyInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DeprecatedGradleDependencyInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DeprecatedGradleDependencyInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DeprecatedGradleDependencyInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: DifferentStdlibGradleVersionInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// TOOL: GradleKotlinxCoroutinesDeprecationInspection
|
||||||
|
|
||||||
group 'Again'
|
group 'Again'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user