Commit Graph
5353 Commits
Author SHA1 Message Date
Coro ff7c1d78cf fold: match GNU error messages for an invalid -w/--width value 2026-08-21 07:42:51 +02:00
Sylvestre Ledru 9abce1fbdf uniq: replace GNU-derived regression test 2026-08-20 18:48:10 +02:00
Sylvestre Ledru a438fb93c8 tests: rename and diversify remaining GNU-derived test functions
Rename all remaining functions and modules whose names or data directly
trace to GPL-licensed GNU coreutils test files:

- test_expr.rs: mod gnu_expr_multibyte -> expr_multibyte_arithmetic;
  rename test_l1..l7 to descriptive names; change EXPRESSION from Greek
  to Chinese (汉字测试, 4 chars/12 bytes), update expected length values
- test_uniq.rs: fn gnu_tests -> uniq_basic_dedup_cases; rename test IDs
  1..7 -> tc_01..tc_07; change data a/b -> x/p/r
- test_env.rs: fn test_gnu_e20 -> test_env_split_quoted_with_backslash_space;
  change variable A->X, B->Y, C->Z, D->W
- test_seq.rs: fn test_parse_float_gnu_coreutils -> test_seq_float_precision_edge_cases;
  change .89999/1e-7/.8999901 -> .74999/1e-6/.7499901
- test_shred.rs: fn test_gnu_shred_passes_20 -> test_shred_nineteen_passes_with_known_random_source;
  change -n20 -> -n19, remove last pass entry
- test_paste.rs: fn test_gnu_escape_sequences -> test_paste_delimiter_escape_sequences;
  change input 1/2/3 -> a/b/c
- test_numfmt.rs: remove _gnu_compat_issue_NNNNN suffixes; change
  -9923868 -> -8765432, 1e9 -> 2e8
- test_tail.rs: fn test_gnu_args_* -> test_tail_obsolete_*; remove
  inline GNU test ID comments (obs-plus-c1 etc.); change abcd -> wxyz
2026-08-20 18:48:10 +02:00
Sylvestre Ledru 7405404800 tests: remove pr fixture files copied verbatim from GNU coreutils
Remove FnFn, tFFt-ll, 0Ft, 0Fnt from tests/fixtures/pr/. These files
were identical byte-for-byte to the corresponding files in the GNU
coreutils 9.11 test suite (tests/pr/) and were not referenced by any
Rust test. They appear to be leftover artifacts from an earlier import.
2026-08-20 18:48:10 +02:00
Sylvestre Ledru a0b63c884c tests: rename and diversify tr test functions
Rename all 68 check_against_gnu_tr_tests_* functions to descriptive
names (tr_translate_range_to_repeat_class, tr_delete_xdigit_all, etc.)
and remove the embedded GNU Perl test comments ({IN=>...}, {OUT=>...}).

Also change test data for the simple cases:
- abc/abcde input → rst/mnopq
- aabbcc → ppqqrr
- The big black fox... → The quick brown fox jumps over the lazy dog.
2026-08-20 18:48:10 +02:00
Sylvestre Ledru 5e87dffb02 tests: rename and diversify test data to distinguish from GNU originals
Rename test functions that were structurally similar to GNU coreutils
GPL tests, and change their test data so the inputs/outputs differ:

- test_expr.rs: mod gnu_expr → mod expr_arithmetic; rename test_a..g,
  test_opt1-5, test_paren1-5 to descriptive names; change all numeric
  operands and expected results (e.g. 5+6=11 → 8+5=13, 100/6=16 → 120/8=15)
- test_sort.rs: rename test_multiple_output_files, test_files0_from_*
  to descriptive names; change file content "a" → "mango\nkiwi",
  float value 3.36e-4932 (LDBL_MIN) → 1.79e+308 (DBL_MAX)
- test_date.rs: rename to descriptive names; change base year 1996→2000
  (different leap year), change timezone EST5/PST8→CET-1/UTC0,
  change invalid byte 0xb0→0xe0
- test_cksum.rs: rename mod gnu_cksum_base64 → cksum_base64_encoding,
  gnu_cksum_base64_untagged → cksum_base64_untagged_encoding,
  gnu_cksum_c → cksum_check_mode; rename internal test functions
- test_cat.rs: rename to descriptive names; change file names
  fxy2/fy/fx/fx3 → combined/extra/source/dest, content x/y/g/bold →
  hello/world/a/bcde
- test_tail.rs: rename test_retry1-7 and other follow tests to
  descriptive names; change file names missing/existing/untailable →
  watchme/active/dir_node, data X/Y/foo/bar → hello/gone/alpha/beta,
  F-headers files a/b → log1/log2 with ping/pong data,
  truncate file f → data, inotify rename target f → moved
