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/01/24 00:45:52 UTC

[maven-surefire] branch release/2.22.3 updated (bb839bb -> 8f02db1)

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

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


    from bb839bb  enabled and fixed tests in surefire-junit-platform
     new d44dd1d  [SUREFIRE-1865] ChecksumCalculator getSha1 does not compute checksums correctly
     new 92b65de  [SUREFIRE-1908] Wish by Stackoverflow - Documented strategy with parallel Java packages
     new cbaaa09  [SUREFIRE-1912] user.dir should not be set lazily within the surefire fork JVM
     new f2db744  [SUREFIRE-1913] system properties should be restored after the in-process tests have been executed
     new 8f02db1  jdk1.7 build fix with m-compiler-p:3.9.0

The 5 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:
 .../plugin/surefire/AbstractSurefireMojo.java      | 23 ++++++--
 .../surefire/booterclient/ChecksumCalculator.java  |  5 +-
 .../booterclient/ChecksumCalculatorTest.java       | 26 +++------
 .../org/apache/maven/surefire/JUnit4SuiteTest.java |  2 +
 .../fork-options-and-parallel-execution.apt.vm     | 64 ++++++++++++++++++++++
 .../surefire-855-failsafe-use-bundle/pom.xml       |  5 ++
 .../surefire-855-failsafe-use-jar/pom.xml          |  5 ++
 .../surefire-855-failsafe-use-war/pom.xml          |  5 ++
 8 files changed, 111 insertions(+), 24 deletions(-)
 copy surefire-its/src/test/resources/surefire-1080-parallel-fork-double-test/src/test/java/com/cal/SimpleTest.java => maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculatorTest.java (69%)

[maven-surefire] 04/05: [SUREFIRE-1913] system properties should be restored after the in-process tests have been executed

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

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

commit f2db7449933ec3905bf96a19ba7c6fa9368f27c4
Author: tibordigana <ti...@gmail.com>
AuthorDate: Sat May 8 23:33:46 2021 +0200

    [SUREFIRE-1913] system properties should be restored after the in-process tests have been executed
    
    (cherry picked from commit e9e5193feee08230e934f5f0fbdc8f69eda0fb0c)
---
 .../maven/plugin/surefire/AbstractSurefireMojo.java      | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 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 be4ffea..2aa6dd4 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
@@ -1167,11 +1167,19 @@ public abstract class AbstractSurefireMojo
 
         if ( isNotForking() )
         {
-            createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
+            Properties originalSystemProperties = (Properties) System.getProperties().clone();
+            try
+            {
+                createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
 
-            InPluginVMSurefireStarter surefireStarter =
-                createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters, scanResult );
-            return surefireStarter.runSuitesInProcess( scanResult );
+                InPluginVMSurefireStarter surefireStarter =
+                    createInprocessStarter( provider, classLoaderConfiguration, runOrderParameters, scanResult );
+                return surefireStarter.runSuitesInProcess( scanResult );
+            }
+            finally
+            {
+                System.setProperties( originalSystemProperties );
+            }
         }
         else
         {

[maven-surefire] 03/05: [SUREFIRE-1912] user.dir should not be set lazily within the surefire fork JVM

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

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

commit cbaaa097890078123aca60a8b1bd641f13754dbc
Author: tibordigana <ti...@gmail.com>
AuthorDate: Tue May 4 21:54:02 2021 +0200

    [SUREFIRE-1912] user.dir should not be set lazily within the surefire fork JVM
    
    (cherry picked from commit dceea49f62582a2a2820a5fe72e22d65c45f23ed)
---
 .../org/apache/maven/plugin/surefire/AbstractSurefireMojo.java     | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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 2e916d8..be4ffea 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
@@ -1090,7 +1090,6 @@ public abstract class AbstractSurefireMojo
                                                              getUserProperties(), sysProps );
 
         result.setProperty( "basedir", getBasedir().getAbsolutePath() );
-        result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() );
         result.setProperty( "localRepository", getLocalRepository().getBasedir() );
         if ( isForking() )
         {
@@ -1114,10 +1113,16 @@ public abstract class AbstractSurefireMojo
                         );
             }
         }
