slachiewicz opened a new issue, #3574:
URL: https://github.com/apache/maven-surefire/issues/3574

   Surefire launches the forked JVM through maven-shared-utils `Commandline`, 
which wraps the command in `/bin/sh -c` on Unix and `cmd.exe /X /C` on Windows. 
That wrapper is behind several issues: #3549 (the jstack extension got the PID 
of `/bin/sh`, worked around in #3552 by walking down to the child), #3128 and 
#3046 (paths with spaces mangled by cmd.exe quoting), and the long-command-line 
workarounds. Surefire uses none of what the wrapper offers: the fork is `java` 
with arguments, an environment and a working directory, and 
`CommandlineExecutor` reads the streams itself. After #3573 the shared-utils 
code surefire still reaches through its shaded copy is `cli` (`Commandline`, 
`CommandLineException`, `ShutdownHookUtils`, 8 files), 
`io.SelectorUtils`/`MatchPatterns` (3 files), 
`xml.PrettyPrintXMLWriter`/`XMLWriter` (1 file) and `logging` (4 files).
   
   Plan, one PR per step:
   
   1. Start the fork with `ProcessBuilder`. `lazytestprovider.Commandline` 
becomes surefire's own small class (executable, arguments, quote-aware 
`argLine` splitting copied from shared-utils `translateCommandline`, 
environment with the existing exclusion list, working directory, a loggable 
`toString()`), `CommandlineExecutor` takes it and calls 
`ProcessBuilder.start()`, failures surface as `IOException` instead of 
`CommandLineException`, and `ShutdownHookUtils` (two methods) moves into 
`surefire-api`. No shell wrapper on any platform: the forked JVM is the direct 
child, so the PID lookup from #3552 becomes a plain `Process.pid()`, and 
cmd.exe quoting no longer applies to the classpath or `argLine`. Windows needs 
a real run before this leaves draft.
   2. `SelectorUtils` and `MatchPatterns` live in `surefire-api`, which lands 
on users' test classpath, so a dependency is not an option; copy the two 
classes (about 600 lines) into `surefire-api`.
   3. `PrettyPrintXMLWriter`/`XMLWriter` in `StatelessXmlReporter` are on the 
plugin side; take them from plexus-xml.
   4. `logging` stays until the plugin's Maven floor is 3.10 and 
`MessageBuilderFactory` is available; after step 3 the shaded shared-utils is 
reduced to that package.
   
   Part of apache/maven-shared-utils#452.
   


-- 
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