Skip to content

Commit

Permalink
Migrate to IntegrationTestKitSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Nov 10, 2023
1 parent c5f268c commit 5dbe4d8
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 127 deletions.
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ gradlePlugin {
implementationClass= 'nebula.plugin.info.reporting.InfoJarManifestPlugin'
tags.set(['nebula', 'info'])
}
infoJARProperties {
id = 'com.netflix.nebula.info-jar-properties'
displayName = 'Gradle Info JAR properties plugin'
description = project.description
implementationClass= 'nebula.plugin.info.reporting.InfoJarPropertiesFilePlugin'
tags.set(['nebula', 'info'])
}
infoJava {
id = 'com.netflix.nebula.info-java'
displayName = 'Gradle Info Java plugin'
Expand Down
10 changes: 0 additions & 10 deletions src/test/groovy/nebula/plugin/info/BaseIntegrationSpec.groovy

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ package nebula.plugin.info

import nebula.test.functional.ExecutionResult

class InfoBrokerPluginIntegrationSpec extends BaseIntegrationSpec {
class InfoBrokerPluginIntegrationSpec extends BaseIntegrationTestKitSpec {

def 'it returns build reports at the end of the build'() {
given:
def report = 'This string may only be retrieved after the build has finished'
buildFile << """
${applyPlugin(InfoBrokerPlugin)}
plugins {
id 'com.netflix.nebula.info-broker'
}
def broker = project.plugins.getPlugin(${InfoBrokerPlugin.name})
Expand All @@ -42,10 +44,10 @@ class InfoBrokerPluginIntegrationSpec extends BaseIntegrationSpec {
new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent()

when:
ExecutionResult result = runTasksSuccessfully('createReport')
def result = runTasks('createReport')

then:
result.standardOutput.contains(report)
result.output.contains(report)
}


Expand Down
50 changes: 21 additions & 29 deletions src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
*/
package nebula.plugin.info

import nebula.test.functional.ExecutionResult

class InfoPluginIntegrationSpec extends BaseIntegrationSpec {
class InfoPluginIntegrationSpec extends BaseIntegrationTestKitSpec {
def 'it returns build reports at the end of the build'() {
given:
buildFile << """
Expand All @@ -30,8 +29,10 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec {
}
}
${applyPlugin(InfoPlugin)}
apply plugin: 'java'
plugins {
id 'com.netflix.nebula.info'
id 'java'
}
repositories { mavenCentral() }
dependencies {
Expand All @@ -51,17 +52,20 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec {
new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent()

when:
ExecutionResult result = runTasksSuccessfully('assemble')
def result = runTasks('assemble')

then:
result.standardOutput.contains('{buildscript-singlemodule-test-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}')
result.output.contains('{buildscript-singlemodule-test-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}')
}

def 'it returns build reports at the end of multiproject build'() {
given:
buildFile << """
plugins {
id 'com.netflix.nebula.info'
}
allprojects {
${applyPlugin(InfoPlugin)}
apply plugin: 'com.netflix.nebula.info'
}
subprojects {
Expand Down Expand Up @@ -91,32 +95,23 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec {
new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent()

when:
ExecutionResult result = runTasksSuccessfully('build')
def result = runTasks('build')

then:
result.standardOutput.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}')
result.standardOutput.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}')
result.output.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}')
result.output.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}')
}

def 'works with jenkins jpi plugin'() {
given:
System.setProperty("ignoreDeprecations", 'true')
buildFile << """
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jenkins-ci.tools:gradle-jpi-plugin:0.49.0"
}
plugins {
id 'com.netflix.nebula.info'
id 'java'
id "org.jenkins-ci.jpi" version "0.50.0-rc.3"
}
${applyPlugin(InfoPlugin)}
apply plugin: 'java'
apply plugin: "org.jenkins-ci.jpi"
jenkinsPlugin {
jenkinsVersion.set('2.249.3')
}
Expand All @@ -134,10 +129,7 @@ class InfoPluginIntegrationSpec extends BaseIntegrationSpec {
// JPI plugin might not be configuration cache compatible yet
new File(projectDir, 'gradle.properties').text = '''org.gradle.configuration-cache=false'''.stripIndent()

when:
ExecutionResult result = runTasksSuccessfully('assemble')

then:
result.success
expect:
runTasks('assemble')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec {

def 'reports proper jdk version when configuring toolchain in compile task'() {
given:
debug = true
buildFile << """
buildscript {
repositories {
Expand Down Expand Up @@ -112,7 +111,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec {

def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains'() {
given:
debug = true
buildFile << """
buildscript {
repositories {
Expand Down Expand Up @@ -165,7 +163,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec {

def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains (multi language)'() {
given:
debug = true
buildFile << """
buildscript {
repositories {
Expand Down Expand Up @@ -221,7 +218,6 @@ class InfoPluginIntegrationTestKitSpec extends BaseIntegrationTestKitSpec {
def 'reports proper jdk version when configuring target/source compatibility in compile task + toolchains (scala support)'() {
given:
debug = true
buildFile << """
buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package nebula.plugin.info.ci

import nebula.plugin.info.BaseIntegrationSpec
import nebula.plugin.info.InfoBrokerPlugin
import nebula.plugin.info.reporting.InfoJarManifestPlugin
import nebula.test.IntegrationSpec
import nebula.plugin.info.BaseIntegrationTestKitSpec
import org.junit.Rule
import org.junit.contrib.java.lang.system.EnvironmentVariables
import spock.lang.IgnoreIf
Expand All @@ -14,7 +11,7 @@ import java.util.jar.JarFile
import java.util.jar.Manifest

@IgnoreIf({ System.getenv('TITUS_TASK_ID') || jvm.isJava21() || jvm.isJava17() })
class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationSpec {
class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationTestKitSpec {

@Rule
public final EnvironmentVariables environmentVariables = new EnvironmentVariables()
Expand All @@ -28,17 +25,19 @@ class ContinuousIntegrationInfoPluginSpec extends BaseIntegrationSpec {

writeHelloWorld('nebula.test')
buildFile << """
${applyPlugin(InfoBrokerPlugin)}
${applyPlugin(ContinuousIntegrationInfoPlugin)}
${applyPlugin(InfoJarManifestPlugin)}
plugins {
id 'com.netflix.nebula.info-broker'
id 'com.netflix.nebula.info-ci'
id 'com.netflix.nebula.info-jar'
}
apply plugin: 'java'
version = '1.0'
""".stripIndent()

when:
runTasksSuccessfully('jar')
runTasks('jar')

then:
File jarFile = new File(projectDir, "build/libs/${moduleName}-1.0.jar")
Expand Down
Loading

0 comments on commit 5dbe4d8

Please sign in to comment.