mirror of
https://github.com/uutils/coreutils.git
synced 2026-05-06 07:26:38 -04:00
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:
committed by
GitHub
parent
ffbcb4b381
commit
7e12383fcf
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user