Commit graph

885 commits

Author SHA1 Message Date
Roy Ivy III 4e20dedf58 tests ~ refactor/polish spelling (comments, names, and exceptions) 2021-05-31 08:23:57 -05:00
Sylvestre Ledru 8c5dcd0765
Merge branch 'master' into implement-more 2021-05-31 10:17:15 +02:00
Terts Diepraam 99fb2c5aac
Merge pull request #2310 from sylvestre/clippy2
Fix a clippy warning
2021-05-30 23:06:10 +02:00
Sylvestre Ledru 69850942b6 fix a clippy warning
WARNING: `cargo clippy`: single-character string constant used as pattern
2021-05-30 16:26:03 +02:00
Anup Mahindre 898d325aea ls: Fix minor output mismatch
When a single directory is passed to ls in recursive mode, uutils ls
won't print the directory name
======================
GNU ls:
z:
======================
======================
uutils ls:
======================

This commit fixes this minor inconsistency and adds corresponding test.
2021-05-30 18:00:52 +05:30
Sylvestre Ledru 3913731222
Revert "rmdir: match GNU error output" 2021-05-30 09:55:02 +02:00
Dean Li 5b417e251d
rmdir: match GNU error output
Related to #2258
2021-05-30 10:45:54 +08:00
Michael Debertol dc63133f14
sort: correctly inherit global flags for keys (#2302)
Closes #2254. We should only inherit global settings for keys when there
are absolutely no options attached to the key.

The default key (matching the whole line) is implicitly added only if no
keys are supplied.

Improved some error messages by including more context.
2021-05-29 23:25:56 +02:00
Michael Debertol d821719c67
expr: support arbitrary precision integers (#2271)
* expr: support arbitrary precision integers

Instead of i64s we now use BigInts for integer operations. This means
that no result or input can be out of range.
The representation of integer flags was changed from i64 to u8 to make
their intention clearer.

* expr: allow big numbers as arguments as well

Also adds some tests

* expr: use num-traits to check bigints for 0 and 1

* expr: remove obsolete refs

match ergonomics made these avoidable.

* formatting

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2021-05-29 23:25:23 +02:00
Jeffrey Finkelstein 4e73b919e9 truncate: add test for -r and -s options together
Add a test for when the reference file is not found and both `-r` and
`-s` options are given on the command-line.
2021-05-29 15:11:27 +02:00
Gilad Naaman 17b0939dee Moved factor to use clap
Issue: https://github.com/uutils/coreutils/issues/2121
2021-05-29 15:11:27 +02:00
Jan Scheer e4aa8ee159 users: fix long_help text and clippy warning 2021-05-29 15:11:27 +02:00
Jan Scheer 3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Michael Debertol bb268d1500
sort: crash when failing to open an input file (#2265)
* sort: crash when failing to open an input file

Instead of ignoring files we fail to open, crash.
The error message does not exactly match gnu, but that would require
more effort.

* use split_whitespace instead of a manual implementation

* fix expected error on windows

* sort: update expected error message
2021-05-28 22:39:33 +02:00
Michael Debertol e9656a6c32
sort: make GNU test sort-debug-keys pass (#2269)
* sort: disable support for thousand separators

In order to be compatible with GNU, we have to disable thousands
separators. GNU does not enable them for the C locale, either.

Once we add support for locales we can add this feature back.

* sort: delete unused fixtures

* sort: compare -0 and 0 equal

I must have misunderstood this when implementing, but GNU considers
-0, 0, and invalid numbers to be equal.

* sort: strip blanks before applying the char index

* sort: don't crash when key start is after key end

* sort: add "no match" for months at the first non-whitespace char

We should put the "^ no match for key" indicator at the first
non-whitespace character of a field.

* sort: improve support for e notation

* sort: use maches! macros
2021-05-28 22:38:29 +02:00
Sylvestre Ledru 9442f26fdb
Merge pull request #2283 from Mikadore/master
Closing #1916 - Concluding the test refactor
2021-05-28 22:36:47 +02:00
Sylvestre Ledru fe42808e9b
Merge branch 'master' into implement-more 2021-05-28 19:49:48 +02:00
Terts Diepraam c7930a63f7
Merge pull request #2285 from blesson3/cp-backup-arg-fix
cp: fix regressed issue with `--backup` and `-b`
2021-05-28 18:44:09 +02:00
Terts Diepraam ebe6341ae3 chore: replace tempdir with tempfile 2021-05-27 22:47:03 +02:00
Mikadore 29f6dd1f35 Fixed warning 2021-05-27 16:55:14 +02:00
Sylvestre Ledru 41539df91d
Merge pull request #2280 from jhscheer/symlink_tests
Improve symlink/hardlink handling in tests
2021-05-27 09:41:48 +02:00
Matt Blessed 41bea72f23 cp: fix regressed issue with --backup and -b
- add test for regressed issue
2021-05-26 18:29:03 -04:00
Matt Blessed f11f5f3abb mv: refactor backup logic to use shared uucore backup control
- add mv backup tests
2021-05-26 18:23:48 -04:00
Mikadore 5e1d52d4be cargo-fmt :DDD 2021-05-26 22:20:16 +02:00
Mikadore 64598d9e26 Closing #1916 2021-05-26 22:15:28 +02:00
Terts Diepraam b4f6c81810
Merge pull request #2281 from deantvv/chmod-match-gnu-error
chmod: match GNU error
2021-05-26 21:13:05 +02:00
Terts Diepraam 658e52dde0
Merge pull request #2275 from blesson3/cp-backup-support
cp: implement backup support
2021-05-26 21:12:01 +02:00
Matt Blessed 25ed5eeb0e cp: move option check to uumain and use show_usage_error
- add test for conflicting options `--backup` and `--no-clobber`
2021-05-26 11:10:04 -04:00
Dean Li fe25b51a66
chmod: match GNU error
Related to #2260

Signed-off-by: Dean Li <deantvv@gmail.com>
2021-05-26 22:31:02 +08:00
Jan Scheer efd5921bda tests/test: replace call to 'ln -s' with call to 'AtPath::symlink_file' 2021-05-26 13:42:12 +02:00
Jan Scheer 6a70d89e8c tests/du: replace call to 'ln' with call to 'AtPath::hard_link' 2021-05-26 12:55:53 +02:00
Jan Scheer afb1b9efb4 tests/util: add AtPath::hard_link 2021-05-26 12:53:11 +02:00
Matt Blessed a8a1ec7faf cp: implement backup control with tests 2021-05-25 23:22:32 -04:00
Yağız can Değirmenci 12f207a6d6 test: fix tests 2021-05-26 03:21:53 +03:00
Yağız can Değirmenci 8fe34c72d2 test: fix tests 2021-05-26 03:07:49 +03:00
Yağız can Değirmenci 071899d24d tests: delete 'error:' prefix from the tests 2021-05-26 02:45:53 +03:00
Yağız can Değirmenci 991fcc548c fix: log error messages properly on permission errors 2021-05-24 21:07:45 +03:00
Michael Debertol 218f523e1b expr: make substr infallible
Instead of returning an Err it should return the "null string"
(in our case that's the empty string) when the offset or length
is invalid.
2021-05-23 22:22:34 +02:00
Sylvestre Ledru 7bf076505f
Merge branch 'master' into who_fix_runlevel 2021-05-23 09:32:37 +02:00
Sylvestre Ledru b175534a97
Merge pull request #2264 from miDeb/sort-sort-flag
sort: support --sort flag and check for conflicts
2021-05-23 09:30:03 +02:00
Sylvestre Ledru 41bd025d00
Merge pull request #2209 from jfinkels/head-ring-buffer
head: add abstractions for "all but last n lines"
2021-05-23 09:28:17 +02:00
Jeffrey Finkelstein bc9db289e8 head: add abstractions for "all but last n lines"
Add some abstractions to simplify the `rbuf_but_last_n_lines()`
function, which implements the "take all but the last `n` lines"
functionality of the `head` program. This commit adds

- `RingBuffer`, a fixed-size ring buffer,
- `ZLines`, an iterator over zero-terminated "lines",
- `TakeAllBut`, an iterator over all but the last `n` elements of an
  iterator.

These three together make the implementation of
`rbuf_but_last_n_lines()` concise.
2021-05-22 23:56:48 -04:00
Jan Scheer 44c033a013 who: exclude --runlevel from non Linux targets (fix #2239) 2021-05-23 03:05:15 +02:00
Sylvestre Ledru 95092e6440 ignore test_should_calculate_implicit_padding_per_free_argument
Fails from time to time with
```
---- test_numfmt::test_should_calculate_implicit_padding_per_free_argument stdout ----
current_directory_resolved:
run: /target/x86_64-unknown-linux-musl/debug/coreutils numfmt --from=auto    1Ki         2K
thread 'test_numfmt::test_should_calculate_implicit_padding_per_free_argument' panicked at 'failed to write to stdin of child: Broken pipe (os error 32)', tests/common/util.rs:859:21
```
2021-05-23 00:34:01 +02:00
Sylvestre Ledru 4aaeede3d8 rustfmt the recent change 2021-05-23 00:13:53 +02:00
Michael Debertol c1f67ed775 sort: support --sort flag and check for conflicts
`sort` supports three ways to specify the sort mode: a long option
(e.g. --numeric-sort), a short option (e.g. -n) and the sort flag
(e.g. --sort=numeric).
This adds support for the sort flag.

Additionally, sort modes now conflict, which means that an error is
shown when multiple modes are passed, instead of silently picking a mode.
For consistency, I added the `random` sort mode to the `SortMode` enum,
instead of it being a bool flag.
2021-05-22 23:10:41 +02:00
David Carlier fcb079e20e who freebsd build fix unsupported RUN_LVL option only for other platforms. 2021-05-22 18:07:02 +01:00
Sylvestre Ledru 542deb8888
Merge pull request #2246 from miDeb/sort-automatic-extsort
sort: automatically fall back to extsort
2021-05-22 17:21:02 +02:00
Sylvestre Ledru 8055f26a73
Merge pull request #2228 from jfinkels/tail-obo-positive-bytes
tail: fix off-by-one issue for +NUM args
2021-05-22 17:18:55 +02:00
Sylvestre Ledru 66cfdb8644
Merge pull request #2143 from nbraud/factor/faster/table
factor::table: Implement a batched version w/ improved performance
2021-05-22 17:18:07 +02:00