This is an automated email from the ASF dual-hosted git repository.
rmannibucau pushed a commit to branch rmannibucau/flush-output-toggle
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
commit 7be86d1ee9c7992dc7a48a218ac4318c320c2b1b
Author: Romain Manni-Bucau
AuthorDate: Wed Jul 8 13:02:23 2020 +0200
enable to flush regularly output of the forked process
---
.../plugin/surefire/AbstractSurefireMojo.java | 15 +++-
.../surefire/booterclient/BooterSerializer.java| 5 +++
...ooterDeserializerProviderConfigurationTest.java | 2 +-
...BooterDeserializerStartupConfigurationTest.java | 2 +-
.../AbstractNoninterruptibleWritableChannel.java | 6 +++
.../util/internal/WritableBufferedByteChannel.java | 2 +
.../maven/surefire/booter/BooterConstants.java | 1 +
.../maven/surefire/booter/BooterDeserializer.java | 4 +-
.../apache/maven/surefire/booter/ForkedBooter.java | 45 ++
.../surefire/booter/ProviderConfiguration.java | 10 -
.../spi/LegacyMasterProcessChannelEncoder.java | 5 +++
11 files changed, 92 insertions(+), 5 deletions(-)
diff --git
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 38d34fb..0f92bbf 100644
---
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -809,6 +809,18 @@ public abstract class AbstractSurefireMojo
private Map jdkToolchain;
/**
+ * How often output is forced to be flushed.
+ * Useful when there is no output for N ms but some data are buffered.
+ * It will trigger a flush each configured interval to ensure
+ * data don't stay blocked in a buffer.
+ * Setting it to 0 disable that feature.
+ *
+ * @since 3.0.0-M6
+ */
+@Parameter( defaultValue = "0" )
+private long outputFlushInterval;
+
+/**
*
*/
@Component
@@ -1850,7 +1862,8 @@ public abstract class AbstractSurefireMojo
testSuiteDefinition,
providerProperties, null,
false, cli,
getSkipAfterFailureCount(),
Shutdown.parameterOf( getShutdown()
),
-
getForkedProcessExitTimeoutInSeconds() );
+
getForkedProcessExitTimeoutInSeconds(),
+ outputFlushInterval );
}
private static Map toStringProperties( Properties
properties )
diff --git
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index c8aee3c..6e62079 100644
---
a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -53,6 +53,7 @@ import static
org.apache.maven.surefire.booter.BooterConstants.FORKTESTSET_PREFE
import static
org.apache.maven.surefire.booter.BooterConstants.INCLUDES_PROPERTY_PREFIX;
import static
org.apache.maven.surefire.booter.BooterConstants.ISTRIMSTACKTRACE;
import static
org.apache.maven.surefire.booter.BooterConstants.MAIN_CLI_OPTIONS;
+import static
org.apache.maven.surefire.booter.BooterConstants.OUTPUT_FLUSH_INTERVAL_MS;
import static org.apache.maven.surefire.booter.BooterConstants.PLUGIN_PID;
import static org.apache.maven.surefire.booter.BooterConstants.PROCESS_CHECKER;
import static
org.apache.maven.surefire.booter.BooterConstants.PROVIDER_CONFIGURATION;
@@ -181,6 +182,10 @@ class BooterSerializer
properties.addList( mainCliOptions, MAIN_CLI_OPTIONS );
}
properties.setNullableProperty( SYSTEM_EXIT_TIMEOUT, toString(
providerConfiguration.getSystemExitTimeout() ) );
+properties.setNullableProperty(
+OUTPUT_FLUSH_INTERVAL_MS,
+providerConfiguration.getOutputFlushInterval() == null
+? "0" : toString(
providerConfiguration.getOutputFlushInterval() ) );
File surefireTmpDir = forkConfiguration.getTempDirectory();
boolean debug = forkConfiguration.isDebug();
diff --git
a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index 7a08390..e62d1c3 100644
---
a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderCo