Commit graph

2483 commits

Author SHA1 Message Date
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
Sylvestre Ledru
0d5daacf99 mv -i: adjust the behavior to match the GNU change
Matches the change upstream
7a69df88999bedd8e9fccf9f3dfa9ac6907fab66
2023-03-25 11:22:45 +01:00
Sylvestre Ledru
a4a290caf2
Merge branch 'main' into default-env-for-tests 2023-03-24 20:33:34 +01:00
Miles Liu
81a4e8fb7d
Remove keep_env from the test framework 2023-03-24 14:25:37 +08:00
Terts Diepraam
c8ece3e972 test_touch: test a specific time with DST problems
Use a specific time to check whether any DST problems arise. The test is
also ignored, because this functionality seems to be broken at the
moment. Still, this is an improvement, because it is more reliable and
does not need to obtain a local offset, which might lead to a panic in
the time library.
2023-03-23 18:16:57 +01:00
Terts Diepraam
4dd88680eb tests: define default env vars for test commands
We now run each command with TZ=UTC and LC_ALL=C to ensure consistent
behavior independent from external timezone and locale settings. These
can still be overridden with other values if necessary.
2023-03-23 18:15:05 +01:00
Daniel Hofstetter
74d8f2fae8
Merge pull request #4578 from daviddwk/fix-util-unnecessary-boolean-not
util: fix unnecessary boolean not operations
2023-03-23 10:41:47 +01:00
Piotr Kwiecinski
51d39c8bb7 test_ls: cannot find function expected_result in this scope 2023-03-23 09:18:17 +01:00
daviddwk
c24194f454 util: fix unnecessary boolean not operations 2023-03-22 17:13:50 +01:00
Sylvestre Ledru
0f497660c8
Merge pull request #4577 from cakebaker/clippy_fix_long_literal_lacking_separators
touch: add underscores to long number in test
2023-03-22 16:59:20 +01:00
Daniel Hofstetter
c95bf0a116 touch: add underscores to long number in test 2023-03-22 16:48:53 +01:00
Miles Liu
2bcdae124c
chroot: fix unused import on Android 2023-03-22 12:02:01 +08:00
Daniel Hofstetter
0140f4f7d0 tests: fix "unresolved import" warnings on Windows 2023-03-20 16:26:31 +01:00
Daniel Hofstetter
94aeba9854 tests: fix unused imports warnings on Windows 2023-03-20 16:06:56 +01:00
Daniel Hofstetter
6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Terts Diepraam
b8f2f295a6
Merge pull request #4498 from jfinkels/dd-seconds-precision-3
dd: fix precision for display of total time spent
2023-03-20 12:52:48 +01:00
Sylvestre Ledru
c611176878
Merge pull request #4546 from leon3s/fix-test-sort-literal-lacking-separator
fix: clippy long literal lacking separators
2023-03-19 19:45:12 +01:00
jfinkels
59d34ce667
Merge branch 'main' into dd-seconds-precision-3 2023-03-19 13:29:14 -04:00
Jeffrey Finkelstein
1de1a84ed2 mktemp: uncomment fixed test case
Uncomment a test case fixed by commit
53c4b0b81e (pull request
https://github.com/uutils/coreutils/pull/4091).
2023-03-19 13:20:10 -04:00
leon3s
be51f9aa5b fix: clippy long literal lacking separators 2023-03-19 15:01:59 +01:00
Sylvestre Ledru
10b4aeb2c8
Merge pull request #4548 from papparapa/test-du-clippy-if-not-else
test_du: fix unnecessary boolean operation
2023-03-19 08:56:57 +01:00
Surya Teja K
b39c4d2756
date: fix invalid argument error for RFC 3339 (#4535) 2023-03-19 08:54:45 +01:00
Koki Ueha
0b042f0b32 test_du: fix unnecessary boolean operation 2023-03-19 04:59:08 +00:00
leon3s
6de67cfc36 sort: fix test clippy long literal lacking separators 2023-03-18 22:30:48 +01:00
Sylvestre Ledru
be6d5bfb9c Fix some redundant closure in test_shurf 2023-03-18 15:52:13 +01:00
Sylvestre Ledru
d42b4883e1 Fix some simply clippy warnings
With:
`cargo +nightly clippy --features unix --allow-dirty --fix -- -W clippy::pedantic`
2023-03-18 14:36:49 +01:00
august radjoe
89b83c2f6a
A better handler for ./coreutils date -f aze (#4482) 2023-03-18 14:19:57 +01:00
Daniel Hofstetter
882a35c3b6
Merge pull request #4526 from tertsdiepraam/date-d-should-return-1
`date`: make sure 'invalid date' message also returns exit code 1
2023-03-18 07:08:04 +01:00
Terts Diepraam
e3aab307fe
Merge pull request #4189 from jfinkels/dd-stdin-from-file-descriptor
dd: open stdin from file descriptor when possible
2023-03-18 01:30:31 +01:00
Terts Diepraam
1b1446ce0c date: make sure 'invalid date' message also returns exit code 1 2023-03-17 21:49:26 +01:00
jparag
7ea63d0b59
Merge branch 'main' into test_ls_fix 2023-03-17 10:58:58 -04:00
Terts Diepraam
2a4b48f253
Merge pull request #4442 from bbara/chmod-usage
chmod: fix GNU test 'chmod/usage'
2023-03-17 15:18:39 +01:00
Daniel Hofstetter
0d9d9118ad
Merge pull request #4523 from miles170/test-shred-force
shred: enable `test_shred_force` on FreeBSD
2023-03-17 09:29:08 +01:00
Miles Liu
ab9d1030ff
shred: enable test_shred_force on FreeBSD 2023-03-17 14:37:15 +08:00
Anish Bhobe
624588d37f date: Added default value for date --i.
`default_missing_value` set to `OPT_DATE` (`"date"`)
`num_args(0..=1)` required for `default_missing_value`.

Using function name `test_date_rfc_8601_default`.
The function name `test_date_rfc_8601` is left intact for
compatibility.
 
Fixes: #4521
2023-03-17 03:06:31 +01:00
Benjamin Bara
e982d57819 chmod: fix GNU test 'chmod/usage' 2023-03-16 21:25:26 +01:00
Benjamin Bara
787d854f89 chmod: add GNU usage tests 2023-03-16 21:16:51 +01:00
Sylvestre Ledru
5298ba8250
Merge pull request #4520 from kidrigger/wip-date-test
tests/date: Added tests for date ISO8601 formats.
2023-03-16 20:53:01 +01:00
Surya Teja K
bd6905cf59
fix: match date -I error messages with GNU date (#4499)
* date: use value_parser to improve errors

* date: update panic! to unreachable inside impl From for Iso8601Format
2023-03-16 20:50:37 +01:00
Anish Bhobe
ac23dca426 tests/date: Added tests for date ISO8601 formats.
Regex matching for correctness check.
Tests for format with `minute`, `hour` and `date` added.
2023-03-16 18:14:27 +01:00
Parag Jain
2118e85508 Merge branch 'main' into test_ls_fix 2023-03-15 17:10:54 -04:00
Terts Diepraam
dad474bfa0
Merge pull request #4315 from miles170/issue-4176-fix-timeout
timeout: fix subprocess is never terminated
2023-03-15 14:10:58 +01:00
Miles Liu
1435d3573a
dd: fix unused imports on FreeBSD 2023-03-15 18:08:32 +08:00
Parag Jain
50e019a711 Fixing failing test locally because of missing case sensitivity handling 2023-03-14 12:28:49 -04:00
Joining7943
5fb091a4fb sleep: Use fundu error types to improve error messages 2023-03-12 15:37:44 +01:00
Joining7943
946aab37ed Cargo: Bump fundu version v0.3.0 -> v0.4.2. Adjust test in test_tail. 2023-03-12 15:37:44 +01:00
Terts Diepraam
9a231be9c5
Merge branch 'main' into dd-seconds-precision-3 2023-03-12 14:14:53 +01:00
Terts Diepraam
7a6092b333
Merge branch 'main' into dd-stdin-from-file-descriptor 2023-03-12 13:56:28 +01:00
Terts Diepraam
320929d83d
Merge branch 'main' into issue-4176-fix-timeout 2023-03-12 13:35:27 +01:00
Jeffrey Finkelstein
2f56536637 dd: fix precision for display of total time spent
Improve the display of the total time spent transferring bytes so that
the number of seconds is displayed using the `%g` format specifier as
in `printf`. This matches the behavior of GNU `dd`.

Before this commit, the precision was always set to one digit after
the decimal point. For example,

    $ dd count=100000 if=/dev/zero of=/dev/null
    100000+0 records in
    100000+0 records out
    51200000 bytes (51 MB, 49 MiB) copied, 0.2 s, 268.1 MB/s

After this commit, the precision increases dynamically as the duration
decreases. For example,

    $ dd count=100000 if=/dev/zero of=/dev/null
    100000+0 records in
    100000+0 records out
    51200000 bytes (51 MB, 49 MiB) copied, 0.1019 s, 507 MB/s
    $ dd count=1000 if=/dev/zero of=/dev/null
    1000+0 records in
    1000+0 records out
    512000 bytes (512 kB, 500 KiB) copied, 0.002663 s, 256 MB/s
    $ dd count=10 if=/dev/zero of=/dev/null
    10+0 records in
    10+0 records out
    5120 bytes (5.1 kB, 5.0 KiB) copied, 0.000182 s, 5.1 MB/s
2023-03-11 22:37:43 -05:00
Jeffrey Finkelstein
9cb6b4a3c0 dd: open stdin from file descriptor when possible
Open stdin using its file descriptor so that a `dd skip=N` command in
a subshell does not consume all bytes from stdin.

For example, before this commit, multiple instances of `dd` reading
from stdin and appearing in a single command line would incorrectly
result in an empty stdin for each instance of `dd` after the first:

    $ printf "abcdef\n" | (dd bs=1 skip=3 count=0 && dd)  2> /dev/null
    # incorrectly results in no output

After this commit, the `dd skip=3` process reads three bytes from the
file descriptor referring to stdin without draining the remaining
three bytes when it terminates:

    $ printf "abcdef\n" | (dd bs=1 skip=3 count=0 && dd)  2> /dev/null
    def
2023-03-11 20:56:37 +00:00
Miles Liu
f406b56f4a
timeout: fix subprocess is never terminated 2023-03-10 18:08:54 +08:00
Daniel Hofstetter
3eeb5dda30 tests: adapt to clap's modified error messages 2023-03-09 10:06:20 +01:00
Terts Diepraam
69406e7d52
Merge pull request #4439 from Joining7943/sleep-fix-panic-adding-durations
`sleep`: Fix parsing of multiple inputs panics on overflow, some whitespace issues ...
2023-03-07 16:32:43 +01:00
Joining7943
71bbebdc76 sleep: Fix whitespace issues. Don't panic when adding durations.
Refactor error propagation and use show_error! instead of USimpleError.
2023-03-07 13:33:49 +01:00
Zaú Júlio
b540b15b5a
Merge branch 'main' into hotfix-mktemp 2023-03-06 21:39:56 -03:00
Sylvestre Ledru
49eb9a2e91
Merge branch 'main' into cp-pathbuf 2023-03-05 16:22:21 +01:00
Zaú Júlio
65b1be9456
Merge branch 'main' into hotfix-mktemp 2023-03-03 14:22:07 -03:00
Sylvestre Ledru
60771b1026
Merge pull request #4446 from eggpi/main
tests/du: run test_du_time with TZ=UTC.
2023-03-03 13:22:08 +01:00
Guilherme Gonçalves
d29119728a tests/du: run test_du_time with TZ=UTC.
du --time formats a file's timestamp according to the local timezone,
but the test implicitly assumed UTC. This caused it to fail when
running locally in my UTC+1 machine.

$ cargo test --features "du touch" --no-default-features
Failure: https://gist.github.com/eggpi/651e01559b7c59e9457c1b22fe4c0c19
2023-03-02 22:14:03 +00:00
Zaú Júlio
b41713c106
Merge branch 'main' into hotfix-mktemp 2023-03-02 15:31:39 -03:00
ZauJulio
2cf2460809
Merge branch 'hotfix-mktemp' of github.com:ZauJulio/coreutils into hotfix-mktemp 2023-03-02 15:31:11 -03:00
ZauJulio
b94a0d2ebe
mktemp: fix test fmt 2023-03-02 15:30:55 -03:00
Daniel Hofstetter
a7a55c7433 comm: allow multiple occurrence of -z 2023-03-02 16:18:42 +01:00
Terts Diepraam
b9bca794cc
Merge pull request #4449 from cakebaker/comm_zero_terminated
comm: implement --zero-terminated
2023-03-01 22:52:31 +01:00
Zaú Júlio
ddb9b592bf
Merge branch 'main' into hotfix-mktemp 2023-03-01 15:52:24 -03:00
ZauJulio
e9bd69e051
mktemp: fix test_prefix_template_separator adding -p param 2023-03-01 15:45:41 -03:00
Daniel Hofstetter
0d782e09c1 comm: implement --zero-terminated 2023-03-01 16:59:51 +01:00
Benjamin Bara
9b49f368c7 tail: parse default before obsolete 2023-02-28 18:58:12 +01:00
Benjamin Bara
f6edea2d05 tail: enable non-utf8 paths 2023-02-28 18:58:12 +01:00
Benjamin Bara
dc34e89d50 tail: skip clap for obsolete args 2023-02-28 18:58:12 +01:00
Benjamin Bara
b83c30b12e tail: improve GNU compatibility 2023-02-28 18:58:12 +01:00
ZauJulio
9b4fb0cb6e
mktemp: add tests UNIX and POSIX to check path in prefix 2023-02-28 12:38:18 -03:00
Joining7943
68f75af678 sleep: Fix duration parsing of multiple inputs when duration overflow should saturate and not panic 2023-02-28 08:04:55 +01:00
Zaú Júlio
5c3bb90df2
Merge branch 'main' into hotfix-mktemp 2023-02-27 01:15:36 -03: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
Zaú Júlio
be2b7032f6
Merge branch 'main' into hotfix-mktemp 2023-02-25 18:37:22 -03:00
ZauJulio
dc1fd027a6
mktemp: fix fmt of test_prefix_template_separator 2023-02-25 18:35:35 -03:00
David Matos
d9a21ff8f0 chmod: allow verbose and quiet flags to be used more than once 2023-02-23 20:21:38 +01:00
Terts Diepraam
3554565c82
Merge pull request #4356 from howjmay/cksum-a
cksum: implement -a
2023-02-23 12:18:21 +01:00
Terts Diepraam
198e948f4a
Merge pull request #4419 from sylvestre/test_invalid_multi_byte_characters
timeout: add a test to verify that it fails as expected
2023-02-23 10:41:59 +01:00
Zaú Júlio
59490e4a17
Merge branch 'main' into hotfix-mktemp 2023-02-22 20:23:36 -03:00
ZauJulio
3d2f3fc5b1
mktemp: add test to . in template prefix 2023-02-22 20:22:16 -03:00
Sylvestre Ledru
41018859bb
Merge pull request #4365 from kylemanna/km/fix-install-directory-chown
install: add missing directory chown
2023-02-22 21:49:22 +01:00
Sylvestre Ledru
74419366fd timeout: add a test to verify that it fails as expected
Follow up of PR #4388
2023-02-22 21:25:23 +01:00
Terts Diepraam
60d2df56de
Merge pull request #4164 from jfinkels/dd-fifo-seek
dd: allow skipping and seeking in FIFOs
2023-02-22 10:38:45 +01:00
Thayne McCombs
17f9507e17 Add tests for non-utf8 2023-02-21 22:58:39 -07:00
Terts Diepraam
6bd42fde6a
Merge pull request #4293 from Joining7943/tests-util-refactor-ucommand-add-run-in-shell
`tests/util`: Small Refactor/Fixes of `UCommand` and add method to run a `UCommand` in a shell platform independently
2023-02-21 22:41:20 +01:00
Guilherme A. de Souza
7d7b9eb49a
Migrate from atty to is-terminal (#4382) 2023-02-21 21:52:18 +01:00
David Matos
dd4299c32e chmod: supress verbose output when not verbose 2023-02-20 22:18:07 +01:00
David Matos
fe4da2b8e5 cp: modify archive flag to copy dir contents rather than dir 2023-02-20 16:49:33 +01:00
Kyle Manna
376f4d90ef install: add tests for invalid owner and group
* Move the user and group resolution to the behavior decoding instead of
  re-running on every file/directory creation.  Simplifies code.
* Update error output to match GNU coreutils.
* Add tests to verify invalid owner and group.
2023-02-18 22:46:12 -06:00
Kyle Manna
7aa7f219a0 install: fix issue #4360 with bad target directory permissions
* Correct bug that set the last directory to the mode the file should
  have been set to.
* Add unit test to verify correct functionality.
2023-02-18 22:32:31 -06: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
Jeffrey Finkelstein
c52647a632 dd: add support for skipping in input FIFO
For example, `dd skip=1 if=fifo` will now work.
2023-02-18 21:24:16 +01:00
Jeffrey Finkelstein
9c3f810f97 dd: add support for seeking in output FIFOs
For example, `dd seek=1 of=fifo` will now work.
2023-02-18 21:24:16 +01:00
Yang Hau
678a11dcf2 cksum: Implement option -a
Implement option -a --algorithm.
Move digest to src/uucore/src/lib/features and rename it to hash.

fix lint

fix Cargo.toml
2023-02-18 20:58:53 +08: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
Joining7943
2b5b0c82c1 tests/util: Bump rlimit version to 0.9.1 to be able to use prlimit on android 2023-02-17 17:39:30 +01:00
Terts Diepraam
9fdce975fd
Merge pull request #4359 from dmatos2012/chmod-multiple-files-error
chmod: change permissions for files present even when there is a missing file
2023-02-17 11:27:32 +01:00