cwegener-79 opened a new pull request, #3475:
URL: https://github.com/apache/maven-surefire/pull/3475

   `ForkStarter#isForkJvmDifferentFromBuildJvm` compares the JDK home of the 
tests with Maven's own JDK home using plain `File#equals`:
   
   ```java
   private boolean isForkJvmDifferentFromBuildJvm() {
       File testsJdkHome = forkConfiguration.getJdkForTests().getJdkHome();
       return testsJdkHome != null && !testsJdkHome.equals(toJdkHomeFromJre());
   }
   ```
   
   Two different spellings of the same directory therefore count as two 
different JDKs. This is easy to hit on CI machines, where the JDK is often 
reached through a symbolic link or an automounted path. 
   
   Since #3444, that comparison decides whether Surefire starts an extra 
short-lived fork to list the test classes. When both paths refer to the same 
JDK, that fork is pure overhead: one additional JVM startup per module, for 
every build.
   
   ### What this PR does
   
   Canonicalizes both paths before comparing them, falling back to the absolute 
path when the file system cannot be queried (unreadable directory, missing 
path).
   
   ### Verification
   
   * New unit tests in `ForkStarterTest` cover relative segments, a symbolic 
link (skipped via assumption on platforms that do not allow creating one) and 
two genuinely different directories.
   * Checked manually on Linux with a project using `forkCount=4` and `<jvm>` 
pointing at a symlink to the running JDK:
     * before: an extra fork is started and 
`target/surefire/surefire-discovered-tests*.txt` is written,
     * after: neither happens, and the tests run exactly as before.
   
   No behaviour changes when the test JDK really is a different one - the 
listing fork is still used in that case.
   
   
   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [X] Each commit in the pull request should have a meaningful subject line 
and body.
    - [X] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
    - [X] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will 
          be performed on your pull request automatically.
    - [ ] You have run the integration tests successfully (`mvn -Prun-its clean 
install`). --> Was not possible in my infrastructure
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under 
   the [Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [X] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to