Skip to content

Commit 1147278

Browse files
committed
Merge remote-tracking branch 'aSemy/fix/failing_6_8_compat_test'
2 parents b52c64f + 67a35c9 commit 1147278

File tree

3 files changed

+61
-17
lines changed

3 files changed

+61
-17
lines changed

src/test/kotlin/org/jetbrains/intellij/IntelliJPluginSpec.kt

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,21 +561,63 @@ class IntelliJPluginSpec : IntelliJPluginSpecBase() {
561561
}
562562

563563
@Test
564-
fun `throws exception if Gradle is lt 6_8`() {
565-
val message = "Gradle IntelliJ Plugin requires Gradle $MINIMAL_SUPPORTED_GRADLE_VERSION and higher"
564+
fun `expect build fails when using unsupported Gradle version`() {
565+
val unsupportedGradleVersions = setOf(
566+
"6.4",
567+
"6.7.1",
568+
)
566569

567-
build("6.4", true, "help").output.let {
568-
assertTrue(it.contains("FAILURE: Build failed with an exception."))
570+
unsupportedGradleVersions.forEach { gradleVersion ->
571+
build(gradleVersion, true, "help").apply {
572+
assertContains("Gradle IntelliJ Plugin requires Gradle", output)
573+
assertContains("FAILURE: Build failed with an exception", output)
574+
}
569575
}
576+
}
570577

571-
build("6.7.1", true, "help").output.let {
572-
assertTrue(it.contains("FAILURE: Build failed with an exception."))
573-
}
578+
/**
579+
* Note: An older version of `kotlin("jvm")` is because 1.7.+ requires Gradle 7.1.
580+
*
581+
* (specifically `kotlin("jvm")` requires the method [org.gradle.api.plugins.JavaPluginExtension.getSourceSets])
582+
*/
583+
@Test
584+
fun `expect successful build using minimal supported Gradle version`() {
574585

575-
build(MINIMAL_SUPPORTED_GRADLE_VERSION, false, "help").output.let {
576-
assertTrue(it.contains("BUILD SUCCESSFUL"))
577-
assertFalse(it.contains(message))
578-
}
586+
buildFile.writeText("") // reset the build file - need to apply an older version of Kotlin plugin
587+
buildFile.groovy(
588+
"""
589+
plugins {
590+
id 'org.jetbrains.intellij'
591+
id 'org.jetbrains.kotlin.jvm' version '1.4.0'
592+
}
593+
sourceCompatibility = 11
594+
targetCompatibility = 11
595+
repositories {
596+
mavenCentral()
597+
}
598+
intellij {
599+
version = '$intellijVersion'
600+
downloadSources = false
601+
pluginsRepositories {
602+
maven('$pluginsRepository')
603+
}
604+
instrumentCode = false
605+
}
606+
buildSearchableOptions {
607+
enabled = false
608+
}
609+
610+
// Define tasks with a minimal set of tasks required to build a source set
611+
sourceSets.all {
612+
task(it.getTaskName('build', 'SourceSet'), dependsOn: it.output)
613+
}
614+
""".trimIndent()
615+
)
616+
617+
val buildResult = build(MINIMAL_SUPPORTED_GRADLE_VERSION, false, "help")
618+
619+
assertContains("BUILD SUCCESSFUL", buildResult.output)
620+
assertNotContains("Gradle IntelliJ Plugin requires Gradle", buildResult.output)
579621
}
580622

581623
@SuppressWarnings("GrEqualsBetweenInconvertibleTypes")

src/test/kotlin/org/jetbrains/intellij/IntelliJPluginSpecBase.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ abstract class IntelliJPluginSpecBase {
3636
?: throw GradleException("'test.intellij.version' isn't provided")
3737
val testMarkdownPluginVersion = System.getProperty("test.markdownPlugin.version").takeUnless { it.isNullOrEmpty() }
3838
?: throw GradleException("'test.markdownPlugin.version' isn't provided")
39-
val dir: File by lazy { createTempDirectory("tmp").toFile() }
39+
var dir: File = createTempDirectory("tmp").toFile()
4040

41-
val gradleProperties = file("gradle.properties")
42-
val buildFile = file("build.gradle")
43-
val pluginXml = file("src/main/resources/META-INF/plugin.xml")
44-
val buildDirectory = File(dir, "build")
41+
val gradleProperties get() = file("gradle.properties")
42+
val buildFile get() = file("build.gradle")
43+
val pluginXml get() = file("src/main/resources/META-INF/plugin.xml")
44+
val buildDirectory get() = File(dir, "build")
4545

4646
@BeforeTest
4747
open fun setUp() {
48+
dir = createTempDirectory("tmp").toFile()
49+
4850
file("settings.gradle").groovy("rootProject.name = 'projectName'")
4951

5052
buildFile.groovy(

src/test/kotlin/org/jetbrains/intellij/tasks/PrepareSandboxTaskSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import kotlin.test.assertTrue
1717
@Suppress("GroovyUnusedAssignment", "PluginXmlValidity", "ComplexRedundantLet")
1818
class PrepareSandboxTaskSpec : IntelliJPluginSpecBase() {
1919

20-
private val sandbox = File(buildDirectory, DEFAULT_SANDBOX)
20+
private val sandbox get() = File(buildDirectory, DEFAULT_SANDBOX)
2121

2222
@Test
2323
fun `prepare sandbox for two plugins`() {

0 commit comments

Comments
 (0)