coreutils/src
Cả thế giới là Rust 16af7d4f9a
ls: Implement -f flag to disable sorting and enable -a (#8824)
* ls: implement -f flag with correct constant, color logic, and localization

Fix the -f flag implementation to properly enable all files display,
disable sorting, and handle color output correctly.

Changes:
- Correct UNSORTED_ALL constant from 'unsorted-all' to 'f'
- Fix color logic to honor explicit --color flag regardless of -f position
- Add French localization for ls-help-unsorted-all
- Add comprehensive integration tests for -f flag behavior

The explicit --color flag now always takes precedence over -f implicit
color disabling, matching expected CLI behavior.

* tests(ls): improve -f flag test assertions

Address maintainer feedback from PR #8824 review:

1. test_f_flag_disables_sorting: Compare -f output with -a (sorted) and -U (unsorted)
   to prove sorting is actually disabled, not just that files appear in output

2. test_f_overrides_big_a: Rename from test_f_overrides_a_and_big_a and fix assertions
   to check for .. presence (distinguishes -f from -A) instead of .hidden (shown in both)

3. test_f_overrides_sort_flags: Use size-based files and explicit output comparisons
   to verify last-flag-wins behavior with deterministic ordering

4. test_big_u_overrides_f_sort: Use size-based files and verify -U participates
   in last-flag-wins by checking actual output order

All tests now properly validate flag interactions instead of just checking file presence.

* refactor(ls): use match expression in extract_sort

Replace if/else chain with match expression for improved readability
and more idiomatic Rust code. Uses match guards for index comparisons.

Addresses maintainer feedback from PR #8824 review.

No functional changes - behavior remains identical.

* fix(ls): use snake_case for test variable names

Follow Rust naming conventions by converting variable names in -f flag
tests from mixed case (out_Af, out_fS, etc.) to snake_case (out_a_f,
out_f_s, etc.). This eliminates clippy warnings about non_snake_case
identifiers.

* tests: fix flaky ls tests that depend on filesystem directory order

The tests test_f_flag_disables_sorting, test_big_u_overrides_f_sort, and
test_f_overrides_sort_flags made incorrect assumptions that unsorted
directory order would always differ from sorted order. However,
fs::read_dir() returns entries in filesystem-dependent order which may
accidentally match sorted order on some filesystems.

Changes:
- Removed assertions comparing unsorted vs sorted outputs
- Added deterministic checks (e.g., verifying --sort after -f works)
- Added explicit order verification for size-sorted outputs
- Tests now verify flag precedence without relying on directory order

Fixes CI failures on Windows and SELinux platforms.

Quality checks passed:
- cargo fmt --check: ✓
- cargo clippy --test tests: ✓
- all 3 modified tests pass: ✓

* test: fix misleading test name for -U flag behavior

Renamed test_big_u_overrides_f_sort to test_big_u_participates_in_sort_flag_wins
to accurately reflect that it tests -U with -S interactions, not -f.
2025-10-13 09:42:25 +02:00
..
bin Fix the doc generation and remove uuhelp_parser 2025-09-11 21:30:33 +02:00
uu ls: Implement -f flag to disable sorting and enable -a (#8824) 2025-10-13 09:42:25 +02:00
uucore uucore: ringbuffer pre-allocates memory based on size given 2025-10-12 18:46:41 -04:00
uucore_procs Fix the doc generation and remove uuhelp_parser 2025-09-11 21:30:33 +02:00