Commit graph

2602 commits

Author SHA1 Message Date
Dorian Péron
58ee0ce427 tests/printf: Verify the correct error behavior of printf when provided with '%0c' or '%0s' 2024-03-01 00:02:31 +01:00
Dorian Péron
42cde767d2 printf: Change get_char and write_padded to handle bytes instead of chars 2024-02-29 00:59:08 +01:00
Dorian Péron
5d74a6e002 tests/printf: Fix char_as_byte test, add char and string padding tests 2024-02-29 00:43:47 +01:00
Sylvestre Ledru
769c5ca7a5
Merge pull request #6000 from BenWiederhake/dev-pipein-fails-flake
tests: Harden two tests, prevent 4 flaky tests (cat, numfmt, sort, split, tee)
2024-02-28 09:41:00 +01:00
Daniel Hofstetter
aa0d15d1ac
Merge pull request #6011 from BenWiederhake/dev-shuf-repeat-zero-items
shuf: Refuse repeating zero lines
2024-02-27 15:28:06 +01:00
Daniel Hofstetter
ae7d03cb15
Merge pull request #6007 from BenWiederhake/dev-basexx-multi-arg
base32/base64/basenc: implement and test proper flag parsing
2024-02-27 15:03:47 +01:00
Sylvestre Ledru
56e26f72b5
Merge pull request #6022 from cakebaker/uniq_use_concat
uniq: use `concat!` in tests for better readability
2024-02-27 13:09:21 +01:00
Daniel Hofstetter
8b2a2921c5
Merge pull request #6018 from BenWiederhake/dev-basename-multi-arg
basename: Fix handling of repeated flags/arguments
2024-02-27 10:03:14 +01:00
Daniel Hofstetter
c85970485a uniq: use concat! in tests for better readability 2024-02-26 16:37:01 +01:00
Daniel Hofstetter
d8e6f36fcb
Merge pull request #6017 from BenWiederhake/dev-uniq-flake-stdin-write-gnutest
uniq: Fix flaky test gnu_tests
2024-02-26 16:18:26 +01:00
Matei Mantu
095eced4be
chmod: Fix chmod -c --reference reporting when no change is made (#6016)
* Make fperm hold 6 digit octal permission. Set it to 4 digits when displaying

* Add test

* Make every permission 4 octal digits

* Change test name to be more suggestive

* chmod: merge two args in test

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2024-02-26 11:01:50 +01:00
Ben Wiederhake
f905d9ce41 basename: implement and test repeated flags and arguments
Note in particular that `args_override_self` would *NOT* work here,
since it would in all cases cause `options::NAME` to override itself,
or interfere with `trailing_var_arg`.
2024-02-25 19:45:32 +01:00
Ben Wiederhake
9441806a23 basename: test flag implications, document -z correctly 2024-02-25 19:14:17 +01:00
Ben Wiederhake
e91d0bd14f uniq: fix flaky test gnu_tests
The testcase tries to write to the stdin pipe while the process under
test is simultaneously exiting with an error code. Naturally, this is a
race, and we should ignore any stdin write errors. However, adding this
feature to the list makes it even more unreadable, and adds no real
value, so let's skip the input data entirely.
2024-02-25 17:59:09 +01:00
Ben Wiederhake
6834b593ee shuf: refuse repeating zero lines
This was a GNU behavior bug:

```console
$ LC_ALL=C shuf -er
shuf: no lines to repeat
[$? = 1]
$ cargo run shuf -er  # old, bad (unexpected success)
$ cargo run shuf -er  # new
shuf: no lines to repeat
[$? = 1]
```
2024-02-25 16:49:03 +01:00
Terts Diepraam
d7a09c042a
Merge pull request #6010 from BenWiederhake/dev-pr-fix-flaky-diff-timestamp
pr: Check the correct timestamp in test_with_pr_core_utils_tests
2024-02-25 11:46:39 +01:00
Sylvestre Ledru
174864566e
Merge pull request #6006 from BenWiederhake/dev-tr-multi-arg
tr: Correctly handle multiple appearances of flag-args
2024-02-25 09:51:40 +01:00
Sylvestre Ledru
8301a8e5be
Merge pull request #5980 from BenWiederhake/dev-shuf-number-speed
shuf: Fix OOM crash for huge number ranges
2024-02-25 09:50:49 +01:00
Yury Zhytkou
17174ab986
uniq: pass remaining GNU tests (#5994) 2024-02-25 09:45:37 +01:00
Ben Wiederhake
5fed98bb01 pr: check the correct timestamp in test_with_pr_core_utils_tests 2024-02-24 23:48:33 +01:00
Ben Wiederhake
445905a045 base32/base64/basenc: permit repeating -d/-i/-w flags 2024-02-24 21:11:18 +01:00
Ben Wiederhake
36e142aa15 basenc: use last given encoding, instead of priority list 2024-02-24 20:44:07 +01:00
Ben Wiederhake
c6f75c98b7 basenc: Test basic functionality
It's good that all encodings already work. Let's make sure they cannot regress!
2024-02-24 20:44:07 +01:00
Ben Wiederhake
44310f426c tr: enable passing -t multiple times 2024-02-24 18:37:45 +01:00
Ben Wiederhake
268af90843 tr: enable passing -s multiple times 2024-02-24 18:37:45 +01:00
Ben Wiederhake
352a8a5bd7 shuf: handle --input-range with huge number ranges
This requires special handling, because we cannot always generate all
possible strings beforehand, e.g. in the case of "-n 2 -i 0-2147483647".
2024-02-24 18:33:46 +01:00
Ben Wiederhake
dc664006fe tr: enable passing -d multiple times 2024-02-23 11:58:22 +01:00
Ben Wiederhake
cad94a69be tr: prevent passing options in the wrong place
Note: This requires using the DEPRECATED item Command::trailing_var_arg
in clap. This is going to be another
[problem with clap](https://github.com/tertsdiepraam/uutils-args/blob/main/docs/design/problems_with_clap.md).
2024-02-23 11:58:22 +01:00
Ben Wiederhake
d9b6675bbf tr: enable passing -c multiple times 2024-02-23 11:58:18 +01:00
Daniel Hofstetter
5a2e0c700e
Merge pull request #5990 from BenWiederhake/dev-shuf-head-null
shuf: Do not read input when -n0 is given
2024-02-23 09:01:14 +01:00
Sylvestre Ledru
208b2dbb51
Merge pull request #5997 from BenWiederhake/dev-unignore
Un-Ignore two tests that fail for nonsense reasons
2024-02-23 08:34:07 +01:00
Sylvestre Ledru
1691127c79
Merge pull request #6001 from BenWiederhake/dev-dd-small-times
dd: fix flaky test_final_stats_unspec
2024-02-23 08:33:35 +01:00
Ben Wiederhake
ede944e1f8 dd: fix flaky test_final_stats_unspec
If the first four decimal digits are zero, GNU dd elides them altogether.
Here's an execution on my PC:

```console
$ for i in $(seq 20000); do LC_ALL=C gnu_dd if=/dev/null of=/dev/null \
    2>&1; done | grep copied | grep -E ' [0-9]e'
0 bytes copied, 1e-05 s, 0 B/s
0 bytes copied, 9e-06 s, 0.0 kB/s
```

Our implementation conforms to this, resulting in the following CI flake:

```
---- test_dd::test_final_stats_unspec stdout ----
run: D:\a\coreutils\coreutils\target\x86_64-pc-windows-gnu\debug\coreutils.exe dd
thread 'test_dd::test_final_stats_unspec' panicked at 'Stderr does not match regex:
0+0 records in
0+0 records out
0 bytes copied, 8e-05 s, 0.0 B/s
', tests\by-util\test_dd.rs:280:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library\std\src/panicking.rs:578:5
```

Of course, this is just an overly strict regex in the test. This was a
one-in-tenthousand flaky test.
2024-02-23 06:24:11 +01:00
Ben Wiederhake
617f3a8b6f tr: when deleting and squeezing, never complement set2 2024-02-23 06:08:37 +01:00
Ben Wiederhake
b3d8344d1d split: don't flake even on exotic pipe buffer sizes 2024-02-23 05:42:29 +01:00
Ben Wiederhake
44c59a6d28 numfmt: don't flake even on exotic pipe buffer sizes 2024-02-23 05:42:29 +01:00
Ben Wiederhake
bcd2d888a1 cat: don't flake even on exotic pipe buffer sizes
See also 9995c637aa.

There is a race condition between the writing thread and the command.
It is easily possible that on the developer's machine, the writing
thread is always faster, filling the kernel's buffer of the stdin pipe,
thus succeeding the write. It is also easily possible that on the busy
CI machines, the child command runs first for whatever reason, and exits
early, thus killing the pipe, which causes the later write to fail. This
results in a flaky test. Let's prevent flaky tests.
2024-02-23 05:42:17 +01:00
Ben Wiederhake
9fa808fb5e sort: add skipped test for combined flags
Now that clap#2624 has been resolved, we can and should test both variants.
2024-02-23 05:42:01 +01:00
Ben Wiederhake
868600cac9 tee: fail test if string setup fails 2024-02-23 05:42:01 +01:00
Ben Wiederhake
48c4b57c97 tr: require second string argument when deleting and squeezing 2024-02-23 03:23:07 +01:00
Ben Wiederhake
27030e9f53 touch: re-enable test, fix typo in expected error messge 2024-02-23 00:21:19 +01:00
Ben Wiederhake
e50eb19056 head: fix 'test_spams_newline' to check *against* newline spam
The comment was introduced in commit 8320b1ec5f,
the test was introduced in commit c1f518e586
claiming to be about "failing GNU head tests".

However, a simple check reveals no such difference:

```console
$ echo -n a | hd
00000000  61                                                |a|
00000001
$ echo -n a | head | hd  # GNU head
00000000  61                                                |a|
00000001
$ echo -n a | cargo run -- head | hd
00000000  61                                                |a|
00000001
$ echo -n a | busybox head | hd
00000000  61                                                |a|
00000001
$
```

Looking at the GNU tests directly, it seems that there is a similar, but different test.
2024-02-23 00:21:19 +01:00
Ben Wiederhake
a29f68b720 shuf: Do not read input when -n0 is given
This is explicitly tested by some suites, including the GNU test suite.
2024-02-22 23:50:03 +01:00
Ben Wiederhake
a59924ece5 shuf: treat -e as a flag, not as a multi-value arg 2024-02-22 23:22:35 +01:00
Daniel Hofstetter
725da985c1 Fix "item x imported redundantly" warnings 2024-02-19 15:39:37 +01:00
Ulrich Hornung
d6ca9e3800
disable failing test_od::test_f16() for android CI. 2024-02-17 18:24:09 +01:00
Ben Wiederhake
b091911aae shuf: refuse multiple input ranges and multiple output files 2024-02-16 21:14:56 +01:00
Ben Wiederhake
69f23c2521 shuf: obey all headcount args, not just the last 2024-02-16 21:08:16 +01:00
Ben Wiederhake
07e8f4c7a5 shuf: include all echo args, not just the last 2024-02-16 20:49:59 +01:00
Daniel Hofstetter
420dfe8a9b
Merge pull request #5958 from tertsdiepraam/csplit-printf
`csplit`: use `printf` functionality from `uucore`
2024-02-16 14:39:03 +01:00