You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/07/25 14:23:54 UTC
[maven-shared-utils] branch master updated: [MSHARED-1109] MessageUtilsTest fails on unsupported platforms (e.g., Apple Silicon or HP-UX/IA64)
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
The following commit(s) were added to refs/heads/master by this push:
new 8822bea [MSHARED-1109] MessageUtilsTest fails on unsupported platforms (e.g., Apple Silicon or HP-UX/IA64)
8822bea is described below
commit 8822bea7d21d53b106a696fd95f10c494ce20c7a
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Mon Jul 25 15:34:29 2022 +0200
[MSHARED-1109] MessageUtilsTest fails on unsupported platforms (e.g., Apple Silicon or HP-UX/IA64)
This closes #106
---
.../shared/utils/logging/MessageUtilsTest.java | 44 +++++++++++++++++++---
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
index e80fe38..2780f8b 100644
--- a/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
@@ -23,6 +23,7 @@ import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeNoException;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@@ -46,12 +47,24 @@ public class MessageUtilsTest
{
MessageUtils.systemInstall();
assertThat( System.out, not( sameInstance( currentOut ) ) );
- MessageUtils.systemUninstall();
assertThat( System.out, sameInstance( currentOut ) );
}
+ catch( LinkageError e )
+ {
+ assumeNoException( "JAnsi not supported for this platform", e );
+ }
finally
{
- System.setOut( currentOut );
+ try
+ {
+ // uninstall is always necessary due to https://github.com/fusesource/jansi/issues/242
+ // but might throw exceptions
+ MessageUtils.systemUninstall();
+ }
+ catch ( Throwable t )
+ {
+ // ignore any thrown exception like NPE here
+ }
}
}
@@ -69,9 +82,28 @@ public class MessageUtilsTest
AnsiOutputStream aos = new AnsiOutputStream( new ByteArrayOutputStream(), width, AnsiMode.Default,
null, AnsiType.Emulation, AnsiColors.Colors256, StandardCharsets.UTF_8,
null, null, false );
- AnsiConsole.systemInstall();
- AnsiConsole.out = new AnsiPrintStream( aos, true );
- assertEquals( 33, MessageUtils.getTerminalWidth() );
- AnsiConsole.systemUninstall();
+ try
+ {
+ AnsiConsole.systemInstall();
+ AnsiConsole.out = new AnsiPrintStream( aos, true );
+ assertEquals( 33, MessageUtils.getTerminalWidth() );
+ }
+ catch( LinkageError e )
+ {
+ assumeNoException( "JAnsi not supported for this platform", e );
+ }
+ finally
+ {
+ try
+ {
+ // uninstall is always necessary due to https://github.com/fusesource/jansi/issues/242
+ // but might throw exceptions
+ AnsiConsole.systemUninstall();
+ }
+ catch ( Throwable t )
+ {
+ // ignore any thrown exception like NPE here
+ }
+ }
}
}