[GitHub] [maven-surefire] slawekjaranowski commented on a diff in pull request #505: [SUREFIRE-2055] Always show random seed

2022-04-09 Thread GitBox


slawekjaranowski commented on code in PR #505:
URL: https://github.com/apache/maven-surefire/pull/505#discussion_r846689352


##
surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java:
##
@@ -55,7 +55,7 @@ public DefaultRunOrderCalculator( RunOrderParameters 
runOrderParameters, int thr
 this.runOrder = runOrderParameters.getRunOrder();
 this.sortOrder = this.runOrder.length > 0 ? getSortOrderComparator( 
this.runOrder[0] ) : null;
 Long runOrderRandomSeed = runOrderParameters.getRunOrderRandomSeed();
-this.random = new Random( runOrderRandomSeed == null ? 
System.nanoTime() : runOrderRandomSeed );
+random = runOrderRandomSeed == null ? null : new Random( 
runOrderRandomSeed );

Review Comment:
   IMHO here `runOrderParameters.getRunOrderRandomSeed();` never be null



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a diff in pull request #505: [SUREFIRE-2055] Always show random seed

2022-04-09 Thread GitBox


slawekjaranowski commented on code in PR #505:
URL: https://github.com/apache/maven-surefire/pull/505#discussion_r846689054


##
surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java:
##
@@ -55,7 +55,7 @@ public DefaultRunOrderCalculator( RunOrderParameters 
runOrderParameters, int thr
 this.runOrder = runOrderParameters.getRunOrder();
 this.sortOrder = this.runOrder.length > 0 ? getSortOrderComparator( 
this.runOrder[0] ) : null;
 Long runOrderRandomSeed = runOrderParameters.getRunOrderRandomSeed();
-this.random = new Random( runOrderRandomSeed == null ? 
System.nanoTime() : runOrderRandomSeed );
+random = runOrderRandomSeed == null ? null : new Random( 
runOrderRandomSeed );

Review Comment:
   Why change in this way ...?
   When `rundom` will be null we will have NPE from `Collections.shuffle( 
testClasses, random );` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a diff in pull request #505: [SUREFIRE-2055] Always show random seed

2022-04-06 Thread GitBox


slawekjaranowski commented on code in PR #505:
URL: https://github.com/apache/maven-surefire/pull/505#discussion_r844261998


##
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##
@@ -3114,9 +3114,12 @@ protected void warnIfIllegalFailOnFlakeCount() throws 
MojoFailureException
 
 private void printDefaultSeedIfNecessary()
 {
-if ( getRunOrderRandomSeed() == null && getRunOrder().equals( 
RunOrder.RANDOM.name() ) )
+if ( getRunOrder().equals( RunOrder.RANDOM.name() ) )
 {
-setRunOrderRandomSeed( System.nanoTime() );
+if ( getRunOrderRandomSeed() == null )
+{
+setRunOrderRandomSeed( System.nanoTime() );

Review Comment:
   `runOrderRandomSeed`  is never NULLm if is not provided it will be set to 
`nanoTime`.
   
   Currently is printed only when is not given in configuration, change 
introduce to print always - also if is given by configuration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [maven-surefire] slawekjaranowski commented on a diff in pull request #505: [SUREFIRE-2055] Always show random seed

2022-04-06 Thread GitBox


slawekjaranowski commented on code in PR #505:
URL: https://github.com/apache/maven-surefire/pull/505#discussion_r844184941


##
surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java:
##
@@ -97,7 +97,17 @@ public void testRandomJUnit4SameSeed()
 }
 }
 }
-
+
+@Test
+public void testRandomJUnit4PrintSeed()
+{
+long seed = 0L;
+OutputValidator validator = executeWithRandomOrder( "junit4", seed );
+validator.verifyTextInLog( "To reproduce ordering use flag" );
+validator = executeWithRandomOrder( "junit4" );
+validator.verifyTextInLog( "To reproduce ordering use flag" );

Review Comment:
   please consider to split into two test, eg:
   - testRandomJUnit4PrintSeedWithGivenSeed
   - testRandomJUnit4PrintSeedWithNoGivenSeed
   



##
surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java:
##
@@ -97,7 +97,17 @@ public void testRandomJUnit4SameSeed()
 }
 }
 }
-
+
+@Test
+public void testRandomJUnit4PrintSeed()
+{
+long seed = 0L;
+OutputValidator validator = executeWithRandomOrder( "junit4", seed );
+validator.verifyTextInLog( "To reproduce ordering use flag" );
+validator = executeWithRandomOrder( "junit4" );
+validator.verifyTextInLog( "To reproduce ordering use flag" );

Review Comment:
   please consider to split into two test, eg:
   - testRandomJUnit4PrintSeedWithGivenSeed
   - testRandomJUnit4PrintSeedWithNoGivenSeed
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org