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 2015/09/08 04:45:15 UTC
[1/2] maven-surefire git commit: awaiting MasterProcessReader up in
providers
Repository: maven-surefire
Updated Branches:
refs/heads/master 78a885f8b -> e87f8807d
awaiting MasterProcessReader up in providers
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/d8770d69
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/d8770d69
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/d8770d69
Branch: refs/heads/master
Commit: d8770d69f62eb66ccd86db9341b0c96c32d54f0a
Parents: 78a885f
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Sep 8 04:43:56 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Sep 8 04:43:56 2015 +0200
----------------------------------------------------------------------
.../surefire/booter/MasterProcessReader.java | 27 ++++++++++++++++++++
.../booter/MasterProcessReaderTest.java | 10 ++++++++
.../maven/surefire/junit4/JUnit4Provider.java | 5 ++++
.../surefire/junitcore/JUnitCoreProvider.java | 7 ++++-
.../maven/surefire/testng/TestNGProvider.java | 5 ++++
5 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8770d69/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
index 8c36bd2..ab45d81 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/MasterProcessReader.java
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
+import org.apache.maven.surefire.testset.TestSetFailedException;
+
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -27,6 +29,7 @@ import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import static java.lang.Thread.State.NEW;
@@ -64,6 +67,8 @@ public final class MasterProcessReader
private final Node head = new Node();
+ private final CountDownLatch startMonitor = new CountDownLatch( 1 );
+
private volatile Node tail = head;
private static class Node
@@ -82,6 +87,27 @@ public final class MasterProcessReader
return reader;
}
+ public boolean awaitStarted()
+ throws TestSetFailedException
+ {
+ if ( state.get() == RUNNABLE )
+ {
+ try
+ {
+ startMonitor.await();
+ return true;
+ }
+ catch ( InterruptedException e )
+ {
+ throw new TestSetFailedException( e.getLocalizedMessage() );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
/**
* @param listener listener called with <em>Any</em> {@link MasterProcessCommand command type}
*/
@@ -367,6 +393,7 @@ public final class MasterProcessReader
{
public void run()
{
+ MasterProcessReader.this.startMonitor.countDown();
DataInputStream stdIn = new DataInputStream( System.in );
boolean isTestSetFinished = false;
try
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8770d69/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
index ae299c1..4e1f0d0 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/MasterProcessReaderTest.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
+import org.apache.maven.surefire.testset.TestSetFailedException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -200,6 +201,15 @@ public class MasterProcessReaderTest
}
}
+ @Test( timeout = 15000 )
+ public void shouldAwaitReaderUp()
+ throws TestSetFailedException
+ {
+ assertTrue( reader.awaitStarted() );
+ reader.stop();
+ assertFalse( reader.awaitStarted() );
+ }
+
private class SystemInputStream
extends InputStream
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8770d69/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index 2276eac..3321a82 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -166,6 +166,11 @@ public class JUnit4Provider
? createTestsDescription()
: createDescription( UNDETERMINED_TESTS_DESCRIPTION ) );
+ if ( commandsReader != null )
+ {
+ commandsReader.awaitStarted();
+ }
+
for ( Class aTestsToRun : testsToRun )
{
executeTestSet( aTestsToRun, reporter, notifier );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8770d69/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index 29687ef..2c7d5c9 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -161,6 +161,11 @@ public class JUnitCoreProvider
{
JUnitCoreWrapper core = new JUnitCoreWrapper( notifier, jUnitCoreParameters, consoleLogger, isFailFast() );
+ if ( commandsReader != null )
+ {
+ commandsReader.awaitStarted();
+ }
+
core.execute( testsToRun, customRunListeners, filter );
// Rerun failing tests if rerunFailingTestsCount is larger than 0
@@ -176,13 +181,13 @@ public class JUnitCoreProvider
core.execute( testsToRun, failingMethodsFilter );
}
}
+ return reporterFactory.close();
}
finally
{
notifier.removeListeners();
closeCommandsReader();
}
- return reporterFactory.close();
}
private boolean isRerunFailingTests()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8770d69/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
index 77b5c75..a317042 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
@@ -94,6 +94,11 @@ public class TestNGProvider
registerPleaseStopListener();
}
+ if ( commandsReader != null )
+ {
+ commandsReader.awaitStarted();
+ }
+
final ReporterFactory reporterFactory = providerParameters.getReporterFactory();
if ( isTestNGXmlTestSuite( testRequest ) )
[2/2] maven-surefire git commit: build fix for race conditions
Posted by ti...@apache.org.
build fix for race conditions
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/e87f8807
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/e87f8807
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/e87f8807
Branch: refs/heads/master
Commit: e87f8807d2594c31b5b69317a6b815416636e6e7
Parents: d8770d6
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Sep 8 04:44:47 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Sep 8 04:44:47 2015 +0200
----------------------------------------------------------------------
.../test/resources/fail-fast-junit/src/test/java/pkg/ATest.java | 3 ++-
.../test/resources/fail-fast-junit/src/test/java/pkg/BTest.java | 2 +-
.../test/resources/fail-fast-junit/src/test/java/pkg/CTest.java | 2 +-
.../test/resources/fail-fast-junit/src/test/java/pkg/DTest.java | 2 +-
.../test/resources/fail-fast-testng/src/test/java/pkg/ATest.java | 3 ++-
.../test/resources/fail-fast-testng/src/test/java/pkg/BTest.java | 2 +-
.../test/resources/fail-fast-testng/src/test/java/pkg/CTest.java | 2 +-
.../test/resources/fail-fast-testng/src/test/java/pkg/DTest.java | 2 +-
8 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ATest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ATest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ATest.java
index 8ac8930..5a3fb4e 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ATest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ATest.java
@@ -11,7 +11,8 @@ public class ATest
public void someMethod()
throws Exception
{
- TimeUnit.MILLISECONDS.sleep( 500 );
+ // checking processros # due to very slow Windows Jenkins machines
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1200 : 500 );
throw new RuntimeException( "assert \"foo\" == \"bar\"\n" +
" |\n"
+ " false" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/BTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/BTest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/BTest.java
index a968b42..3015f40 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/BTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/BTest.java
@@ -11,7 +11,7 @@ public class BTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.SECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3 : 1 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
throw new RuntimeException();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
index 6c609d7..9865e69 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
@@ -11,7 +11,7 @@ public class CTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1500 : 500 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
index dfd5a0e..4167f67 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
@@ -11,7 +11,7 @@ public class DTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1500 : 500 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ATest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ATest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ATest.java
index acce402..b90859b 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ATest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ATest.java
@@ -10,7 +10,8 @@ public class ATest
public void someMethod()
throws InterruptedException
{
- TimeUnit.MILLISECONDS.sleep( 500 );
+ // checking processros # due to very slow Windows Jenkins machines
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1200 : 500 );
throw new RuntimeException( "assert \"foo\" == \"bar\"\n"
+ " |\n"
+ " false" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/BTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/BTest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/BTest.java
index c5c5f3b..8cdc13d 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/BTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/BTest.java
@@ -11,7 +11,7 @@ public class BTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.SECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3 : 1 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
throw new RuntimeException();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
index 6978391..8fe2faf 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
@@ -11,7 +11,7 @@ public class CTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1500 : 500 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/e87f8807/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
index 5ad8bd3..c4ffd68 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
@@ -11,7 +11,7 @@ public class DTest
throws InterruptedException
{
// checking processros # due to very slow Windows Jenkins machines
- TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 1500 : 500 );
+ TimeUnit.MILLISECONDS.sleep( Runtime.getRuntime().availableProcessors() == 1 ? 3000 : 1250 );
}
}