From 4eaf1f44a3173b3c10c7f79dbc366387514feee2 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 27 Jun 2024 00:14:05 +0200 Subject: [PATCH] [SUREFIRE-2124] Avoid creating unnecessary target files for pom projects --- .../maven/plugin/failsafe/IntegrationTestMojo.java | 10 +++------- .../org/apache/maven/surefire/api/suite/RunResult.java | 6 +++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java index cceb794096..7e6ee3a68c 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java @@ -553,15 +553,11 @@ protected int getRerunFailingTestsCount() { @SuppressWarnings("unchecked") protected void handleSummary(RunResult summary, Exception firstForkException) throws MojoExecutionException, MojoFailureException { - File summaryFile = getSummaryFile(); - if (!summaryFile.getParentFile().isDirectory()) { - //noinspection ResultOfMethodCallIgnored - summaryFile.getParentFile().mkdirs(); - } - try { Object token = getPluginContext().get(FAILSAFE_IN_PROGRESS_CONTEXT_KEY); - writeSummary(summary, summaryFile, token != null); + if (!summary.isNoTestsRun()) { + writeSummary(summary, getSummaryFile(), token != null); + } } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/suite/RunResult.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/suite/RunResult.java index ceb182aee6..8be1df1d04 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/suite/RunResult.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/suite/RunResult.java @@ -86,9 +86,9 @@ public RunResult( this.errors = errors; this.failures = failures; this.skipped = skipped; + this.flakes = flakes; this.failure = failure; this.timeout = timeout; - this.flakes = flakes; } private static String getStackTrace(Exception e) { @@ -174,6 +174,10 @@ public static RunResult noTestsRun() { return new RunResult(0, 0, 0, 0); } + public boolean isNoTestsRun() { + return completedCount == 0 && errors == 0 && skipped == 0 && flakes == 0 && failure == null && !timeout; + } + @Override @SuppressWarnings("RedundantIfStatement") public boolean equals(Object o) {