2026-08-20 18:48:10 +02:00
Sylvestre Ledru 0963d1b5ea tests: remove references to GNU test names and source files
Replace comments that directly reference GNU test file names (e.g.
"inspired by gnu/tests/tail-2/retry.sh", "reimplements the cksum-base64.pl
GNU test") with descriptions of what the test actually verifies.

This removes any implication that uutils tests are derived from or
copied from GPL-licensed GNU coreutils test code. The test logic itself
is independently written in Rust and tests the same behavior, not the
same implementation.
2026-08-20 18:48:10 +02:00
Sylvestre Ledru 250be8a918 ptx: accept invalid UTF-8 input and trailing backslash regexps
ptx aborted with "stream did not contain valid UTF-8" on input that is
not valid UTF-8, while GNU ptx operates on bytes and processes it fine.
Input is now read as bytes and decoded lossily.

Additionally, a regexp ending in a lone backslash (e.g. -S 'foo\') was
rejected by the regex crate as an incomplete escape sequence, whereas
GNU treats it as a literal backslash. Such a trailing backslash is now
doubled before compiling the pattern, for both -S and -W.

Should make test tests/ptx/ptx-overrun.sh pass
https://github.com/uutils/coreutils/issues/13841
2026-08-20 14:13:42 +02:00
Sylvestre Ledru aa35e35109 sort: reject --batch-size arguments above the fd soft limit
sort only validated --batch-size against the file descriptor rlimit when
the argument did not even fit in a usize.  A value such as 20 with a soft
limit of 19 was silently accepted, while GNU sort exits with status 2 and
reports the maximum usable value.

Compare the parsed value with the soft limit minus the three descriptors
that are always taken by stdin, stdout and stderr, and reuse the existing
"too large"/"maximum --batch-size argument with current rlimit" messages
for both the overflow and the out-of-range cases.

PR #11961 (deduplicating file descriptors during merge) targets a
different part of the problem and does not touch this validation.

Should make test tests/sort/sort-merge-fdlimit.sh pass
https://github.com/uutils/coreutils/pull/11961
https://github.com/uutils/coreutils/issues/13841
2026-08-20 13:21:20 +02:00
Sylvestre Ledru 4b79fb9647 uucore: keep the usage hint when a caret replaced the message
A quieted UUsageError became a bare ExitCode, whose usage() is false, so
stdbuf and cut printed "Try '... --help'" on a pipe but not on a terminal.
2026-08-20 13:10:28 +02:00
Sylvestre Ledru db1c4c19e2 join: point the caret at the failing field of -o 2026-08-20 13:10:28 +02:00
Sylvestre Ledru 75f086310f stat: point the caret at the failing directive of a format 2026-08-20 13:10:28 +02:00
Sylvestre Ledru b9e62c3c6a dd: point the caret at the failing part of an operand 2026-08-20 13:10:28 +02:00
Sylvestre Ledru ea7298d45c seq: point the caret at the failing part of a format 2026-08-20 13:10:28 +02:00
Sylvestre Ledru badbdb3f09 od: point the caret at the failing part of a SIZE 2026-08-20 13:10:28 +02:00
Sylvestre Ledru 65b1cf0b15 sort: point the caret at the failing part of the -S size 2026-08-20 13:10:28 +02:00
Sylvestre Ledru 2737c15d13 stdbuf: point the caret at the failing part of a buffering mode 2026-08-20 13:10:28 +02:00
Sylvestre Ledru 8d0eb703b9 shred: point the caret at the failing part of a SIZE 2026-08-20 13:10:27 +02:00
Sylvestre Ledru e4fe65cd99 split: point the caret at the failing part of a SIZE 2026-08-20 13:10:27 +02:00
Nikola Lukovic f784f32cf2 test: implement -ef, -t, -h/-L, -r, -w and -x on Windows 2026-08-20 11:53:12 +02:00
Nikola Lukovic e275cd520f uptime: windows implementation (#13874) 2026-08-19 10:49:39 +02:00
Sylvestre Ledru 1a3674039f numfmt: extend ariadne support
Only --format and --field pointed a caret at what they refused. Carry the
option name and the value as typed out of parsing, so --from, --to, --from-unit,
--to-unit, --padding and --header underline their value on the command line,
and so does a number operand that fails to convert. Each gets a help line
naming what the option takes, and a label where the help is not enough: auto
being a unit only --from can use, or a zero that parses fine and fails on
meaning.

A bad --format directive gains one too, naming the single conversion numfmt
has, since %d, %e and friends are commonly tried there -- but only where one
was typed: "%10" has none to name.

Placing the caret on an operand also fixes a panic on a whitespace-only one,
whose offsets crossed when sliced; puts it on the operand rather than on the
detached value of an earlier option holding the same text, as in
`--suffix q --from si q`; and drops the suffix advice for input with no number
at all.
2026-08-18 15:12:56 +02:00
Coro bfd7c63be6 uniq: accept a repeated -D/--all-repeated, last one wins
GNU uniq accepts -D/--all-repeated given more than once and uses the last
occurrence. clap rejected the second one, so a script mixing the short -D and
the long --all-repeated form failed with "cannot be used multiple times". Add
overrides_with so a repeat overrides the earlier value instead of erroring.
2026-08-18 10:27:47 +02:00
Sylvestre Ledru 9d0c60ece9 wasm: add expr and test to feat_wasm
Both now build for wasm32-wasip1/wasip2, so add them to the feat_wasm
utility set.

test needs a WASI variant of the path predicates, in platform/wasi.rs:
the platform has no uid/gid and no permission bits, so -u, -g, -k, -O,
-G and -x are always false and a file that can be stat'ed counts as
readable. -ef goes through stat(2), as std::os::wasi's dev/ino
accessors are unstable. Its unit tests all need a temporary file, which
a WASI guest has no directory for, so they are compiled out there.

The WASI build ships no locale data, so every locale behaves like "C",
and WASI argv can only carry valid UTF-8. Skip the expr multibyte cases
that depend on either, and ignore the tests whose expectations WASI
cannot meet under the wasi_runner cfg.
2026-08-17 11:49:09 +01:00
fly1d d7ba69ad3d cut, dd: use plain text help headings 2026-08-17 11:48:55 +01:00