You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/02/03 05:21:54 UTC

[maven-surefire] branch InterruptedIOException updated (360f159 -> 5b8e23b)

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

tibordigana pushed a change to branch InterruptedIOException
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


 discard 360f159  interrupted PpidChecker = error, more logs
 discard cd005c2  InterruptedIOException and cause:InterruptedException have the same purpose and should be caught
     add c2da914  [JUnit47ParallelIT.forcedShutdownVerifyingLogs] The logs do not have to match "These tests were executed in prior to the shutdown operation:" if the interrupted tests were finished fast enough. If this error message appears then the next line has to list the name of the class with tests in progress.
     add 627139e  Bump junit from 4.13.1 to 4.13.2
     add 2880b08  [JUnit47ParallelIT.forcedShutdownVerifyingLogs] fixed assertion regex
     add 4e69349  replaced ancestor org.easytesting:fest-assert>1.4 by org.assertj:assertj-core:3.22.0
     add 33ccb25  Drop max-parallel from GitHub build
     add 47aebbb  [SUREFIRE-1556] Test XML file is not valid when rerun "fails" with an assumption
     add 9b44095  [SUREFIRE-1997] InterruptedIOException and cause:InterruptedException have the same purpose and should be caught in CommandReader
     new a2e6fe4  interrupted PpidChecker = error, more logs
     new 5b8e23b  [SUREFIRE-1998] Interrupted PPID Checker should have the same meaning as stopped PPID Checker

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (360f159)
            \
             N -- N -- N   refs/heads/InterruptedIOException (5b8e23b)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/maven-verify.yml                 |   8 +-
 .../plugin/failsafe/IntegrationTestMojoTest.java   |   2 +-
 .../failsafe/MarshallerUnmarshallerTest.java       |   2 +-
 .../maven/plugin/failsafe/RunResultTest.java       |   2 +-
 .../surefire/report/StatelessXmlReporter.java      |  54 ++++++++---
 .../AbstractSurefireMojoJava7PlusTest.java         |   4 +-
 .../plugin/surefire/AbstractSurefireMojoTest.java  |  77 ++++++++--------
 .../AbstractSurefireMojoToolchainsTest.java        |  11 +--
 .../maven/plugin/surefire/CommonReflectorTest.java |   2 +-
 .../maven/plugin/surefire/MojoMocklessTest.java    |   2 +-
 .../surefire/SurefireDependencyResolverTest.java   |   2 +-
 .../maven/plugin/surefire/SurefireHelperTest.java  |   2 +-
 .../booterclient/DefaultForkConfigurationTest.java |   2 +-
 .../booterclient/ForkConfigurationTest.java        |  26 +++---
 .../surefire/booterclient/ForkStarterTest.java     |   4 +-
 .../booterclient/ForkingRunListenerTest.java       |   7 +-
 .../JarManifestForkConfigurationTest.java          |   6 +-
 .../ModularClasspathForkConfigurationTest.java     |   2 +-
 .../OutputStreamFlushableCommandlineTest.java      |   4 +-
 .../booterclient/output/ForkClientTest.java        |   5 +-
 .../output/ThreadedStreamConsumerTest.java         |   2 +-
 .../extensions/ConsoleOutputReporterTest.java      |   5 +-
 .../maven/plugin/surefire/extensions/E2ETest.java  |   2 +-
 .../extensions/EventConsumerThreadTest.java        |   2 +-
 .../extensions/ForkedProcessEventNotifierTest.java |   2 +-
 .../surefire/extensions/StatelessReporterTest.java |   2 +-
 .../surefire/extensions/StreamFeederTest.java      |   2 +-
 .../surefire/report/StatelessXmlReporterTest.java  | 102 ++++++++++++++++++---
 .../plugin/surefire/report/TestSetStatsTest.java   |   2 +-
 .../runorder/RunEntryStatisticsMapTest.java        |   2 +-
 .../plugin/surefire/util/ScannerUtilTest.java      |   2 +-
 .../maven/surefire/extensions/ForkChannelTest.java |   2 +-
 .../StatelessTestsetInfoReporterTest.java          |   2 +-
 .../surefire/providerapi/ProviderDetectorTest.java |   2 +-
 .../report/ConsoleOutputFileReporterTest.java      |   2 +-
 .../org/apache/maven/surefire/spi/SPITest.java     |   2 +-
 .../maven/surefire/stream/EventDecoderTest.java    |   2 +-
 .../maven/plugin/surefire/SurefirePluginTest.java  |   2 +-
 .../report/SurefireSchemaValidationTest.java       |   5 +-
 pom.xml                                            |  12 +--
 .../api/booter/ForkingRunListenerTest.java         |   2 +-
 .../api/stream/AbstractStreamDecoderTest.java      |   2 +-
 .../api/stream/AbstractStreamEncoderTest.java      |   2 +-
 .../surefire/api/util/ReflectionUtilsTest.java     |   2 +-
 .../api/util/internal/AsyncSocketTest.java         |   2 +-
 .../api/util/internal/ChannelsReaderTest.java      |   2 +-
 .../api/util/internal/ChannelsWriterTest.java      |   2 +-
 .../api/util/internal/ObjectUtilsTest.java         |   2 +-
 .../apache/maven/surefire/booter/PpidChecker.java  |  27 +++++-
 .../surefire/booter/BooterDeserializerTest.java    |   2 +-
 .../maven/surefire/booter/CommandReaderTest.java   |   6 +-
 .../surefire/booter/ForkedBooterMockTest.java      |  10 +-
 .../maven/surefire/booter/ForkedBooterTest.java    |   2 +-
 .../maven/surefire/booter/PpidCheckerTest.java     |  58 +++++++++++-
 .../maven/surefire/booter/SystemUtilsTest.java     |   2 +-
 .../booter/spi/CommandChannelDecoderTest.java      |   2 +-
 .../booter/spi/EventChannelEncoderTest.java        |   2 +-
 .../extensions/CommandlineExecutorTest.java        |   4 +-
 .../its/CheckTestNgCustomObjectFactoryIT.java      |   2 +-
 .../its/CheckTestNgCustomTestRunnerFactoryIT.java  |   2 +-
 .../surefire/its/CheckTestNgExecuteErrorIT.java    |   2 +-
 .../maven/surefire/its/JUnit47ParallelIT.java      |  34 +++++--
 .../maven/surefire/its/JUnitPlatformEnginesIT.java |   4 +-
 .../its/JUnitPlatformStreamCorruptionIT.java       |   2 +-
 .../maven/surefire/its/LongWindowsPathIT.java      |   2 +-
 .../surefire/its/MultiModuleProjectWithJPMSIT.java |   2 +-
 .../Surefire1295AttributeJvmCrashesToTestsIT.java  |   2 +-
 .../its/jiras/Surefire1367AssumptionLogsIT.java    |   2 +-
 .../its/jiras/Surefire141PluggableProvidersIT.java |   2 +-
 .../jiras/Surefire1535TestNGParallelSuitesIT.java  |   2 +-
 .../its/jiras/Surefire34SecurityManagerIT.java     |   2 +-
 ...fire735ForkFailWithRedirectConsoleOutputIT.java |   2 +-
 ...Surefire946KillMainProcessInReusableForkIT.java |   2 +-
 .../surefire/log/api/ConsoleLoggerUtilsTest.java   |   2 +-
 .../maven/plugin/surefire/log/api/LevelTest.java   |   2 +-
 .../maven/plugin/surefire/log/api/LoggersTest.java |   2 +-
 surefire-providers/surefire-junit-platform/pom.xml |   5 -
 .../junitplatform/JUnitPlatformProviderTest.java   |  17 ++--
 .../junitplatform/RunListenerAdapterTest.java      |   2 +-
 surefire-providers/surefire-testng/pom.xml         |   5 -
 .../maven/surefire/testng/TestNGReporterTest.java  |   2 +-
 81 files changed, 394 insertions(+), 218 deletions(-)