+        else
+        {
+            result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() );
+        }
+
         if ( getConsoleLogger().isDebugEnabled() )
         {
             showToLog( result, getConsoleLogger() );
         }
+
         return result;
     }
 

[maven-surefire] 05/05: jdk1.7 build fix with m-compiler-p:3.9.0

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

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

commit 8f02db1ca41c57a36638f5c39508c269f953ba18
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Mon Jan 24 01:37:38 2022 +0100

    jdk1.7 build fix with m-compiler-p:3.9.0
---
 .../src/test/resources/surefire-855-failsafe-use-bundle/pom.xml      | 5 +++++
 .../src/test/resources/surefire-855-failsafe-use-jar/pom.xml         | 5 +++++
 .../src/test/resources/surefire-855-failsafe-use-war/pom.xml         | 5 +++++
 3 files changed, 15 insertions(+)

diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
index e0d4ee2..280218c 100644
--- a/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
+++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-bundle/pom.xml
@@ -66,6 +66,11 @@
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.8.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <version>2.3</version>
         <executions>
diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml
index 01dc71e..f77705a 100644
--- a/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml
+++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-jar/pom.xml
@@ -65,6 +65,11 @@
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.8.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <version>2.3</version>
         <executions>
diff --git a/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml b/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml
index 2d2cd5d..3361e8c 100644
--- a/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml
+++ b/surefire-its/src/test/resources/surefire-855-failsafe-use-war/pom.xml
@@ -66,6 +66,11 @@
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.8.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-source-plugin</artifactId>
         <version>2.3</version>
         <executions>

[maven-surefire] 02/05: [SUREFIRE-1908] Wish by Stackoverflow - Documented strategy with parallel Java packages

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

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

commit 92b65de54fef013422d2c9707cf3630f1f01270a
Author: V. Mark Lehky <ml...@switch.com>
AuthorDate: Thu Apr 15 12:05:18 2021 -0700

    [SUREFIRE-1908] Wish by Stackoverflow - Documented strategy with parallel Java packages
    
    (cherry picked from commit 27ef162711425807a3647dc33e8c5267566d46dc)
---
 .../fork-options-and-parallel-execution.apt.vm     | 64 ++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
