Closed hohwille closed 2 weeks ago
Seems I did something wrong. My code/test behaves differently on Linux and therefore fails:
[ERROR] Tests run: 6, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.015 s <<< FAILURE! -- in com.devonfw.tools.ide.os.WindowsPathSyntaxTest
[ERROR] com.devonfw.tools.ide.os.WindowsPathSyntaxTest.testMsys -- Time elapsed: 0.007 s <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: "/c/Windows/system32/drivers/etc/hosts"
but was: "C:\Windows\system32\drivers\etc\hosts"
Seems that Path
on Linux represents the exact path given as string differently than on Windows...
Ok the Linux/Mac error is a nice one:
If we do Path.of("C:\Windows\system32\drivers\etc\hosts")
on Windows, we get the proper absolute path while on Linux or Mac, we get a relative Path
with just one segment (file or folder) named C:\Windows\system32\drivers\etc\hosts
.
OS abstraction is usually great in Java and you get reproducible behavior on any OS but not work here since the FileSystem implementation is intentionally OS specific. So either we have to ignore such tests if we are not on Windows or we have to build in ugly workarounds/hacks for it...
With the missing change you pushed, output looks good now for env
on Windows. However for env --bash
, some variables are still not converted correctly:
ide> env --bash
export PATH="/c/projects/IDEasy/software/node:/ [...]
[...]
export AWS_SHARED_CREDENTIALS_FILE="C:\projects\IDEasy\conf\aws\credentials"
IDE_HOME="/c/projects/IDEasy"
export MAVEN_ARGS="-s C:\projects\IDEasy\conf\mvn\settings.xml"
[...]
I have updated, tested, and debugged my code with more care and detail.
export AWS_SHARED_CREDENTIALS_FILE="C:\projects\IDEasy\conf\aws\credentials"
This is fixed on my end now.
export MAVEN_ARGS="-s C:\projects\IDEasy\conf\mvn\settings.xml"
I added a change to "fix" this but commented it out since it is most probably correct as is and "fixing" it to git-bash syntax might even break maven.
We can test this and if it works with maven (even without IDEasy involved) properly with git-bash syntax, we can comment in the out-commented code to avoid potential confusion.
However, in general on Windows the Windows Paths are typically correct and even required for native processes. Only to make things working in git-bash itself, we need all this messy path conversion stuff.
I also have some doubts that converting M2_REPO
to git-bash syntax will be correct and not cause any maven bug.
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java | 2 | 74.07% | ||
com/devonfw/tools/ide/variable/VariableDefinition.java | 3 | 57.14% | ||
com/devonfw/tools/ide/environment/EnvironmentVariablesMap.java | 5 | 60.0% | ||
com/devonfw/tools/ide/variable/VariableDefinitionPath.java | 5 | 55.56% | ||
com/devonfw/tools/ide/common/SystemPath.java | 8 | 76.87% | ||
com/devonfw/tools/ide/context/IdeContext.java | 11 | 42.55% | ||
com/devonfw/tools/ide/environment/AbstractEnvironmentVariables.java | 12 | 78.24% | ||
com/devonfw/tools/ide/os/WindowsPathSyntax.java | 15 | 73.13% | ||
com/devonfw/tools/ide/process/ProcessContextImpl.java | 21 | 75.49% | ||
com/devonfw/tools/ide/context/AbstractIdeContext.java | 82 | 56.91% | ||
<!-- | Total: | 164 | --> |
Totals | |
---|---|
Change from base Build 9515396777: | -0.05% |
Covered Lines: | 4749 |
Relevant Lines: | 7589 |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java | 2 | 74.07% | ||
com/devonfw/tools/ide/variable/VariableDefinition.java | 3 | 57.14% | ||
com/devonfw/tools/ide/environment/EnvironmentVariablesMap.java | 5 | 60.0% | ||
com/devonfw/tools/ide/variable/VariableDefinitionPath.java | 5 | 55.56% | ||
com/devonfw/tools/ide/context/IdeContext.java | 11 | 42.55% | ||
com/devonfw/tools/ide/environment/AbstractEnvironmentVariables.java | 12 | 78.24% | ||
com/devonfw/tools/ide/common/SystemPath.java | 14 | 76.87% | ||
com/devonfw/tools/ide/os/WindowsPathSyntax.java | 15 | 73.13% | ||
com/devonfw/tools/ide/process/ProcessContextImpl.java | 21 | 75.49% | ||
com/devonfw/tools/ide/context/AbstractIdeContext.java | 82 | 56.91% | ||
<!-- | Total: | 170 | --> |
Totals | |
---|---|
Change from base Build 9515396777: | -0.05% |
Covered Lines: | 4749 |
Relevant Lines: | 7589 |
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java | 2 | 74.07% | ||
com/devonfw/tools/ide/variable/VariableDefinition.java | 3 | 57.14% | ||
com/devonfw/tools/ide/environment/EnvironmentVariablesMap.java | 5 | 60.0% | ||
com/devonfw/tools/ide/variable/VariableDefinitionPath.java | 5 | 55.56% | ||
com/devonfw/tools/ide/context/IdeContext.java | 11 | 42.55% | ||
com/devonfw/tools/ide/environment/AbstractEnvironmentVariables.java | 12 | 78.24% | ||
com/devonfw/tools/ide/common/SystemPath.java | 14 | 76.87% | ||
com/devonfw/tools/ide/os/WindowsPathSyntax.java | 15 | 73.01% | ||
com/devonfw/tools/ide/process/ProcessContextImpl.java | 21 | 75.49% | ||
com/devonfw/tools/ide/context/AbstractIdeContext.java | 82 | 56.81% | ||
<!-- | Total: | 170 | --> |
Totals | |
---|---|
Change from base Build 9552528477: | -0.05% |
Covered Lines: | 4754 |
Relevant Lines: | 7615 |
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java | 2 | 74.07% | ||
com/devonfw/tools/ide/variable/VariableDefinition.java | 3 | 57.14% | ||
com/devonfw/tools/ide/environment/EnvironmentVariablesMap.java | 5 | 60.0% | ||
com/devonfw/tools/ide/variable/VariableDefinitionPath.java | 5 | 55.56% | ||
com/devonfw/tools/ide/context/IdeContext.java | 11 | 42.55% | ||
com/devonfw/tools/ide/environment/AbstractEnvironmentVariables.java | 12 | 78.24% | ||
com/devonfw/tools/ide/common/SystemPath.java | 14 | 76.87% | ||
com/devonfw/tools/ide/os/WindowsPathSyntax.java | 15 | 73.01% | ||
com/devonfw/tools/ide/process/ProcessContextImpl.java | 21 | 75.49% | ||
com/devonfw/tools/ide/context/AbstractIdeContext.java | 82 | 56.81% | ||
<!-- | Total: | 170 | --> |
Totals | |
---|---|
Change from base Build 9552528477: | -0.05% |
Covered Lines: | 4754 |
Relevant Lines: | 7615 |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java | 2 | 74.07% | ||
com/devonfw/tools/ide/variable/VariableDefinition.java | 3 | 57.14% | ||
com/devonfw/tools/ide/environment/EnvironmentVariablesMap.java | 5 | 60.0% | ||
com/devonfw/tools/ide/variable/VariableDefinitionPath.java | 5 | 55.56% | ||
com/devonfw/tools/ide/context/IdeContext.java | 11 | 42.55% | ||
com/devonfw/tools/ide/environment/AbstractEnvironmentVariables.java | 12 | 78.24% | ||
com/devonfw/tools/ide/common/SystemPath.java | 14 | 76.87% | ||
com/devonfw/tools/ide/os/WindowsPathSyntax.java | 15 | 73.01% | ||
com/devonfw/tools/ide/process/ProcessContextImpl.java | 21 | 75.49% | ||
com/devonfw/tools/ide/context/AbstractIdeContext.java | 82 | 56.81% | ||
<!-- | Total: | 170 | --> |
Totals | |
---|---|
Change from base Build 9566917428: | -0.05% |
Covered Lines: | 4761 |
Relevant Lines: | 7622 |
Fixes #321
EnvironmentCommandlet
and moved it toWindowsPathSyntax
WindowsPathSyntax
according to OS and--bash
flagWindowsPathSyntax
tocollectVariables
method ofEnvironmentVariables
that was extended with a variant taking this parameter.getValue
method that has been extended in the same way.getDefaultValueAsString
method ofVariableDefinition
that has been extended accordingly.VariableDefinitionPath
andVariableDefinitionSystemPath
now honor this new parameter to do the actual path conversion.