[maven-surefire] 01/02: interrupted PpidChecker = error, more logs

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch InterruptedIOException
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit a2e6fe4f00923149c70ecbab5082806bde591950
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Tue Feb 1 15:01:03 2022 +0100

    interrupted PpidChecker = error, more logs
---
 .../java/org/apache/maven/surefire/booter/PpidChecker.java  | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index ff5d77c..a5287c7 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -35,6 +35,7 @@ import java.util.regex.Pattern;
 
 import static java.lang.Integer.parseInt;
 import static java.lang.Long.parseLong;
+import static java.lang.String.join;
 import static java.util.concurrent.TimeUnit.DAYS;
 import static java.util.concurrent.TimeUnit.HOURS;
 import static java.util.concurrent.TimeUnit.MINUTES;
@@ -397,6 +398,8 @@ final class PpidChecker
             Process process = null;
             ProcessInfo processInfo = INVALID_PROCESS_INFO;
             StringBuilder out = new StringBuilder( 64 );
+            out.append( join( " ", command ) )
+                .append( NL );
             try
             {
                 if ( IS_OS_HP_UX ) // force to run shell commands in UNIX Standard mode on HP-UX
@@ -414,13 +417,17 @@ final class PpidChecker
                 }
                 checkValid( scanner );
                 int exitCode = process.waitFor();
-                if ( exitCode != 0 || isStopped() )
+                boolean isError = Thread.interrupted() || isStopped();
+                if ( exitCode != 0 || isError )
                 {
-                    out.append( "<<exit>> <<" ).append( exitCode ).append( ">>" ).append( NL );
+                    out.append( "<<exit>> <<" ).append( exitCode ).append( ">>" )
+                        .append( NL )
+                        .append( "<<stopped>> <<" ).append( isStopped() ).append( ">>" );
                     DumpErrorSingleton.getSingleton()
                             .dumpText( out.toString() );
                 }
-                return isStopped() ? ERR_PROCESS_INFO : exitCode == 0 ? processInfo : INVALID_PROCESS_INFO;
+
+                return isError ? ERR_PROCESS_INFO : ( exitCode == 0 ? processInfo : INVALID_PROCESS_INFO );
             }
             catch ( Exception e )
             {

[maven-surefire] 02/02: [SUREFIRE-1998] Interrupted PPID Checker should have the same meaning as stopped PPID Checker

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch InterruptedIOException
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 5b8e23b3667bd0d830e8eea68a4cd3c30532bd19
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Thu Feb 3 06:20:07 2022 +0100

    [SUREFIRE-1998] Interrupted PPID Checker should have the same meaning as stopped PPID Checker
---
 .../apache/maven/surefire/booter/PpidChecker.java  | 27 ++++++++++-
 .../maven/surefire/booter/PpidCheckerTest.java     | 56 ++++++++++++++++++++++
 2 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index a5287c7..3eb703d 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -25,6 +25,7 @@ import javax.annotation.Nonnull;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
+import java.nio.file.Path;
 import java.text.SimpleDateFormat;
 import java.util.Queue;
 import java.util.Scanner;
@@ -36,6 +37,9 @@ import java.util.regex.Pattern;
 import static java.lang.Integer.parseInt;
 import static java.lang.Long.parseLong;
 import static java.lang.String.join;
+import static java.nio.file.Files.createTempFile;
+import static java.nio.file.Files.delete;
+import static java.nio.file.Files.readAllBytes;
 import static java.util.concurrent.TimeUnit.DAYS;
 import static java.util.concurrent.TimeUnit.HOURS;
 import static java.util.concurrent.TimeUnit.MINUTES;
@@ -394,14 +398,16 @@ final class PpidChecker
         ProcessInfo execute( String... command )
         {
             ProcessBuilder processBuilder = new ProcessBuilder( command );
-            processBuilder.redirectErrorStream( true );
             Process process = null;
             ProcessInfo processInfo = INVALID_PROCESS_INFO;
             StringBuilder out = new StringBuilder( 64 );
             out.append( join( " ", command ) )
                 .append( NL );
+            Path stdErr = null;
             try
             {
+                stdErr = createTempFile( "surefire", null );
+                processBuilder.redirectError( stdErr.toFile() );
                 if ( IS_OS_HP_UX ) // force to run shell commands in UNIX Standard mode on HP-UX
                 {
                     processBuilder.environment().put( "UNIX95", "1" );
@@ -447,11 +453,28 @@ final class PpidChecker
                 if ( process != null )
                 {
                     destroyableCommands.remove( process );
-                    process.destroy();
                     closeQuietly( process.getInputStream() );
                     closeQuietly( process.getErrorStream() );
                     closeQuietly( process.getOutputStream() );
                 }
+
+                if ( stdErr != null )
+                {
+                    try
+                    {
+                        String error = new String( readAllBytes( stdErr ) ).trim();
+                        if ( !error.isEmpty() )
+                        {
+                            DumpErrorSingleton.getSingleton()
+                                .dumpText( error );
+                        }
+                        delete( stdErr );
+                    }
+                    catch ( IOException e )
+                    {
+                        // cannot do anything about it, the dump file writes would fail as well
+                    }
+                }
             }
         }
     }
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
index 5f7a744..d9431e1 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.booter;
  * under the License.
  */
 
+import org.apache.maven.surefire.api.booter.DumpErrorSingleton;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -27,7 +28,9 @@ import java.io.File;
 import java.lang.management.ManagementFactory;
 import java.util.regex.Matcher;
 
+import static java.nio.file.Files.readAllBytes;
 import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.maven.surefire.shared.io.FileUtils.getTempDirectory;
 import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_UNIX;
 import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
 import static org.apache.maven.surefire.booter.ProcessInfo.unixProcessInfo;
@@ -150,6 +153,59 @@ public class PpidCheckerTest
     }
 
     @Test
