Skip to content

Commit 7219725

Browse files
jerome-chetelat-sonarsourcesonartech
authored andcommitted
SONAR-27130 Fix is_file test on Windows by avoiding path relativize
1 parent fdec1e6 commit 7219725

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/predicates/DefaultFilePredicatesTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,8 @@ public void is_file() throws Exception {
151151
Files.createParentDirs(javaFile.file());
152152
Files.touch(javaFile.file());
153153

154-
// relative file - normalize path to use forward slashes for cross-platform compatibility
155-
Path relativePath = moduleBasePath.relativize(javaFile.path());
156-
String normalizedPath = relativePath.toString().replace('\\', '/');
157-
assertThat(predicates.is(new File(normalizedPath)).apply(javaFile)).isTrue();
154+
// relative file
155+
assertThat(predicates.is(new File(javaFile.relativePath())).apply(javaFile)).isTrue();
158156

159157
// absolute file
160158
assertThat(predicates.is(javaFile.file()).apply(javaFile)).isTrue();

0 commit comments

Comments
 (0)