GoogleContainerTools / jib

🏗 Build container images for your Java applications.
Apache License 2.0
13.58k stars 1.43k forks source link

test: windows path resolution #4159

Open mpeddada1 opened 8 months ago

mpeddada1 commented 8 months ago

Thank you for your interest in contributing! For general guidelines, please refer to the contributing guide.

Before filing a pull request, make sure to do the following:

This helps to reduce the chance of having a pull request rejected.

Fixes # 🛠️

mpeddada1 commented 8 months ago

Modifying test to assertThat(testJibExtension.getExtraDirectories().getPaths().get(0).getFrom()) .isEqualTo(fakeProject.getProjectDir().toPath().resolve("foo")); in a34d24d236eb3ac54ce0f86a6f614e0e2403d8c9 results in tests passing in windows and failing with the following error in ubuntu:

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties FAILED
    expected: /tmpfs/src/github/jib/jib-gradle-plugin/build/tmp/test/work/gradle16051347658540989475projectDir/foo
    but was : /foo
        at app//com.google.cloud.tools.jib.gradle.JibExtensionTest.testProperties(JibExtensionTest.java:525)

com.google.cloud.tools.jib.gradle.JibPluginTest > testLazyEvalForExtraDirectories_individualPaths STANDARD_OUT
    Downloading https://services.gradle.org/distributions/gradle-8.0-bin.zip

Further exploration of the return values in the logic shows a difference starting at ExtraDirectoryParameters#getFrom. Verified through printing the value od System.out.println(from.getSingleFile().toPath()); at https://github.com/GoogleContainerTools/jib/pull/4159/commits/cfecdc83c733f5ca548cf77b1c00def08b043e84 which results in the following log statements:

  WINDOWS PATH TEST
    \foo
    VALUE OF FROM
    file collection
    VALUE OF FROM
    file collection
    VALUE OF GET FROM
    C:\tmpfs\src\github\jib\jib-gradle-plugin\build\tmp\test\work\gradle1471789139889995471projectDir\foo

On the other hand, ubuntu's log statements show:

com.google.cloud.tools.jib.gradle.JibExtensionTest > testProperties STANDARD_OUT
   .  . .
    VALUE OF GET FROM
    /foo

However, note that in JibExtenisonTest#testExtraDirectories(), the paths seem to always resolve to the absolute path in both windows and ubuntu. The difference occurs when we use System properties to specify the file path.

sonarcloud[bot] commented 8 months ago

Quality Gate Failed Quality Gate failed

Failed conditions

0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud