You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Ivan Iliev (Jira)" <ji...@apache.org> on 2023/01/13 16:29:00 UTC

[jira] [Created] (SUREFIRE-2142) user.dir is changed in forkCount=0

Ivan Iliev created SUREFIRE-2142:
------------------------------------

             Summary: user.dir is changed in forkCount=0
                 Key: SUREFIRE-2142
                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2142
             Project: Maven Surefire
          Issue Type: Bug
    Affects Versions: 3.0.0-M5
            Reporter: Ivan Iliev


When *not* forking the tests, the 
{code:java}
user.dir{code}
system property is changed to the current [<workingDirectory> |https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#workingDirectory]. This can have a fatal effect on code which reads files via for ex. FileInputStream.

For ex. in a multi module maven project like:
/root/f1/p1/p2/m1
/root/f2/m2

such that the reactor builds m2 -> m1, and m2 executes in forkCount=0, the user.dir will be set to /root/f2/m2, then any code in m1's build pipeline which tries to open a file(even with absolute path) via FileInputStream will fail.

See

 
{code:java}
org.apache.maven.plugin.surefire.AbstractSurefireMojo#setupProperties ->
result.setProperty( "user.dir", getWorkingDirectory().getAbsolutePath() ); ->
org.apache.maven.plugin.surefire.AbstractSurefireMojo#executeProvider -> 
if ( isNotForking() )
{
createCopyAndReplaceForkNumPlaceholder( effectiveProperties, 1 ).copyToSystemProperties();
...
}
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)