+    public void shouldBeStoppedCheckerWithError() throws Exception
+    {
+        String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim();
+        DumpErrorSingleton.getSingleton().init( getTempDirectory(), "dump" );
+
+        PpidChecker checker = new PpidChecker( expectedPid );
+        checker.stop();
+
+        ProcessInfo processInfo = IS_OS_UNIX ? checker.unix() : checker.windows();
+        assertThat( processInfo.isError() ).isTrue();
+
+        File dump = DumpErrorSingleton.getSingleton().dumpText( null );
+        dump.deleteOnExit();
+
+        String error = new String( readAllBytes( dump.toPath() ) );
+
+        assertThat( error )
+            .contains( "<<exit>> <<0>>" )
+            .contains( "<<stopped>> <<true>>" );
+    }
+
+    @Test
+    public void shouldBeEmptyDump() throws Exception
+    {
+        String expectedPid = ManagementFactory.getRuntimeMXBean().getName().split( "@" )[0].trim();
+        DumpErrorSingleton.getSingleton().init( getTempDirectory(), "dump" );
+
+        PpidChecker checker = new PpidChecker( expectedPid );
+        Thread.currentThread().interrupt();
+
+        ProcessInfo processInfo = IS_OS_UNIX ? checker.unix() : checker.windows();
+        assertThat( processInfo.isError() ).isTrue();
+
+        // a hack to obtain the file
+        File dump = DumpErrorSingleton.getSingleton().dumpText( null );
+
+        dump.deleteOnExit();
+
+        String error = new String( readAllBytes( dump.toPath() ) ).trim();
+
+        String[] lines = error.split( "\r\n|\r|\n" );
+
+        assertThat( lines.length )
+            .isEqualTo( 2 );
+
+        assertThat( lines[0] )
+            .startsWith( "# Created at " );
+
+        assertThat( lines[1] )
+            .isEqualTo( "null" );
+    }
+
+    @Test
     public void shouldNotFindSuchPID()
     {
         PpidChecker checker = new PpidChecker( "1000000" );