Skip to content

Commit 89a63c5

Browse files
committed
fix: use platform-appropriate paths in tests for Windows compatibility
The test_parse_local_absolute_path tests used Unix-style paths like /home/user/file.txt which are not recognized as absolute paths on Windows. Updated cp.rs and mv.rs to use conditional compilation for platform-appropriate paths.
1 parent 3ea35e2 commit 89a63c5

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

crates/cli/src/commands/cp.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,13 @@ mod tests {
591591

592592
#[test]
593593
fn test_parse_local_absolute_path() {
594-
let result = parse_path("/home/user/file.txt").unwrap();
594+
// Use platform-appropriate absolute path
595+
#[cfg(unix)]
596+
let path = "/home/user/file.txt";
597+
#[cfg(windows)]
598+
let path = "C:\\Users\\user\\file.txt";
599+
600+
let result = parse_path(path).unwrap();
595601
assert!(matches!(result, ParsedPath::Local(_)));
596602
if let ParsedPath::Local(p) = result {
597603
assert!(p.is_absolute());

crates/cli/src/commands/mv.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,17 @@ mod tests {
306306

307307
#[test]
308308
fn test_parse_local_absolute_path() {
309-
let result = parse_path("/tmp/file.txt").unwrap();
309+
// Use platform-appropriate absolute path
310+
#[cfg(unix)]
311+
let path = "/tmp/file.txt";
312+
#[cfg(windows)]
313+
let path = "C:\\temp\\file.txt";
314+
315+
let result = parse_path(path).unwrap();
310316
assert!(matches!(result, ParsedPath::Local(_)));
317+
if let ParsedPath::Local(p) = result {
318+
assert!(p.is_absolute());
319+
}
311320
}
312321

313322
#[test]

0 commit comments

Comments
 (0)