From c61f75370e121b6de1dd61968593df26608265db Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Mon, 19 Aug 2024 18:17:40 +0200 Subject: [PATCH] tests: fix tests --- .github/workflows/build.yml | 2 +- .mvn/wrapper/maven-wrapper.properties | 2 +- pom.xml | 3 +- .../GitVersioningExtensionIT.java | 112 +++++++++++++----- 4 files changed, 84 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d45429e4..3cdc59b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ jobs: build: runs-on: ubuntu-latest env: - # MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" + MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version" steps: - uses: actions/checkout@v4 diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 6686a643..4b40fcfd 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/pom.xml b/pom.xml index 9e01344f..f63ad8df 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,8 @@ org.apache.maven maven-core - 3.9.9 + + 3.9.7 provided diff --git a/src/test/java/me/qoomon/maven/gitversioning/GitVersioningExtensionIT.java b/src/test/java/me/qoomon/maven/gitversioning/GitVersioningExtensionIT.java index be9b7b87..8ef08619 100644 --- a/src/test/java/me/qoomon/maven/gitversioning/GitVersioningExtensionIT.java +++ b/src/test/java/me/qoomon/maven/gitversioning/GitVersioningExtensionIT.java @@ -55,10 +55,11 @@ void noGitVersioning() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.displayStreamBuffers(); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "0.0.0"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -82,12 +83,13 @@ void disableVersioning_cliOption() throws Exception { writeExtensionConfigFile(projectDir, new Configuration()); // When - Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()) {{ - addCliOption("-Dversioning.disable"); - }}; - verifier.executeGoal("verify"); + Verifier verifier = getVerifier(projectDir); + verifier.addCliArgument("-Dversioning.disable"); + verifier.addCliArguments("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); verifier.verifyTextInLog("skip - versioning is disabled by command option"); String expectedVersion = pomModel.getVersion(); @@ -109,9 +111,11 @@ void revVersioning_noCommit() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "0000000000000000000000000000000000000000"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -136,9 +140,11 @@ void revVersioning() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = givenCommit.getName(); verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -163,9 +169,11 @@ void branchVersioning() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "feature-test-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -193,9 +201,11 @@ void tagVersioning_atBranch() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "v1.0.0-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -224,9 +234,11 @@ void tagVersioning_detachedHead() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "v1.0.0-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -255,9 +267,11 @@ void tagVersioning_lightweightTag_atBranch() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "v1.0.0-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -285,9 +299,11 @@ void tagVersioning_considerTagsOnlyIfHeadIsDetached() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "master-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -315,9 +331,11 @@ void tagVersioning_environmentVariable() throws Exception { Verifier verifier = new Verifier(projectDir.toFile().getAbsolutePath()) {{ setEnvironmentVariable("VERSIONING_GIT_BRANCH", "v1.0.0"); }}; - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "v1.0.0-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -380,9 +398,11 @@ void revVersioning_multiModuleProject() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "master-SNAPSHOT"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -439,9 +459,11 @@ void revVersioning_multiModuleProject_ambiguous_artifactId() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "master-SNAPSHOT"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -483,9 +505,11 @@ void branchVersioning_multiModuleProject_noParent() throws Exception { // When Verifier verifier = getVerifier(logicProjectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "feature-test-gitVersioning"; verifier.verifyTextInLog("Building " + logicPomModel.getArtifactId() + " " + expectedVersion); @@ -539,9 +563,11 @@ void branchVersioning_multiModuleProject_withExternalParent() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "feature-test-gitVersioning"; verifier.verifyTextInLog("Building " + logicPomModel.getArtifactId() + " " + expectedVersion); @@ -593,9 +619,11 @@ void branchVersioning_multiModuleProject_withAggregationAndParent() throws Excep // When Verifier verifier = getVerifier(logicProjectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "feature-test-gitVersioning"; verifier.verifyTextInLog("Building " + logicPomModel.getArtifactId() + " " + expectedVersion); @@ -651,9 +679,11 @@ void dependencyUpdates_multiModuleProject() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "test-gitVersioning"; verifier.verifyTextInLog("Building " + logicPomModel.getArtifactId() + " " + expectedVersion); @@ -683,9 +713,11 @@ void branchVersioning_WithBuildTime() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) + "-gitVersioning"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -708,9 +740,11 @@ void apply_emptyRepoGivesExpectedPlusDistanceResult() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "0"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -719,7 +753,7 @@ void apply_emptyRepoGivesExpectedPlusDistanceResult() throws Exception { assertThat(gitVersionedPomModel.getVersion()).isEqualTo(expectedVersion); } - } + } @Test void apply_singleCommitUntaggedRepoGivesExpectedPlusDistanceResult() throws Exception { @@ -735,9 +769,11 @@ void apply_singleCommitUntaggedRepoGivesExpectedPlusDistanceResult() throws Exce // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "1"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -746,7 +782,7 @@ void apply_singleCommitUntaggedRepoGivesExpectedPlusDistanceResult() throws Exce assertThat(gitVersionedPomModel.getVersion()).isEqualTo(expectedVersion); } - } + } @Test void apply_NoCommitsSinceLastTagGivesExpectedPlusDistanceResult() throws Exception { @@ -765,9 +801,11 @@ void apply_NoCommitsSinceLastTagGivesExpectedPlusDistanceResult() throws Excepti // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "677"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -776,7 +814,7 @@ void apply_NoCommitsSinceLastTagGivesExpectedPlusDistanceResult() throws Excepti assertThat(gitVersionedPomModel.getVersion()).isEqualTo(expectedVersion); } - } + } @Test void apply_TwoCommitsSinceLastTagGivesExpectedPlusDistanceResult() throws Exception { @@ -797,9 +835,11 @@ void apply_TwoCommitsSinceLastTagGivesExpectedPlusDistanceResult() throws Except // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "679"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -824,9 +864,11 @@ void apply_DescribeDistanceSnapshotRelease() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); String expectedVersion = "2.0.4"; Model gitVersionedPomModel = readModel(projectDir.resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel.getVersion()).isEqualTo(expectedVersion); @@ -852,9 +894,11 @@ void apply_DescribeDistanceSnapshot() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); String expectedVersion = "2.0.4-SNAPSHOT"; Model gitVersionedPomModel = readModel(projectDir.resolve(GIT_VERSIONING_POM_NAME).toFile()); assertThat(gitVersionedPomModel.getVersion()).isEqualTo(expectedVersion); @@ -900,9 +944,11 @@ private void apply_TagOnMerged(final boolean firstParent) throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = firstParent ? tagOnMaster : tagOnBranch; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion); @@ -929,9 +975,11 @@ void apply_UseDescribeTagVersionLabel() throws Exception { // When Verifier verifier = getVerifier(projectDir); - verifier.executeGoal("verify"); + verifier.addCliArgument("verify"); + verifier.execute(); // Then + System.err.println(String.join("\n", verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false))); verifier.verifyErrorFreeLog(); String expectedVersion = "label"; verifier.verifyTextInLog("Building " + pomModel.getArtifactId() + " " + expectedVersion);