Skip to content

Conversation

@mattsu2020
Copy link
Contributor

Summary

Align tsort with GNU behavior: silently accept -w, reorder successors to produce GNU’s deterministic output, and surface loop errors with the new util: error: … prefix via clap_localization::print_prefixed_error.
Adjust uniq, comm, tsort, and chroot tests to expect the prefixed error strings so they continue to pass with the updated localization handling.
Keep the test fixtures and assertions consistent with the updated message format across the suite.

Tests

cargo test test_tsort
cargo test test_uniq (including gnu_tests)
cargo test test_chroot --features chroot

…raph topologies

- Introduce new test cases for cycle loops in file inputs, including extra nodes and multiple loops
- Add tests for POSIX graph examples and linear tree graphs to validate topological sorting
- Include tests for error handling on odd token counts and multiple file inputs
- Ensures robustness and correctness of tsort implementation across various edge cases and standard scenarios
…ne literals in tsort test file

- Reformatted TSORT_LOOP_STDERR_AC and TSORT_UNEXPECTED_ARG_ERROR constants for improved code readability and consistency, with no change in string content or functionality. The multi-line format was merged into single lines to align with potential linting rules or style preferences for string literals in tests. This refactoring enhances maintainability without affecting test logic.
- Added `ArgAction` import and a new hidden `-w`/`--warn` argument to the tsort command for future warning features
- Modified iteration of successor names to use `.into_iter().rev()` in the topological sorting algorithm to process nodes in reverse order, ensuring more stable and predictable output sequence
- Refactored Clap error localization in `clap_localization.rs` to use `print_prefixed_error()` method instead of direct `eprintln!` calls, improving consistency in error message formatting across the application
Update expected error outputs in uniq tests to match the new format where error messages are prefixed with "uniq: ". This ensures test cases align with the updated error message formatting in the utility, providing clearer error identification by including the program name at the start of each error message. Changes affect multiple test assertions for invalid options and incompatible argument combinations.
The expected error message now starts with "chroot: " to match the updated output format in the chroot utility. This ensures the test accurately reflects the command's behavior.
…d format

Remove "chroot: " prefix from expected error output, aligning the test with the updated stderr format that omits utility name redundancy in error messages.
Remove the 'uniq: ' prefix from expected error messages in test cases to match the updated output format of the uniq utility, ensuring tests pass with the current implementation. This change affects multiple GNU compatibility tests for invalid options and argument conflicts.
…t 'comm: ' prefix

The stderr assertion in test_comm_arg_error was expecting an error message prefixed with "comm: ", but the actual command output does not include this prefix. This update fixes the test to align with the real behavior, ensuring the test passes correctly.
… stderr output in ErrorFormatter

Replace the call to self.print_prefixed_error with direct eprintln for printing unexpected argument errors, and add an additional blank line for better formatting and readability in error messages. This change aims to simplify the output process and ensure consistent error presentation in the clap localization module.
@mattsu2020 mattsu2020 changed the title tsort: gnu misc /tsort.pl tsort: gnu misc tsort.pl Nov 15, 2025
…irect eprintln for cleaner output

Modified error handling in clap_localization.rs to eliminate the utility name prefix by replacing self.print_prefixed_error calls with direct eprintln! invocations. This simplifies the codebase and changes error message formatting to display clap errors without the preceding util name. Removed the unused print_prefixed_error method.
…age is corrected

- Added #[ignore] attribute to test_only_one_input_file to skip it during execution.
- Reason: Test likely fails due to an incorrect error message; this prevents false negatives while the message is being fixed in the tsort utility.
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 16, 2025

CodSpeed Performance Report

Merging #9289 will not alter performance

Comparing mattsu2020:tsort_compatibility (7cb4474) with main (370ea74)

Summary

✅ 127 untouched
⏩ 6 skipped1

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

is it expected that tsort.pl doesn't pass yet? thanks

- Change FILE arg to accept zero or more inputs (appended), defaulting to "-" if none
- Add validation to error on more than one input with "extra operand" message
- Update test to expect new error format, matching GNU tsort behavior
- Unignore test_only_one_input_file after error message correction
Split the TSORT_EXTRA_OPERAND_ERROR constant string into multiple lines
to improve code formatting and adhere to line length guidelines.
Removed the tests_tsort.patch entry as it is no longer applied, possibly due to upstream integration or obsolescence, to keep the patch series current and relevant.
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/misc/tsort is no longer failing!

…rapper

Remove unnecessary `.into()` call when creating the extra operand error in uumain,
resulting in cleaner, more concise error handling code. This change does not alter
the program's functionality but improves code readability and reduces nesting.
@github-actions
Copy link

github-actions bot commented Dec 2, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/misc/tsort is no longer failing!

return Err(USimpleError::new(
1,
format!(
"extra operand {}\nTry 'tsort --help' for more information.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the translate!() macro

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

));
}

let input = inputs.into_iter().next().expect("at least one input");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Add localized strings for 'extra operand' and 'at least one input' errors in en-US and fr-FR locales. Update code to use translate! macro for consistent error reporting across languages, improving user experience for international users.
The translate! macro returns a String, but expect() requires a &str. Added .as_str() to convert the translated string for correct type usage and fix compilation error.
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

GNU testsuite comparison:

Congrats! The gnu test tests/misc/tsort is no longer failing!

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/misc/tsort is no longer failing!

@sylvestre sylvestre merged commit 0f8eb45 into uutils:main Dec 23, 2025
125 of 126 checks passed
@mattsu2020 mattsu2020 deleted the tsort_compatibility branch December 23, 2025 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants