Commit 16af7d4
authored
ls: Implement -f flag to disable sorting and enable -a (uutils#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 uutils#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 uutils#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.1 parent 2884718 commit 16af7d4
File tree
4 files changed
+448
-36
lines changed- src/uu/ls
- locales
- src
- tests/by-util
4 files changed
+448
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
440 | | - | |
441 | | - | |
442 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
443 | 458 | | |
444 | 459 | | |
445 | | - | |
| 460 | + | |
| 461 | + | |
446 | 462 | | |
447 | 463 | | |
448 | 464 | | |
| |||
452 | 468 | | |
453 | 469 | | |
454 | 470 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
486 | 534 | | |
487 | 535 | | |
488 | 536 | | |
| |||
540 | 588 | | |
541 | 589 | | |
542 | 590 | | |
543 | | - | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
544 | 607 | | |
545 | 608 | | |
546 | 609 | | |
547 | 610 | | |
548 | 611 | | |
549 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
550 | 625 | | |
551 | 626 | | |
552 | 627 | | |
| |||
1575 | 1650 | | |
1576 | 1651 | | |
1577 | 1652 | | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1578 | 1659 | | |
1579 | 1660 | | |
1580 | 1661 | | |
| |||
0 commit comments