The ungated test ran the same argv as
unix::test_every_failing_operand_is_reported_once_and_in_order and
asserted a subset of what it does. It was kept for the Windows leg, but
the one thing it added there, that an operand after a failure is still
renamed, is already pinned on every platform by the tally table: its
`s9 s1` row can only exit 2 if the rename after the failure happened.
No other utility in the tree adjusts argv before clap parses it, and
keeping rename on clap's behavior like the rest is worth more than
matching getopt in this one corner.
Without POSIXLY_CORRECT the rewrite handed argv back untouched, so only
runs with the variable set change. There, an argument after the first
operand that begins with `-` is now read as an option, as it already is
without the variable, where C util-linux reads it as a filename or as
the replacement. `--` still ends the options in both.
Sixty-four tests: the exit-status tally, the three substitution modes,
the path-scope rule, both overwrite guards, symlink mode, byte-oriented
names, and the test_invalid_arg smoke test every other util carries.
They defend the decisions a refactor would plausibly undo rather than
restating what clap already guarantees. The two overwrite predicates and
their opposite treatment of a dangling destination, the short circuit
that runs before any syscall, and the order of stripping against the
existence check each have a test whose only job is to fail if someone
tidies them away.
Diagnostics are asserted only as far as we write them. The errno text
after our half belongs to libc, so the suite does not pin strerror
strings on platforms it cannot run.
The substitution engine keeps its unit tests beside it in subst.rs.
`cargo test` from the workspace root does not run them, because the root
package is the only default member; `cargo test -p uu_rename` does.
* chcpu: report each error only once
Every failure was printed twice: `CpuList::run` reported it itself with a raw
`eprintln!`, then also returned it, so `uucore` printed it again with the
`chcpu: ` prefix. The unprefixed copy came first, which is the one users saw.
Reporting each per-CPU failure with `uucore::show!` keeps the diagnostic for
every element of a CPU list, gives all of them the program-name prefix that
was previously only on the duplicate, and sets the exit code rather than
returning an error - the pattern uucore documents for non-fatal errors when
applying an operation to many items. Exit codes are untouched: 1 when nothing
succeeded, 64 for partial success.
Adds the first tests for this utility, covering the error paths. They need no
privileges and change no CPU state: an absent CPU index is rejected before
anything is written, and enabling an already-enabled CPU only prints.
* chcpu: cover argument parsing in tests
These reach only clap, never sysfs, so they also guard the option surface on
the platforms where the utility itself is unimplemented.
---------
Co-authored-by: mmc <codeberg.wilder850@simplelogin.com>
This supports the same functionality as util-linux hexdump except for
--format and --color options. Output should be bit-exact, except as
added bonus this supports the `-s` option on pipes and other non-seekable
files.
* feat(last): add --since and --until
* clean up clap slightly
* fix clippy
* test(last): add tests for --since and --until
* refactor(last): resolve review comments
* test(last): set cfg for since and until to unix
* remove unnecessary comment
* move parse_time_value below uumain
* minor cleanup
* fix ci issues
* last: fix not all hostnames are shown in the last column with --hostlast option
* last: fix not all hostnames are shown in the last column with --hostlast option
* Added test case related to the hostlast option in last command.
* Change binary input fixture name for last command and Fix format source code.
* feat: add macOS platform & update tests for compatibility
* fix: correct formatting in platform and test files for macOS compatibility
* fix: format
* fix: correct variable name and improve test output handling