You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/10/03 19:32:56 UTC

[maven-ear-plugin] branch test-logs updated: Print Maven log after test fail

This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch test-logs
in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git


The following commit(s) were added to refs/heads/test-logs by this push:
     new bf7d61c  Print Maven log after test fail
bf7d61c is described below

commit bf7d61c8b78f2d1756d7fbf9252ade7ea05095a6
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Mon Oct 3 21:32:43 2022 +0200

    Print Maven log after test fail
---
 .../maven/plugins/ear/it/AbstractEarPluginIT.java  | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java b/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
index cdda5ae..6071144 100644
--- a/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
+++ b/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
@@ -23,6 +23,9 @@ import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -36,6 +39,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.maven.plugins.ear.util.ResourceEntityResolver;
@@ -159,13 +163,23 @@ public abstract class AbstractEarPluginIT
         final File baseDir = executeMojo( projectName, new Properties(), true, cleanBeforeExecute );
 
         final File earModuleDir = getEarModuleDirectory( baseDir, earModuleName );
-        assertEarArchive( earModuleDir, projectName );
-        assertEarDirectory( earModuleDir, projectName );
-        assertArchiveContent( earModuleDir, projectName, expectedArtifacts, artifactsDirectory );
-        assertDeploymentDescriptors( earModuleDir, projectName );
-        assertClassPathElements( earModuleDir, projectName, artifactsToValidateManifest,
-                                 artifactsToValidateManifestDirectory, expectedClassPathElements );
-
+        try
+        {
+            assertEarArchive( earModuleDir, projectName );
+            assertEarDirectory( earModuleDir, projectName );
+            assertArchiveContent( earModuleDir, projectName, expectedArtifacts, artifactsDirectory );
+            assertDeploymentDescriptors( earModuleDir, projectName );
+            assertClassPathElements( earModuleDir, projectName, artifactsToValidateManifest,
+                                     artifactsToValidateManifestDirectory, expectedClassPathElements );
+        }
+        catch ( AssertionFailedError e )
+        {
+            Path logPath = baseDir.toPath().resolve( "log.txt" );
+            System.err.println("----- Log file: " + logPath);
+            Files.readAllLines( logPath ).forEach( System.err::println );
+            System.err.println("-----");
+            throw e;
+        }
         return baseDir;
     }