uname: add -A/--all-labeled, following GNU master - #13912
Conversation
There was a problem hiding this comment.
Pull request overview
Adds GNU-compatible uname -A/--all-labeled output (one labeled item per line) to the uname utility, including CLI wiring, localized help/labels, and regression tests.
Changes:
- Add
-A/--all-labeledflag, plus labeled multi-line output formatting inuname. - Add new localization keys for the flag help text and output labels (en-US, fr-FR).
- Add Rust tests for
-Abehavior and--all-labeledequivalence; update GNU fetch script to backport the corresponding GNU test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| util/fetch-gnu.sh | Adds GNU test backport entry and attempts to register backported tests in GNU build files. |
| tests/by-util/test_uname.rs | Adds tests for -A output shape and --all-labeled parity with -A. |
| src/uu/uname/src/uname.rs | Implements --all-labeled option, labeled output generation, and CLI flag wiring. |
| src/uu/uname/locales/en-US.ftl | Adds help text and label strings for --all-labeled. |
| src/uu/uname/locales/fr-FR.ftl | Adds French help text and label strings for --all-labeled. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| let Some(value) = value else { continue }; | ||
| out.push(translate!(label)); | ||
| out.push(": "); | ||
| out.push(value); | ||
| out.push("\n"); |
Merging this PR will regress 1 benchmark
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (3)
util/fetch-gnu.sh:24
sed -iplus\nand\tin the replacement string is GNU-sed-specific; on BSD/macOS sed this commonly fails or inserts literaln/t, which can corruptall_testsand breakmake check. Consider switching this block to a more portable insertion approach (e.g., a small Perl/Python edit, or a POSIX-sed-compatible multiline insert), and avoid relying on\tescape handling in sed replacements.
# A test that does not exist in $ver at all is absent from its test list, so
# `make check` would silently never run it. Register those in both the automake
# input and the generated Makefile.in: configure derives Makefile from the
# latter, and build-gnu.sh deliberately keeps automake from re-running.
for f in "${backport[@]}"; do
grep -qF "tests/$f" tests/local.mk ||
sed -i "s|^all_tests =.*|&\n tests/$f\t\t\t\t\\\\|" tests/local.mk
grep -qF "tests/$f" Makefile.in ||
sed -i "s|^all_tests =.*|&\n tests/$f\t\t\t\t\\\\|" Makefile.in
done
src/uu/uname/src/uname.rs:79
- The output punctuation/spacing (
": ") is hardcoded in code rather than localized. This makes locale-specific typography impossible (e.g., French commonly uses a space before:) and forces all locales into the same formatting. A more maintainable approach is to include the separator/format in the localized string (e.g., make labels include:/ spacing, or use a single localized format string that takes{ label }and{ value }).
out.push(translate!(label));
out.push(": ");
out.push(value);
out.push("\n");
tests/by-util/test_uname.rs:154
- This test asserts English label text even though the implementation uses localized strings (
translate!(...)). If the test runner environment ever selects a non-English locale, this becomes brittle. To make the test deterministic, consider forcing the locale for the invoked command (e.g., setLC_ALL=C/LANG=en_US.UTF-8via the test command builder) or asserting against non-localized invariants (like line count + presence of values) rather than specific translated labels.
fn test_uname_all_labeled() {
let result = new_ucmd!().arg("-A").succeeds();
let stdout = result.stdout_str();
// One labeled "Label: value" line per item. Like GNU, an unknown processor or
// hardware platform is omitted, and we never determine either one.
assert_eq!(stdout.lines().count(), 6);
for label in [
"Kernel name: ",
"Node name: ",
"Kernel release: ",
"Kernel version: ",
"Machine: ",
"Operating system: ",
] {
assert!(stdout.contains(label), "missing {label:?}");
}
|
Binary size comparison: |
|
GNU testsuite comparison: |
No description provided.