jib icon indicating copy to clipboard operation
jib copied to clipboard

test: windows path resolution

Open mpeddada1 opened this issue 1 year ago • 2 comments

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:

  • [ ] Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose.
  • [ ] Ensure that your implementation plan is approved by the team.
  • [ ] Verify that integration tests and unit tests are passing after the change.
  • [ ] Address all checkstyle issues. Refer to the style guide.

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

Fixes #<issue_number_goes_here> 🛠️

mpeddada1 avatar Dec 21 '23 02:12 mpeddada1

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.

mpeddada1 avatar Dec 21 '23 16:12 mpeddada1

Quality Gate Failed Quality Gate failed

Failed conditions

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

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Dec 21 '23 20:12 sonarqubecloud[bot]