diff options
author | Aleksandra Bozhinoska <aleksandra.bozhinoska@sonarsource.com> | 2024-12-18 13:46:46 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-12-19 20:03:05 +0000 |
commit | 6dbb470b4e525fb4bd6b5219d0fc1a71f832c2f9 (patch) | |
tree | 106a638cc513d58d885752f40917d0cfa99cefb8 | |
parent | 8e787f57cfc0883790d651e7587e02021e576438 (diff) | |
download | sonarqube-6dbb470b4e525fb4bd6b5219d0fc1a71f832c2f9.tar.gz sonarqube-6dbb470b4e525fb4bd6b5219d0fc1a71f832c2f9.zip |
Fix failing filesystem tests due to Path issues on MacOS
-rw-r--r-- | sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java index 77af9620598..dc7057f85fc 100644 --- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java +++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java @@ -41,6 +41,7 @@ import org.sonar.api.CoreProperties; import org.sonar.api.SonarEdition; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.internal.apachecommons.io.FilenameUtils; import org.sonar.api.testfixtures.log.LogTesterJUnit5; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.PathUtils; @@ -449,7 +450,8 @@ class FileSystemMediumIT { .execute(); assertThat(result.inputFiles()).hasSize(1); - String expectedLog = String.format("File '%s' is bigger than 1MB and as consequence is removed from the analysis scope.", fileGreaterThanLimit.toPath().toRealPath()); + String expectedLog = String.format("File '%s' is bigger than 1MB and as consequence is removed from the analysis scope.", + fileGreaterThanLimit.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(logTester.logs()).contains(expectedLog); } @@ -999,12 +1001,13 @@ class FileSystemMediumIT { AnalysisResult result = tester.newAnalysis() .properties(builder - .put("sonar.sources", "src," + PathUtils.canonicalPath(xooFile2)) + .put("sonar.sources", "src," + FilenameUtils.separatorsToUnix(xooFile2.getPath())) .build()) .execute(); assertThat(result.inputFiles()).hasSize(1); - String expectedLog = String.format("File '%s' is ignored. It is not located in project basedir '%s'.", xooFile2.toPath().toRealPath(), baseDir.toPath().toRealPath()); + String expectedLog = String.format("File '%s' is ignored. It is not located in project basedir '%s'.", xooFile2.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS), + baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(logTester.logs(Level.WARN)).contains(expectedLog); } @@ -1037,17 +1040,18 @@ class FileSystemMediumIT { writeFile(moduleA, "src/sampleA.xoo", "Sample xoo\ncontent"); File xooFile2 = writeFile(baseDir, "another.xoo", "Sample xoo 2\ncontent"); + Path xooFile2Path = xooFile2.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS); AnalysisResult result = tester.newAnalysis() .properties(builder .put("sonar.modules", "moduleA") - .put("moduleA.sonar.sources", "src," + PathUtils.canonicalPath(xooFile2)) + .put("moduleA.sonar.sources", "src," + FilenameUtils.separatorsToUnix(xooFile2.getPath())) .build()) .execute(); assertThat(result.inputFiles()).hasSize(1); - Path xooFile2Path = xooFile2.toPath().toRealPath(); - Path moduleAPath = new File(baseDir, "moduleA").toPath().toRealPath(); + + Path moduleAPath = new File(baseDir, "moduleA").toPath().toRealPath(LinkOption.NOFOLLOW_LINKS); assertThat(logTester.logs(Level.WARN)) .contains(String.format("File '%s' is ignored. It is not located in module basedir '%s'.", xooFile2Path, moduleAPath)); } |