Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegexBasedInterpolatorTest fails when building with maven 3.4.0-SNAPSHOT #10

Closed
belingueres opened this issue Aug 19, 2016 · 3 comments
Closed

Comments

@belingueres
Copy link
Contributor

Hi,
I found a problem when building the project with a apache-maven-3.4.0-SNAPSHOT:
mvn -version:
Apache Maven 3.4.0-SNAPSHOT (a2249ce21ca1e5f28858422c3018153b8eba4d3a; 2016-08-18T17:35:14-03:00)
Maven home: C:\productos\apache-maven-3.4.0-SNAPSHOT\bin..
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_66\jre
Default locale: es_AR, platform encoding: Cp1252
OS name: "Windows 10", version: "10.0", arch: "amd64", family: "Windows"

The problem is that some tests are interpolating from environment variables using ${HOME} and ${env.HOME} but this environment variable is not defined any longer inside maven 3.4.0-SNAPSHOT mvn.cmd file.
see this commit

Setting the variable inside the mvn.cmd file corrects the problem:
if "%HOME%" == "" (set "HOME=%USERPROFILE%")
however I don't know if this is a bug or a feature in maven 3.4.0.

Should we change the tests to a different env var?
WDYT?
Gabriel

@michael-o
Copy link
Member

$HOME is not portable. One should rely on user.home. I have removed this intentionally because it was an implementation detail and nothing publically documented.
Michael

@belingueres
Copy link
Contributor Author

Thanks @michael-o .
Based on a quick search on the mvn scripts on v3.4.0-SNAPSHOT and 3.3.9, seems that environment variable MAVEN_PROJECTBASEDIR is defined in all platforms (Unix and Windows).
I that's OK I can work on a patch.

Gabriel

@michael-o
Copy link
Member

Again, MAVEN_PROJECTBASEDIR is not publically documented in the header of the shell/command script, thus it is an implementation detail. You can use JAVA_HOME which has to exist on both platforms during mvn test.

belingueres added a commit to belingueres/plexus-interpolation that referenced this issue Aug 21, 2016
…ng with maven 3.4.0-SNAPSHOT

Tests fails because the $HOME env var is no longer defined inside mvn.cmd and is not found (some tests pass even if the env var is not found!).

- Changed the OperatingSystemUtils to allow mocking the Map of env vars.
- Fixed tests to use mocking whenever the env vars are not the focus of the unit test.
- When testing with a REAL env var, it is chosen to be $JAVA_HOME since it is required to be present to run mvn script.
- Added tests to EnvarBasedValueSource and fixed.EnvarBasedValueSource.
belingueres added a commit to belingueres/plexus-interpolation that referenced this issue Aug 22, 2016
…ng with maven 3.4.0-SNAPSHOT

Tests fails because the $HOME env var is no longer defined inside mvn.cmd and is not found (some tests pass even if the env var is not found!).

- Changed the OperatingSystemUtils to allow mocking the Map of env vars.
- Fixed tests to use mocking whenever the env vars are not the focus of the unit test.
- When testing with a REAL env var, it is chosen to be $JAVA_HOME since it is required to be present to run mvn script.
- Added tests to EnvarBasedValueSource and fixed.EnvarBasedValueSource.
belingueres added a commit to belingueres/plexus-interpolation that referenced this issue May 16, 2017
commit f8f8c36727d5b1c925803b7cef419f5749de873a
Merge: a1ef097 2307195
Author: belingueres <belingueres@gmail.com>
Date:   Sun May 14 22:27:15 2017 -0300

    Merge branch 'Fix10' of https://github.com/belingueres/plexus-interpolation into Fix10

    # Conflicts:
    #	src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java

commit a1ef097
Merge: 0af4e03 0d3c1d2
Author: belingueres <belingueres@gmail.com>
Date:   Sun May 14 22:14:54 2017 -0300

    Merge remote-tracking branch 'upstream/master' into Fix10

    # Conflicts:
    #	src/test/java/org/codehaus/plexus/interpolation/fixed/FixedStringSearchInterpolatorTest.java

commit 2307195
Author: belingueres <belingueres@gmail.com>
Date:   Sat Aug 20 23:36:07 2016 -0300

    Fix codehaus-plexus#10 - RegexBasedInterpolatorTest fails when building with maven 3.4.0-SNAPSHOT

    Tests fails because the $HOME env var is no longer defined inside mvn.cmd and is not found (some tests pass even if the env var is not found!).

    - Changed the OperatingSystemUtils to allow mocking the Map of env vars.
    - Fixed tests to use mocking whenever the env vars are not the focus of the unit test.
    - When testing with a REAL env var, it is chosen to be $JAVA_HOME since it is required to be present to run mvn script.
    - Added tests to EnvarBasedValueSource and fixed.EnvarBasedValueSource.

commit 0af4e03
Author: belingueres <belingueres@gmail.com>
Date:   Sat Aug 20 23:36:07 2016 -0300

    Fix codehaus-plexus#10 - RegexBasedInterpolatorTest fails when building with maven 3.4.0-SNAPSHOT

    Tests fails because the $HOME env var is no longer defined inside mvn.cmd and is not found (some tests pass even if the env var is not found!).

    - Changed the OperatingSystemUtils to allow mocking the Map of env vars.
    - Fixed tests to use mocking whenever the env vars are not the focus of the unit test.
    - When testing with a REAL env var, it is chosen to be $JAVA_HOME since it is required to be present to run mvn script.
    - Added tests to EnvarBasedValueSource and fixed.EnvarBasedValueSource.
@olamy olamy closed this as completed in d187343 May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants