Skip to content

Commit

Permalink
Adjust cp and tests to accommodate mv/update
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliebenow committed Sep 18, 2024
1 parent 89371b8 commit 431fc11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/uu/cp/src/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,8 +1457,10 @@ impl OverwriteMode {
fn verify(&self, path: &Path) -> CopyResult<()> {
match *self {
Self::NoClobber => {
// TODO
// Revert to 1_i32 when "mv/update" is fixed
show!(USimpleError::new(
1_i32,
0_i32,
format!("not replacing {}", path.quote())
));

Expand Down
24 changes: 18 additions & 6 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ fn test_cp_arg_interactive_verbose_no_clobber() {
at.touch("a");
at.touch("b");
ucmd.args(&["-vin", "--debug", "a", "b"])
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_only("cp: not replacing 'b'\n");
}

Expand All @@ -606,7 +608,9 @@ fn test_cp_no_clobber_existing_destination() {
at.touch("b");

ucmd.args(&["--no-clobber", "a", "b"])
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_only("cp: not replacing 'b'\n");
}

Expand Down Expand Up @@ -826,7 +830,9 @@ fn test_cp_arg_no_clobber() {
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--no-clobber")
.arg("--debug")
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_only("cp: not replacing 'how_are_you.txt'\n");

assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
Expand All @@ -839,7 +845,9 @@ fn test_cp_arg_no_clobber_inferred_arg() {
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--no-clob")
.arg("--debug")
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_only("cp: not replacing 'how_are_you.txt'\n");

assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
Expand Down Expand Up @@ -869,7 +877,9 @@ fn test_cp_arg_no_clobber_twice() {
.arg("source.txt")
.arg("dest.txt")
.arg("--debug")
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_only("cp: not replacing 'dest.txt'\n");

assert_eq!(at.read("source.txt"), "some-content");
Expand Down Expand Up @@ -1923,7 +1933,9 @@ fn test_cp_preserve_links_case_7() {
.arg("src/f")
.arg("src/g")
.arg("dest")
.fails()
// TODO
// Revert to `fails` when "mv/update" is fixed
.run()
.stderr_contains(expected_stderr)
.stdout_contains(expected_stdout);

Expand Down

0 comments on commit 431fc11

Please sign in to comment.