From dd267ee614440920d67110a56fe88b204256cee4 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:19:34 -0800 Subject: [PATCH 1/6] OspackageApplicationDaemonPluginLauncherSpec: use test kit --- .../gradle/plugins/BaseIntegrationTestKitSpec.groovy | 9 +++++++++ ...spackageApplicationDaemonPluginLauncherSpec.groovy | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy diff --git a/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy new file mode 100644 index 00000000..ce2f063e --- /dev/null +++ b/src/test/groovy/com/netflix/gradle/plugins/BaseIntegrationTestKitSpec.groovy @@ -0,0 +1,9 @@ +package com.netflix.gradle.plugins + +import nebula.test.IntegrationTestKitSpec + +abstract class BaseIntegrationTestKitSpec extends IntegrationTestKitSpec { + def setup() { + + } +} diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationDaemonPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationDaemonPluginLauncherSpec.groovy index fcfc0a8a..201d6a84 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationDaemonPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationDaemonPluginLauncherSpec.groovy @@ -16,21 +16,24 @@ package com.netflix.gradle.plugins.application -import nebula.test.IntegrationSpec +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec -class OspackageApplicationDaemonPluginLauncherSpec extends IntegrationSpec { +class OspackageApplicationDaemonPluginLauncherSpec extends BaseIntegrationTestKitSpec { def 'daemon script from application'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(OspackageApplicationDaemonPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-application-daemon' + } + application { mainClass = 'nebula.test.HelloWorld' } """.stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: def archivePath = file("build/distributions/${moduleName}_0_all.deb") From b37d284322ba0f98e0d1a0af28765431f4e61aeb Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:20:48 -0800 Subject: [PATCH 2/6] OspackageApplicationPluginLauncherSpec: move to testkit --- ...OspackageApplicationPluginLauncherSpec.groovy | 16 ++++++++++------ ...pplicationSpringBootPluginLauncherSpec.groovy | 1 - 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationPluginLauncherSpec.groovy index 6f200ddf..04007e11 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationPluginLauncherSpec.groovy @@ -16,20 +16,22 @@ package com.netflix.gradle.plugins.application -import nebula.test.IntegrationSpec +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec -class OspackageApplicationPluginLauncherSpec extends IntegrationSpec { +class OspackageApplicationPluginLauncherSpec extends BaseIntegrationTestKitSpec { def 'application shows up in deb'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(OspackageApplicationPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-application' + } application { mainClass = 'nebula.test.HelloWorld' } """.stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: def archivePath = file("build/distributions/${moduleName}_0_all.deb") @@ -47,7 +49,9 @@ class OspackageApplicationPluginLauncherSpec extends IntegrationSpec { def 'can customize destination'() { writeHelloWorld('nebula.test') buildFile << """ - ${applyPlugin(OspackageApplicationPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-application' + } ospackage_application { prefix = '/usr/local' } @@ -58,7 +62,7 @@ class OspackageApplicationPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: def archivePath = file("build/distributions/${moduleName}_0_all.deb") diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy index adb9197e..f21b1711 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy @@ -20,7 +20,6 @@ import com.netflix.gradle.plugins.deb.Scanner import nebula.test.IntegrationSpec import org.junit.Rule import org.junit.contrib.java.lang.system.ProvideSystemProperty -import spock.lang.Shared import spock.lang.Unroll import spock.lang.IgnoreIf From a3fd28d0a27c22084769331e651a7d3d95664fcc Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:23:39 -0800 Subject: [PATCH 3/6] OspackageApplicationSpringBootPluginLauncherSpec: move to testkit --- ...icationSpringBootPluginLauncherSpec.groovy | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy index f21b1711..0111f416 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/application/OspackageApplicationSpringBootPluginLauncherSpec.groovy @@ -16,8 +16,8 @@ package com.netflix.gradle.plugins.application +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec import com.netflix.gradle.plugins.deb.Scanner -import nebula.test.IntegrationSpec import org.junit.Rule import org.junit.contrib.java.lang.system.ProvideSystemProperty import spock.lang.Unroll @@ -25,39 +25,33 @@ import spock.lang.IgnoreIf import java.util.jar.JarFile -class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { +class OspackageApplicationSpringBootPluginLauncherSpec extends BaseIntegrationTestKitSpec { @Rule public final ProvideSystemProperty ignoreDeprecations = new ProvideSystemProperty("ignoreDeprecations", "true") def 'plugin throws exception if spring-boot plugin not applied'() { buildFile << """ - ${applyPlugin(OspackageApplicationSpringBootPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-application-spring-boot' + } """ when: - def result = runTasks("help") + def result = runTasksAndFail("help") then: - result.failure.getCause().getCause().getCause().message == "The 'org.springframework.boot' plugin must be applied before applying this plugin" + result.output.contains("The 'org.springframework.boot' plugin must be applied before applying this plugin") } String buildScript(String bootVersion, File startScript) { writeHelloWorld('nebula.test') return """ - buildscript { - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/milestone' } - } - dependencies { - classpath 'org.springframework.boot:spring-boot-gradle-plugin:$bootVersion' - } + plugins { + id 'org.springframework.boot' version '$bootVersion' + id 'com.netflix.nebula.ospackage-application-spring-boot' } - apply plugin: 'org.springframework.boot' - ${applyPlugin(OspackageApplicationSpringBootPlugin)} - mainClassName = 'nebula.test.HelloWorld' repositories { @@ -90,7 +84,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { buildFile << buildScript(bootVersion, null) when: - runTasksSuccessfully('build', 'buildDeb') + runTasks('build', 'buildDeb') then: final archivePath = file("build/distributions/test_0_all.deb") @@ -134,7 +128,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { def result = runTasks('runStartScript') then: - result.standardOutput.contains('Hello Integration Test') + result.output.contains('Hello Integration Test') where: bootVersion << ['2.7.0'] @@ -155,10 +149,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { """ when: - def result = runTasksSuccessfully('runStartScript') + def result = runTasks('runStartScript') then: - result.standardOutput.contains('Hello Integration Test') + result.output.contains('Hello Integration Test') where: bootVersion << ['2.7.0'] @@ -176,7 +170,7 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: final appName = "myapp-boot" @@ -210,10 +204,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { """ when: - def result = runTasksWithFailure('installDist') + def result = runTasksAndFail('installDist') then: - result.standardError.contains("mainClass should be configured in order to generate a valid start script. i.e. mainClass = 'com.netflix.app.MyApp'") + result.output.contains("mainClass should be configured in order to generate a valid start script. i.e. mainClass = 'com.netflix.app.MyApp'") where: bootVersion << ['2.7.0'] @@ -232,10 +226,10 @@ class OspackageApplicationSpringBootPluginLauncherSpec extends IntegrationSpec { """ when: - def result = runTasksWithFailure('installDist') + def result = runTasksAndFail('installDist') then: - result.standardError.contains("No value has been specified for property 'mainClassName'") + result.output.contains("No value has been specified for property 'mainClassName'") where: bootVersion << ['2.4.0'] From 3c733aaf242b024f0f6f765fa237bb6b31c20483 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:30:33 -0800 Subject: [PATCH 4/6] OspackageDaemonPluginLauncherSpec: move to testkit --- .../OspackageDaemonPluginLauncherSpec.groovy | 106 +++++++----------- 1 file changed, 38 insertions(+), 68 deletions(-) diff --git a/src/test/groovy/com/netflix/gradle/plugins/daemon/OspackageDaemonPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/daemon/OspackageDaemonPluginLauncherSpec.groovy index 50186da3..226ecdd0 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/daemon/OspackageDaemonPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/daemon/OspackageDaemonPluginLauncherSpec.groovy @@ -16,20 +16,22 @@ package com.netflix.gradle.plugins.daemon -import com.netflix.gradle.plugins.packaging.SystemPackagingPlugin -import nebula.test.IntegrationSpec +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec import org.junit.Rule import org.junit.rules.TemporaryFolder -class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { +class OspackageDaemonPluginLauncherSpec extends BaseIntegrationTestKitSpec { @Rule public TemporaryFolder tmpFolder= new TemporaryFolder() def 'single daemon'() { buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } + daemon { daemonName = 'foobar' command = 'sleep infinity' @@ -37,7 +39,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb', 'buildRpm', '--warning-mode', 'all') + runTasks('buildDeb', 'buildRpm', '--warning-mode', 'all') then: new File(projectDir, "build/distributions/${moduleName}-0.noarch.rpm").exists() @@ -69,8 +71,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { def 'all the bells an whistles'() { buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemon { daemonName = "foobaz" // default = packageName command = "sleep infinity" // required @@ -99,7 +103,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { }""".stripIndent() when: - runTasksSuccessfully('buildDeb', 'buildRpm') + runTasks('buildDeb', 'buildRpm') then: // DEB @@ -131,8 +135,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { File srcDir = new File(projectDir, 'src') srcDir.mkdirs() buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemon { daemonName = "foobaz" // default = packageName command = "sleep infinity" // required @@ -140,7 +146,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { }""".stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: def archivePath = file("build/distributions/${moduleName}_0_all.deb") @@ -152,50 +158,6 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { !postInst.contains("/usr/sbin/update-rc.d") } - def 'custom templates'() { - buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} - - daemonsTemplates.folder = '/com/netflix/gradle/plugins/daemon/custom' - - daemon { - daemonName = 'foobar' - command = 'sleep infinity' - } - """.stripIndent() - - when: - runTasksSuccessfully('buildDeb', 'buildRpm') - - then: - new File(projectDir, "build/distributions/${moduleName}-0.noarch.rpm").exists() - - def rpmTemplateDir = new File(projectDir, 'build/daemon/Foobar/buildRpm/') - def rpmInitFile = new File(rpmTemplateDir, 'initd') - rpmInitFile.exists() - rpmInitFile.text.contains(''' - # chkconfig: 345 85 15 - # description: Control Script for foobar - - . /etc/rc.d/init.d/functions'''.stripIndent()) - - new File(projectDir, "build/distributions/${moduleName}_0_all.deb").exists() - - def debTemplateDir = new File(projectDir, 'build/daemon/Foobar/buildDeb/') - def debInitFile = new File(debTemplateDir, 'initd') - debInitFile.exists() - debInitFile.text.contains(''' - ### BEGIN of CUSTOM SCRIPT INIT INFO - # Provides: foobar - # Default-Start: 2 3 4 5 - # Default-Stop: 0 1 6 - # Required-Start: - # Required-Stop: - # Description: Control Script for foobar - ### END INIT INFO'''.stripIndent()) - } - def 'custom templates - in a project folder'() { File projectTemplates = new File(projectDir, 'templates') projectTemplates.mkdirs() @@ -226,8 +188,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { postInstall.text = "" buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemonsTemplates.folder = '${projectTemplates.name}' @@ -238,7 +202,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb', 'buildRpm') + runTasks('buildDeb', 'buildRpm') then: new File(projectDir, "build/distributions/${moduleName}-0.noarch.rpm").exists() @@ -283,8 +247,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { File postInstall = tmpFolder.newFile('postInstall.tpl') buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemonsTemplates.folder = '${tmpFolder.getRoot().path}' @@ -295,7 +261,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb', 'buildRpm') + runTasks('buildDeb', 'buildRpm') then: new File(projectDir, "build/distributions/${moduleName}-0.noarch.rpm").exists() @@ -316,8 +282,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { def 'custom default values'() { settingsFile.text = """rootProject.name = \"custom-defaults\"""" buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemonsDefaultDefinition { useExtensionDefaults = ${externalDefaults} @@ -338,7 +306,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb', 'buildRpm') + runTasks('buildDeb', 'buildRpm') then: def debTemplateDir = new File(projectDir, 'build/daemon/Foobar/buildDeb/') @@ -354,8 +322,10 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { def 'scripts can have custom location where they will be placed'() { buildFile << """ - ${applyPlugin(OspackageDaemonPlugin)} - ${applyPlugin(SystemPackagingPlugin)} + plugins { + id 'com.netflix.nebula.ospackage-daemon' + id 'com.netflix.nebula.ospackage' + } daemonsDefaultDefinition { runScriptLocation = '/custom/\${daemonName}/run' @@ -370,7 +340,7 @@ class OspackageDaemonPluginLauncherSpec extends IntegrationSpec { """.stripIndent() when: - runTasksSuccessfully('buildDeb') + runTasks('buildDeb') then: def archivePath = file("build/distributions/${moduleName}_0_all.deb") From b2aaba3096d935a3c2849918333ad136dde3af7e Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:34:49 -0800 Subject: [PATCH 5/6] DebPluginLauncherSpec: move to testkit --- .../plugins/deb/DebPluginLauncherSpec.groovy | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/test/groovy/com/netflix/gradle/plugins/deb/DebPluginLauncherSpec.groovy b/src/test/groovy/com/netflix/gradle/plugins/deb/DebPluginLauncherSpec.groovy index 57069b1e..2961809f 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/deb/DebPluginLauncherSpec.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/deb/DebPluginLauncherSpec.groovy @@ -1,57 +1,63 @@ package com.netflix.gradle.plugins.deb -import com.netflix.gradle.plugins.packaging.SystemPackagingPlugin +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec import com.netflix.gradle.plugins.utils.GradleUtils -import nebula.test.IntegrationSpec +import org.gradle.testkit.runner.TaskOutcome import spock.lang.Issue import spock.lang.Unroll -class DebPluginLauncherSpec extends IntegrationSpec { +class DebPluginLauncherSpec extends BaseIntegrationTestKitSpec { def 'not up-to-date when specifying any value'() { when: writeHelloWorld('nebula.test') - buildFile << applyPlugin(SystemPackagingPlugin) buildFile << ''' + plugins { + id 'com.netflix.nebula.ospackage' + } ospackage { } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def results = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') + results.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE } def 'not up-to-date when specifying a value and not files'() { when: - buildFile << applyPlugin(SystemPackagingPlugin) buildFile << ''' + plugins { + id 'com.netflix.nebula.ospackage' + } buildDeb { summary 'No copy spec values, but still not up to date' } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def results = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') + results.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE } def 'not up-to-date when specifying a value on task'() { when: // Run once with a file writeHelloWorld('nebula.test') - buildFile << applyPlugin(SystemPackagingPlugin) buildFile << ''' + plugins { + id 'com.netflix.nebula.ospackage' + } buildDeb { from('src') } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def results = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') + results.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE when: // Nothing changing @@ -59,10 +65,10 @@ class DebPluginLauncherSpec extends IntegrationSpec { // Adding nothing. '''.stripIndent() - runTasksSuccessfully('buildDeb') + def secondResult = runTasks('buildDeb') then: - wasUpToDate(':buildDeb') + secondResult.task(':buildDeb').outcome == TaskOutcome.UP_TO_DATE when: // Adding a non-file input @@ -72,26 +78,29 @@ class DebPluginLauncherSpec extends IntegrationSpec { } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def thirdResult = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') + thirdResult.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE } + def 'not up-to-date when specifying a value on extension'() { when: // Run once with a file writeHelloWorld('nebula.test') - buildFile << applyPlugin(SystemPackagingPlugin) buildFile << ''' + plugins { + id 'com.netflix.nebula.ospackage' + } buildDeb { from('src') } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def results = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') // Need to run once with a file input + results.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE // Need to run once with a file input when: // Nothing changing @@ -99,10 +108,10 @@ class DebPluginLauncherSpec extends IntegrationSpec { // Adding nothing. '''.stripIndent() - runTasksSuccessfully('buildDeb') + def secondResult = runTasks('buildDeb') then: - wasUpToDate(':buildDeb') + secondResult.task(':buildDeb').outcome == TaskOutcome.UP_TO_DATE when: // Adding a non-file input @@ -112,10 +121,10 @@ class DebPluginLauncherSpec extends IntegrationSpec { } '''.stripIndent() - runTasksSuccessfully('buildDeb') + def thirdResult = runTasks('buildDeb') then: - !wasUpToDate(':buildDeb') + thirdResult.task(':buildDeb').outcome != TaskOutcome.UP_TO_DATE } @Issue("https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/104") @@ -128,7 +137,9 @@ class DebPluginLauncherSpec extends IntegrationSpec { buildFile << """ -apply plugin: 'com.netflix.nebula.ospackage' +plugins { + id 'com.netflix.nebula.ospackage' +} ospackage { packageName = 'translates-extension-description' @@ -143,7 +154,7 @@ ospackage { """ when: - runTasksSuccessfully('buildDeb', '-i') + runTasks('buildDeb', '-i') then: def scan = new Scanner(file('build/distributions/translates-extension-description_1.0_all.deb')) From e5ebd15c91cdeb92d3601909f8d8cc8a1de12f72 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Mon, 20 Nov 2023 15:38:40 -0800 Subject: [PATCH 6/6] RpmPluginIntegrationTest: move to testkit --- ...sPackageDockerPluginIntegrationTest.groovy | 13 ++-- .../rpm/RpmPluginIntegrationTest.groovy | 72 ++++++++++++------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/test/groovy/com/netflix/gradle/plugins/docker/OsPackageDockerPluginIntegrationTest.groovy b/src/test/groovy/com/netflix/gradle/plugins/docker/OsPackageDockerPluginIntegrationTest.groovy index 0055fed7..2b92108c 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/docker/OsPackageDockerPluginIntegrationTest.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/docker/OsPackageDockerPluginIntegrationTest.groovy @@ -1,20 +1,19 @@ package com.netflix.gradle.plugins.docker -import nebula.test.IntegrationSpec +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec import spock.lang.IgnoreIf -class OsPackageDockerPluginIntegrationTest extends IntegrationSpec { +class OsPackageDockerPluginIntegrationTest extends BaseIntegrationTestKitSpec { static final String SERVER_URL = 'http://localhost:2375' - def setup() { - fork = true - } @IgnoreIf({ !OsPackageDockerPluginIntegrationTest.isDockerServerInfoUrlReachable() }) def "Can create Dockerfile and build image from it"() { given: buildFile << """ -apply plugin: com.netflix.gradle.plugins.docker.OsPackageDockerPlugin +plugins { + id 'com.netflix.nebula.ospackage-docker' +} repositories { mavenCentral() @@ -27,7 +26,7 @@ createDockerfile { } """ when: - runTasksSuccessfully('buildImage') + runTasks('buildImage') then: noExceptionThrown() diff --git a/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy b/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy index 038ea109..1ce76c6e 100644 --- a/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy +++ b/src/test/groovy/com/netflix/gradle/plugins/rpm/RpmPluginIntegrationTest.groovy @@ -1,10 +1,11 @@ package com.netflix.gradle.plugins.rpm +import com.netflix.gradle.plugins.BaseIntegrationTestKitSpec import com.netflix.gradle.plugins.utils.GradleUtils -import nebula.test.IntegrationSpec import nebula.test.dependencies.DependencyGraph import nebula.test.dependencies.GradleDependencyGenerator import org.apache.commons.io.FileUtils +import org.gradle.testkit.runner.TaskOutcome import spock.lang.Issue import spock.lang.Unroll @@ -12,7 +13,7 @@ import static org.redline_rpm.header.Header.HeaderTag.DESCRIPTION import static org.redline_rpm.header.Header.HeaderTag.NAME import static org.redline_rpm.payload.CpioHeader.* -class RpmPluginIntegrationTest extends IntegrationSpec { +class RpmPluginIntegrationTest extends BaseIntegrationTestKitSpec { @Issue("https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/82") def "rpm task is marked up-to-date when setting arch or os property"() { @@ -21,7 +22,9 @@ class RpmPluginIntegrationTest extends IntegrationSpec { libDir.mkdirs() new File(libDir, 'a.java').text = "public class A { }" buildFile << ''' -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} task buildRpm(type: Rpm) { packageName = 'rpmIsUpToDate' @@ -33,13 +36,13 @@ task buildRpm(type: Rpm) { } ''' when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') and: - def result = runTasksSuccessfully('buildRpm') + def result = runTasks('buildRpm') then: - result.wasUpToDate(':buildRpm') + result.task(':buildRpm').outcome == TaskOutcome.UP_TO_DATE } @Issue("https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/104") @@ -50,7 +53,9 @@ task buildRpm(type: Rpm) { libDir.mkdirs() new File(libDir, 'a.java').text = "public class A { }" buildFile << """ -apply plugin: 'com.netflix.nebula.ospackage' +plugins { + id 'com.netflix.nebula.ospackage' +} ospackage { packageName = 'bleah' @@ -63,7 +68,7 @@ ospackage { """ when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') then: def scan = Scanner.scan(file('build/distributions/bleah-1.0.noarch.rpm')) @@ -83,7 +88,9 @@ ospackage { libDir.mkdirs() new File(libDir, 'a.java').text = "public class A { }" buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} task buildRpm(type: Rpm) { version '1' @@ -94,7 +101,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm', '--warning-mode', 'none') + runTasks('buildRpm', '--warning-mode', 'none') then: def scan = Scanner.scan(file('build/distributions/projectNameDefault-1.noarch.rpm')) @@ -106,18 +113,19 @@ task buildRpm(type: Rpm) { def 'file handle closed'() { given: buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' - +plugins { + id 'com.netflix.nebula.rpm' +} task buildRpm(type: Rpm) { } """ when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') then: // see https://github.com/nebula-plugins/gradle-ospackage-plugin/issues/200#issuecomment-244666158 // if file is not closed this will fail - runTasksSuccessfully('clean') + runTasks('clean') } def 'category_on_spec'() { @@ -131,7 +139,9 @@ task buildRpm(type: Rpm) { appleFile.text = 'apple' buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} version = '1.0.0' @@ -150,7 +160,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') then: // Evaluate response @@ -168,7 +178,9 @@ task buildRpm(type: Rpm) { appleFile.text = '{{BASE}}/apple' buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} version = '1.0.0' @@ -184,7 +196,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') then: def scan = Scanner.scan(file('build/distributions/sample-1.0.0.noarch.rpm')) @@ -204,7 +216,9 @@ task buildRpm(type: Rpm) { // Simulate SystemPackagingBasePlugin buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} def parentExten = project.extensions.create('rpmParent', com.netflix.gradle.plugins.packaging.ProjectPackagingExtension, project) @@ -224,7 +238,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') then: // Evaluate response @@ -248,7 +262,9 @@ task buildRpm(type: Rpm) { when: buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} configurations { myConf @@ -277,7 +293,7 @@ task buildRpm(type: Rpm) { """ then: - runTasksSuccessfully('buildRpm') + runTasks('buildRpm') } @@ -292,7 +308,9 @@ task buildRpm(type: Rpm) { FileUtils.forceMkdirParent(file) java.nio.file.Files.createSymbolicLink(file.toPath(), target.toPath()) buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} task buildRpm(type: Rpm) { packageName = 'example' @@ -302,7 +320,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm', '--warning-mode', 'none') + runTasks('buildRpm', '--warning-mode', 'none') then: def scan = Scanner.scan(this.file('build/distributions/example-3.noarch.rpm')) @@ -321,7 +339,9 @@ task buildRpm(type: Rpm) { FileUtils.forceMkdirParent(file) java.nio.file.Files.createSymbolicLink(file.toPath(), target.toPath()) buildFile << """ -apply plugin: 'com.netflix.nebula.rpm' +plugins { + id 'com.netflix.nebula.rpm' +} task buildRpm(type: Rpm) { packageName = 'example' @@ -333,7 +353,7 @@ task buildRpm(type: Rpm) { """ when: - runTasksSuccessfully('buildRpm', '--warning-mode', 'none') + runTasks('buildRpm', '--warning-mode', 'none') then: def scan = Scanner.scan(this.file('build/distributions/example-4.noarch.rpm'))