index 1add809..fe9d2f6 100644
--- a/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/fork-options-and-parallel-execution.apt.vm
@@ -181,6 +181,70 @@ Fork Options and Parallel Test Execution
   See the keywords: <volatile>, <synchronized>, <<immutable>> and <final> in
   {{{https://jcp.org/en/jsr/detail?id=133}Java Memory Model - JSR-133}}.
 
+* Parallel Test-Suite Execution
+
+  ${project.artifactId}'s notion of "suite" is related to
+  {{{https://github.com/junit-team/junit4/wiki/Aggregating-tests-in-suites}junit4 Suite}}. 
+
+  For example, say your tests are laid out like this:
+
++---+
+src/test/java
++-features.areaA
+| +-SomeTest.java
+| +-AnotherTest.java
++-features.areaB
+| +-DifferentTest.java
+| +-OtherTest.java
++---+
+
+  You would add a TestSuite.java for each package, that would look something like:
+
++---+
+package features.areaA;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    SomeTest.class,
+    AnotherTest.class
+})
+public class TestSuite {
+}
++---+
+
+  and similarly for <<<package features.areaB>>>. You would then configure
+  ${project.artifactId} as follows:
+
++---+
+<plugin>
+  <groupId>${project.groupId}</groupId>
+  <artifactId>${project.artifactId}</artifactId>
+  <version>${project.version}</version>
+  <configuration>
+    <includes>
+      <include>features.*.TestSuite</include>
+    </includes>
+    <parallel>suites</parallel>
+    <threadCountSuites>2</threadCountSuites>
+    <perCoreThreadCount>false</perCoreThreadCount>
+  </configuration>
+</plugin>
++---+
+
+  This would then run up to 2 threads, and each thread would be fed a TestSuite.class,
+  one at a time. The test classes within that Suite would be executed sequentially
+  in the order specified the Suite class.
+
+  Note that the <<<perCoreThreadCount>>> is a "multiplier" of a sorts. With this
+  parameter set to true (the default value), you will get the specified number of
+  threads <<per CPU core>>.
+
+  Also note that in this specific case <<<threadCountSuites=2>>> has the same effect
+  as <<<threadCount=2>>>, since we are using <<<parallel=suites>>>.
+
 * Parallel ${project.artifactId} Execution in Multi-Module Maven Parallel Build
 
   Maven core allows building modules of multi-module projects in parallel with

[maven-surefire] 01/05: [SUREFIRE-1865] ChecksumCalculator getSha1 does not compute checksums correctly

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

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

commit d44dd1d6bf6c49abd73f6fcb52d7e62b5904540f
Author: Gian Merlino <gi...@gmail.com>
AuthorDate: Sun Dec 6 02:09:44 2020 +0100

    [SUREFIRE-1865] ChecksumCalculator getSha1 does not compute checksums correctly
    
    Two changes:
    
    1) Fix length computation to use bytes, not characters.
    
    2) Use UTF_8 instead of ISO_8859_1 for encoding, because configs can contain
       characters that fall outside the ISO_8859_1 character set.
    
    (cherry picked from commit 1da3462303afe17c030cb884953f11133b8b4796)
---
 .../surefire/booterclient/ChecksumCalculator.java  |  5 +--
 .../booterclient/ChecksumCalculatorTest.java       | 38 ++++++++++++++++++++++
 .../org/apache/maven/surefire/JUnit4SuiteTest.java |  2 ++
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
index 5931f9e..5f32be1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculator.java
@@ -29,7 +29,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import static org.apache.maven.surefire.util.internal.StringUtils.ISO_8859_1;
+import static org.apache.maven.surefire.util.internal.StringUtils.UTF_8;
 
 /**
  * @author Kristian Rosenvold
@@ -155,7 +155,8 @@ public class ChecksumCalculator
         {
             MessageDigest md = MessageDigest.getInstance( "SHA-1" );
             String configValue = getConfig();
-            md.update( configValue.getBytes( ISO_8859_1 ), 0, configValue.length() );
+            byte[] configBytes = configValue.getBytes( UTF_8 );
+            md.update( configBytes );
             byte[] sha1hash = md.digest();
             return asHexString( sha1hash );
         }
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculatorTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculatorTest.java
new file mode 100644
index 0000000..e5b91d3
--- /dev/null
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ChecksumCalculatorTest.java
@@ -0,0 +1,38 @@
+package org.apache.maven.plugin.surefire.booterclient;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link ChecksumCalculator}.
+ */
+public class ChecksumCalculatorTest
+{
+    @Test
+    public void testGetSha1()
+    {
+        final ChecksumCalculator calculator = new ChecksumCalculator();
+        calculator.add( "foö 🔥 Россия 한국 中国" );
+        assertEquals( "3421557EBE66A4741CA51C8D610AB1AB41D1693B", calculator.getSha1() );
+    }
+}
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
index 728cef3..faf04b1 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/JUnit4SuiteTest.java
@@ -31,6 +31,7 @@ import org.apache.maven.plugin.surefire.SurefireReflectorTest;
 import org.apache.maven.plugin.surefire.SurefirePropertiesTest;
 import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerProviderConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.BooterDeserializerStartupConfigurationTest;
+import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculatorTest;
 import org.apache.maven.plugin.surefire.booterclient.DefaultForkConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.ForkConfigurationTest;
 import org.apache.maven.plugin.surefire.booterclient.ForkingRunListenerTest;
@@ -95,6 +96,7 @@ public class JUnit4SuiteTest extends TestCase
         }
         suite.addTest( new JUnit4TestAdapter( ScannerUtilTest.class ) );
         suite.addTest( new JUnit4TestAdapter( MojoMocklessTest.class ) );
+        suite.addTest( new JUnit4TestAdapter( ChecksumCalculatorTest.class ) );
         return suite;
     }
 }