cp: show relative path of source file with -vr (#8887)

* cp: show relative path of source file with -vr

Add test to cover fix.

* fix test expected output for windows
This commit is contained in:
Christopher Ada Armstrong
2025-10-11 11:30:19 -04:00
committed by GitHub
parent ffbcb4b381
commit 7e12383fcf
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -296,7 +296,7 @@ fn copy_direntry(
if !source_is_dir {
if let Err(err) = copy_file(
progress_bar,
&entry.source_absolute,
&entry.source_relative,
entry.local_to_target.as_path(),
options,
symlinked_files,
+27
View File
@@ -7136,3 +7136,30 @@ fn test_cp_no_preserve_target_directory() {
assert!(at.file_exists("e/f2"));
assert!(at.file_exists("e/f3"));
}
#[test]
fn test_cp_recurse_verbose_output() {
let source_dir = "source_dir";
let target_dir = "target_dir";
let file = "file";
#[cfg(not(windows))]
let output = format!(
"'{source_dir}' -> '{target_dir}/'\n'{source_dir}/{file}' -> '{target_dir}/{file}'\n"
);
#[cfg(windows)]
let output = format!(
"'{source_dir}' -> '{target_dir}\\'\n'{source_dir}\\{file}' -> '{target_dir}\\{file}'\n"
);
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir(source_dir);
at.touch(format!("{source_dir}/{file}"));
ucmd.arg(source_dir)
.arg(target_dir)
.arg("-r")
.arg("--verbose")
.succeeds()
.no_stderr()
.stdout_is(output);
}