From b1edd8154eb8b87cf5bec18ba02feaa27c19554a Mon Sep 17 00:00:00 2001 From: Maciej Kwidzinski Date: Thu, 13 Jun 2024 16:26:58 +0200 Subject: [PATCH] Reproduce the double patch bump Repro https://github.com/atlassian-labs/db-replica/issues/77 --- .../performance/tools/license/Fixtures.kt | 2 +- .../performance/tools/license/ReleaseTest.kt | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/test/kotlin/com/atlassian/performance/tools/license/Fixtures.kt b/src/test/kotlin/com/atlassian/performance/tools/license/Fixtures.kt index aa79a32..05671c7 100644 --- a/src/test/kotlin/com/atlassian/performance/tools/license/Fixtures.kt +++ b/src/test/kotlin/com/atlassian/performance/tools/license/Fixtures.kt @@ -24,7 +24,7 @@ class Fixtures { buildFolder.create() val git = Git.init().setDirectory(buildFolder.root).call() addInitialCommit(projectName, buildFolder, git) - git.tag().setName("release-$version-alpha").call() + git.tag().setName("release-$version").call() addCode(buildFolder, git) return ProjectFixture(buildFolder.root, git) } diff --git a/src/test/kotlin/com/atlassian/performance/tools/license/ReleaseTest.kt b/src/test/kotlin/com/atlassian/performance/tools/license/ReleaseTest.kt index 338fc57..9ac4b81 100644 --- a/src/test/kotlin/com/atlassian/performance/tools/license/ReleaseTest.kt +++ b/src/test/kotlin/com/atlassian/performance/tools/license/ReleaseTest.kt @@ -1,10 +1,12 @@ package com.atlassian.performance.tools.license +import com.atlassian.performance.tools.license.Fixtures.ProjectFixture import org.assertj.core.api.Assertions.assertThat import org.eclipse.jgit.api.Git import org.eclipse.jgit.transport.URIish +import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner -import org.gradle.testkit.runner.TaskOutcome +import org.gradle.testkit.runner.TaskOutcome.SUCCESS import org.junit.Test import org.junit.rules.TemporaryFolder @@ -23,16 +25,28 @@ class ReleaseTest { project.git.addOrigin(safelyPushableRemote) project.git.push().call() - val releaseResult = GradleRunner.create() - .withProjectDir(project.root) - .withArguments("release", "--stacktrace") + val markNextVersion = project.buildTask( + "markNextVersion", + "-Prelease.incrementer=incrementPatch", + "-Prelease.localOnly", + "--stacktrace" + ) + assertThat(markNextVersion?.task(":markNextVersion")?.outcome).isEqualTo(SUCCESS) + + val release = project.buildTask("release", "--stacktrace") + assertThat(release?.task(":release")?.outcome).isEqualTo(SUCCESS) + + val currentVersion = project.buildTask("currentVersion") + assertThat(currentVersion?.output).contains("1.2.5") + } + + private fun ProjectFixture.buildTask(task: String, vararg args: String): BuildResult? { + return GradleRunner.create() + .withProjectDir(this.root) + .withArguments(task, *args) .withPluginClasspath() .forwardOutput() .withDebug(true) .build() - - val releaseTask = releaseResult.task(":release") - assertThat(releaseTask?.outcome) - .isEqualTo(TaskOutcome.SUCCESS) } }