1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Added assertion of stderr strings for macos and windows and fixed lints

This commit is contained in:
Anirban Halder 2024-05-08 00:19:11 +05:30 committed by Ben Wiederhake
parent f7e55b1322
commit 1f81912b3c
3 changed files with 13 additions and 15 deletions

View file

@ -213,7 +213,7 @@ where
// `path.ends_with(".")` does not seem to work // `path.ends_with(".")` does not seem to work
path.as_ref().display().to_string().ends_with("/.") path.as_ref().display().to_string().ends_with("/.")
} }
#[allow(clippy::too_many_arguments)]
/// Copy a single entry during a directory traversal. /// Copy a single entry during a directory traversal.
fn copy_direntry( fn copy_direntry(
progress_bar: &Option<ProgressBar>, progress_bar: &Option<ProgressBar>,
@ -326,6 +326,7 @@ fn copy_direntry(
/// ///
/// Any errors encountered copying files in the tree will be logged but /// Any errors encountered copying files in the tree will be logged but
/// will not cause a short-circuit. /// will not cause a short-circuit.
#[allow(clippy::too_many_arguments)]
pub(crate) fn copy_directory( pub(crate) fn copy_directory(
progress_bar: &Option<ProgressBar>, progress_bar: &Option<ProgressBar>,
root: &Path, root: &Path,

View file

@ -1272,7 +1272,7 @@ fn construct_dest_path(
TargetType::File => target.to_path_buf(), TargetType::File => target.to_path_buf(),
}) })
} }
#[allow(clippy::too_many_arguments)]
fn copy_source( fn copy_source(
progress_bar: &Option<ProgressBar>, progress_bar: &Option<ProgressBar>,
source: &Path, source: &Path,
@ -1914,7 +1914,7 @@ fn calculate_dest_permissions(
/// ///
/// The original permissions of `source` will be copied to `dest` /// The original permissions of `source` will be copied to `dest`
/// after a successful copy. /// after a successful copy.
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity, clippy::too_many_arguments)]
fn copy_file( fn copy_file(
progress_bar: &Option<ProgressBar>, progress_bar: &Option<ProgressBar>,
source: &Path, source: &Path,

View file

@ -2667,9 +2667,6 @@ fn test_cp_symlink_overwrite_detection() {
at.mkdir("good"); at.mkdir("good");
at.mkdir("tmp"); at.mkdir("tmp");
at.touch("README");
at.touch("good/README");
at.write("README", "file1"); at.write("README", "file1");
at.write("good/README", "file2"); at.write("good/README", "file2");
@ -2681,18 +2678,18 @@ fn test_cp_symlink_overwrite_detection() {
at.touch("tmp/foo"); at.touch("tmp/foo");
let result = ts ts.ucmd()
.ucmd()
.arg("README") .arg("README")
.arg("good/README") .arg("good/README")
.arg("tmp") .arg("tmp")
.fails(); .fails()
let stderr = result.stderr_str(); .stderr_only(if cfg!(target_os = "windows") {
"cp: will not copy 'good/README' through just-created symlink 'tmp\\README'\n"
assert_eq!( } else if cfg!(target_os = "macos") {
"cp: will not copy 'good/README' through just-created symlink 'tmp/README'\n", "cp: will not overwrite just-created 'tmp/README' with 'good/README'\n"
stderr } else {
); "cp: will not copy 'good/README' through just-created symlink 'tmp/README'\n"
});
let contents = at.read("tmp/foo"); let contents = at.read("tmp/foo");
assert_eq!(contents, "file1"); assert_eq!(contents, "file1");
} }