Commit graph

172 commits

Author SHA1 Message Date
PGIII
252d01ac33
cp: fail when trying to copy to read only file on mac (#5261)
* cp: fail when trying to copy to read only file

* fix spelling error in macos.rs

* simplify permissions check

* add comment

* fix typo
2023-10-03 00:48:22 +02:00
tommady
2789885648
cp: fix cp -dR --no-preserve=links d c should have different inodes (#5320)
* fix issue 5308
2023-09-27 13:16:10 +02:00
tommady
bd0fb817a7
cp: fix the result of inodes are not the same when preserve links is flagged (#5064)
Should fix:
```
rm -rf a b c
touch a
ln -s a b
mkdir c
./target/debug/coreutils cp --preserve=links -R -H a b c
a_inode=$(ls -i c/a|sed 's,c/.*,,')
b_inode=$(ls -i c/b|sed 's,c/.*,,')
echo "$a_inode" = "$b_inode"
```
2023-09-24 10:53:27 +02:00
David Matos
8be6338da9 cp: Error out if cp only contains source 2023-09-05 23:35:14 +02:00
Sylvestre Ledru
0b9c829bce
Merge pull request #5182 from sylvestre/clippy_
Fix some of the recent clippy warnings
2023-08-21 16:21:02 -04:00
Sylvestre Ledru
bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Sylvestre Ledru
7c9f4ba92a Fix some clippy warnings 2023-08-21 08:41:40 +02:00
Daniel Hofstetter
5d03d2d9d4 clippy: fix warnings introduced by Rust 1.71.0 2023-07-13 17:35:33 +02:00
Daniel Hofstetter
11b098fce1
Merge pull request #5028 from sylvestre/cp-multiple
cp: allow multiple usages of -R - Closes: #5027
2023-07-03 16:09:45 +02:00
Sylvestre Ledru
e491bbdbed cp: allow multiple usages of -R/-r Closes: #5027
works for all other rm args
2023-07-03 14:19:45 +02:00
Daniel Hofstetter
ba509a1489 cp: use mkdir_all() instead of mkdir() in test 2023-07-03 09:24:37 +02:00
Daniel Hofstetter
732dbb3f12 cp: fix "unused variable" warning on Windows 2023-06-27 16:46:50 +02:00
Daniel Hofstetter
01f70768d9 cp: fix "unused variable" warnings on Windows 2023-06-27 14:57:06 +02:00
Sylvestre Ledru
ddcdda44db Remove the auto capitalization of error message 2023-06-25 00:18:33 +02:00
Guillaume Ranquet
ee4691f4a2 cp: makes --preserve requires =
prevents --preserve to eat the next argument when no value is passed.

default value for --preserve is set to mode,ownership(unix only),timestamps

before the patch:
cp --preserve foo bar
error: invalid value 'foo' for '--preserve [<ATTR_LIST>...]'
  [possible values: mode, ownership, timestamps, context, link, links, xattr, all]

Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
2023-06-04 09:46:35 +02:00
Daniel Hofstetter
bbfa77dcad cp: replace assert!(false) with panic!() 2023-06-02 16:43:45 +02:00
Sylvestre Ledru
20ce7accf2 cp: -i prompts in the right place
Should fix tests/cp/cp-i.sh
2023-06-01 21:42:35 +02:00
Sylvestre Ledru
4eb1e847e9 cp --no-clobber should fail 2023-06-01 21:42:32 +02:00
Sylvestre Ledru
f2006a9a6b cp: add support of cp --debug 2023-05-29 22:44:57 +02:00
John Shin
a817186e10 cp: preserve permissions on -r -p --parents 2023-05-12 11:34:51 -07:00
Daniel Hofstetter
98fa941250
Merge pull request #4759 from sylvestre/clippy4
fix some clippy warnings in tests
2023-05-12 07:15:44 +02:00
Sylvestre Ledru
d98293bdaa
bring back the empty line 2023-05-11 18:20:28 +02:00
John Shin
7a31d841ba
cp: preserve permission on -p --parents (#4853) 2023-05-11 16:44:23 +02:00
Sylvestre Ledru
b94d10f080 Fix some semicolon_if_nothing_returned 2023-05-06 19:35:44 +02:00
Daniel Hofstetter
616a166e36
Merge pull request #4820 from sylvestre/thru-dangling-2
cp: fix cp -f f loop when loop is a symlink loop
2023-05-04 08:20:57 +02:00
Sylvestre Ledru
832fd2d2c6 cp: fix cp -f f loop when loop is a symlink loop
Fix: tests/cp/thru-dangling.sh
2023-05-03 19:54:35 +02:00
Daniel Hofstetter
a97199f72a
Merge pull request #4796 from shinhs0506/mv-cp-update
mv, cp: add support for --update=none,all,older
2023-05-03 15:21:21 +02:00
John Shin
918c36b485 cp: write test for multiple update args 2023-05-02 13:46:08 -07:00
John Shin
983fee0cea cp: fix wrong test names for update 2023-05-02 13:35:52 -07:00
John Shin
c0e4e4f757 cp: simplify tests for update 2023-05-02 13:35:06 -07:00
Daniel Hofstetter
3f8e21c36c
Merge pull request #4812 from sylvestre/thru-dangling
cp: add support POSIXLY_CORRECT=1 when dealing with dangling links
2023-05-02 10:00:18 +02:00
John Shin
66a9169e55 cp: fix typos 2023-05-01 03:54:56 -07:00
Sylvestre Ledru
2d4dfc3d7d cp: add support POSIXLY_CORRECT=1 when dealing with dangling links
GNU: tests/cp/thru-dangling.sh
2023-05-01 11:05:00 +02:00
John Shin
ed3ff10540 cp: write tests for --update 2023-04-30 19:29:49 -07:00
Sylvestre Ledru
53ae5c33c9 Disable test_sort::test_compress_fail (for real) & test_cp::test_cp_arg_interactive_update on android 2023-04-29 20:39:18 +02:00
Sylvestre Ledru
4e712140fe Do not run test_closes_file_descriptors on android
Closes: #4736
2023-04-29 18:48:15 +02:00
Sylvestre Ledru
efa361dd7c Fix some trivial clippy warnings 2023-04-20 23:22:05 +02:00
Terts Diepraam
74b54074e1
deps: bump time from 0.3.17 to 0.3.20 (#4643) 2023-03-26 21:47:12 +02:00
Sylvestre Ledru
d0a4059f34 cp -i: adjust the behavior to match the GNU change
Just like mv

Note that cp -i -u won't show the overwrite question

Matches the change upstream
7a69df88999bedd8e9fccf9f3dfa9ac6907fab66
2023-03-25 11:22:45 +01:00
Miles Liu
81a4e8fb7d
Remove keep_env from the test framework 2023-03-24 14:25:37 +08:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Daniel Hofstetter
3eeb5dda30 tests: adapt to clap's modified error messages 2023-03-09 10:06:20 +01:00
Sylvestre Ledru
49eb9a2e91
Merge branch 'main' into cp-pathbuf 2023-03-05 16:22:21 +01:00
Terts Diepraam
c148215e7d
Merge pull request #3954 from dmatos2012/modify-cp-archive-flag-behavior
cp: modify archive flag to copy dir contents rather than dir
2023-02-26 13:24:45 +01:00
Thayne McCombs
17f9507e17 Add tests for non-utf8 2023-02-21 22:58:39 -07:00
David Matos
fe4da2b8e5 cp: modify archive flag to copy dir contents rather than dir 2023-02-20 16:49:33 +01:00
Joining7943
1c230fd779 tests/util: Refactor UCommand and TestScenario.
Summary of changes in UCommand:
* Extend UCommand by builder methods and simplify methods in TestScenario
* Simplify code structures where possible. Add documentation.
* Store bin_path as PathBuf and util_name as String in all structs
* Remove UCommand::util and make bin_path, temp_dir private
* Rename UCommand::with_limit -> UCommand::limit

Summary of changes in TestScenario:
* Rename some parameters in TestScenario methods to be more descriptive
* Remove ucmd_keepenv, cmd_keepenv from TestScenario. Use UCommand::keep_env instead.
2023-02-18 23:38:20 +01:00
Joining7943
fdf0f96a01 tests/util: Restructure UCommand to run in shell per default. Introduce constant TESTS_BINARY.
Summary of changes in tests/util:

* Introduce global constant TESTS_BINARY holding the path to `coreutils`
* Implement running an arbitrary command in a sh or cmd shell per default.
* Implement std::fmt::Display for UCommand.
* Change usages of UCommand::util_name from &Option<OsStr> to Option<OsStr>
* `UCommand::new_from_tmp`: Use OsStr directly instead of TempDir -> String -> OsStr
* Collect arguments in `UCommand::args` field
* Build environment variables in `UCommand` itself instead of `std::process::Command`
* Move building of std::process:Command from fields in UCommand to own method `build`
* Remove assertions of UCommand::has_run in arg, args and env.

Summary of changes in tests/by-util:

* Remove usages of UCommand::raw. Fix tests to use UCommand::to_string.
* test_test: Adjust test_invalid_utf8_integer_compare to use `UCommand::args`
* test_chmod: run_single_test
* test_pwd: symlinked_env
* test_cp:
    Fix the usage of &Option<OsStr> in `test_src_base_dot`
    Refactor test_src_base_dot to not use UCommand::new but ts.ucmd() instead
2023-02-17 17:39:33 +01:00
Daniel Hofstetter
f6b646e4e5 clippy: fix warnings introduced with Rust 1.67.0 2023-01-27 17:37:56 +01:00
Joining7943
1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00