This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git

commit cfe2a7d5b0d067c335ee66ade06ac6e70a8cb82d
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 21 02:03:11 2026 +0100

    Run the absolute-path cases of DirectoryUtilsTest on Windows
    
    The test was skipped on Windows because "/foo" there has a root but no 
drive: it is not absolute and resolves against the drive of the base, while the 
expected value took the drive of the working directory. Build the absolute 
paths from the temp directory's root instead, and cover the driveless case in a 
Windows-only test.
---
 .../eclipse/aether/util/DirectoryUtilsTest.java    | 35 ++++++++++++----------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java
 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java
index 3113f9f10..a51462632 100644
--- 
a/maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java
+++ 
b/maven-resolver-util/src/test/java/org/eclipse/aether/util/DirectoryUtilsTest.java
@@ -19,15 +19,15 @@
 package org.eclipse.aether.util;
 
 import java.io.IOException;
-import java.nio.file.FileSystems;
 import java.nio.file.Files;
 import java.nio.file.Path;
 
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.api.io.TempDir;
 
 import static org.junit.jupiter.api.Assertions.*;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 public class DirectoryUtilsTest {
     @Test
@@ -46,23 +46,28 @@ public class DirectoryUtilsTest {
 
     @Test
     void expectedCasesAbsolute(@TempDir Path tmpDir) throws IOException {
-        // TODO: this test is skipped on Windows, as it is not clear which 
drive letter will `new File("/foo")`
-        // path get. According to Windows (and  assuming Java Path does 
separator change OK), "\foo" file should
-        // get resolved to CWD drive + "\foo" path, but seems Java 17 is 
different from 11 and 8 in this respect.
-        // This below WORKS on win + Java8 abd win + Java11 but FAILS on win + 
Java17
-        assumeTrue(
-                
!"WindowsFileSystem".equals(FileSystems.getDefault().getClass().getSimpleName()));
-
+        // absolute on every platform: "/foo" on Unix, "C:\foo" (the drive of 
tmpDir) on Windows
+        Path root = tmpDir.getRoot();
         Path result;
 
-        result = DirectoryUtils.resolveDirectory("/foo", tmpDir, false);
-        
assertEquals(FileSystems.getDefault().getPath("/foo").toAbsolutePath(), result);
+        result = 
DirectoryUtils.resolveDirectory(root.resolve("foo").toString(), tmpDir, false);
+        assertEquals(root.resolve("foo"), result);
+
+        result = 
DirectoryUtils.resolveDirectory(root.resolve("foo/bar").toString(), tmpDir, 
false);
+        assertEquals(root.resolve("foo/bar"), result);
 
-        result = DirectoryUtils.resolveDirectory("/foo/bar", tmpDir, false);
-        
assertEquals(FileSystems.getDefault().getPath("/foo/bar").toAbsolutePath(), 
result);
+        result = 
DirectoryUtils.resolveDirectory(root.resolve("foo/./bar/..").toString(), 
tmpDir, false);
+        assertEquals(root.resolve("foo"), result);
+    }
 
-        result = DirectoryUtils.resolveDirectory("/foo/./bar/..", tmpDir, 
false);
-        
assertEquals(FileSystems.getDefault().getPath("/foo").toAbsolutePath(), result);
+    /**
+     * On Windows "/foo" has a root but no drive, so it is not absolute: it 
resolves against the drive of the base.
+     */
+    @Test
+    @EnabledOnOs(OS.WINDOWS)
+    void rootedWithoutDriveOnWindows(@TempDir Path tmpDir) throws IOException {
+        Path result = DirectoryUtils.resolveDirectory("/foo", tmpDir, false);
+        assertEquals(tmpDir.getRoot().resolve("foo"), result);
     }
 
     @Test

Reply via email to