Repository navigation
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
As with other coreutils-compatible backup controls,--backup=nevershould disable backups… · New GNU coreutils-style backup controls treat--backup=neveras disabling backups (equivalent to… · New The new parameterizedtest_cp_backup_controlonly exercises the argument order `cp SRC <options>… · New These///doc comments are now interleaved among#[case]attributes, so they no longer document… · New Same issue as intest_wc.rs: these///doc comments are now embedded inside arstestcase… · New Fix grammatical typo: change 'an file' to 'a file'. · New
What changed in this PR
This PR consolidates many one-off tests into parameterized rstest cases across several util test files to reduce duplication and make it easier to add new variants.
Changes:
- Replaced clusters of similar
#[test]functions with#[rstest]+#[case]tables in multiple files. - Standardized many assertions to
stdout_only(...)for stricter output checking. - Expanded some option-matrix coverage (e.g., backup controls, sparse/debug variants) by using multiple
#[case]s.
| File | Description |
|---|---|
| tests/by-util/test_wc.rs | Consolidates UTF-8, stdin, and argument-matrix tests into rstest cases. |
| tests/by-util/test_tr.rs | Merges many stdin translation/deletion/squeeze tests into one parameterized rstest. |
| tests/by-util/test_printf.rs | Collapses many formatting/escape tests into a large rstest table. |
| tests/by-util/test_mv.rs | Reworks backup-control tests into a single rstest with cases. |
| tests/by-util/test_install.rs | Reworks backup-control tests into rstest and adds a file→dir variant matrix. |
| tests/by-util/test_fold.rs | Merges many stdin folding behaviors into a single rstest case table. |
| tests/by-util/test_echo.rs | Collapses many escape/flag parsing tests into an rstest. |
| tests/by-util/test_cp.rs | Consolidates backup-control and debug/sparse tests into rstest matrices and shared helpers. |
Review effort: Lite
| #[case::simple(&["--backup=simple"], Some("~"))] | ||
| #[case::never(&["--backup=never"], Some("~"))] | ||
| #[case::none(&["--backup=none"], None)] | ||
| #[case::off(&["--backup=off"], None)] | ||
| fn test_install_backup_control(#[case] args: &[&str], #[case] backup_suffix: Option<&str>) { |
| #[case::simple(&["--backup=simple"], Some("~"))] | ||
| #[case::never(&["--backup=never"], Some("~"))] | ||
| #[case::none(&["--backup=none"], None)] | ||
| #[case::off(&["--backup=off"], None)] | ||
| fn test_mv_backup_control(#[case] args: &[&str], #[case] backup_suffix: Option<&str>) { |
| fn test_cp_backup_control(#[case] args: &[&str], #[case] backup_suffix: Option<&str>) { | ||
| let (at, mut ucmd) = at_and_ucmd!(); | ||
|
|
||
| ucmd.arg(TEST_HELLO_WORLD_SOURCE) | ||
| .args(args) | ||
| .arg(TEST_HOW_ARE_YOU_SOURCE) | ||
| .arg("-b") | ||
| .succeeds(); | ||
| .succeeds() |
| /// Test for an empty file. | ||
| #[case::file_empty(&["-clmwL", "emptyfile.txt"], "0 0 0 0 0 emptyfile.txt\n")] | ||
| /// Test for an file containing a single non-whitespace character | ||
| /// *without* a trailing newline. | ||
| #[case::file_single_line_no_trailing_newline(&["-clmwL", "notrailingnewline.txt"], "1 1 2 2 1 notrailingnewline.txt\n")] |
| /// A bare `-` has no trailing `w`, so it must not be mistaken for one of the | ||
| /// short spellings that consumes the next argument as its width -- that once | ||
| /// swallowed whatever followed the `-` operand instead of scanning it. | ||
| #[case::dash_operand_does_not_swallow_the_next_argument(&["-", "-5"], "hello\n", "hello\n")] | ||
| fn test_fold_stdin(#[case] args: &[&str], #[case] input: &str, #[case] expected: &str) { |
| #[case::single_all_counts(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"], " 5 57 302 302 66 alice_in_wonderland.txt\n")] | ||
| /// Test for an empty file. | ||
| #[case::file_empty(&["-clmwL", "emptyfile.txt"], "0 0 0 0 0 emptyfile.txt\n")] | ||
| /// Test for an file containing a single non-whitespace character |
155e725 to
7459dbd
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
7 open issues
GNU coreutils-style backup controls treat--backup=neveras disabling backups (equivalent to… As with other coreutils-compatible backup controls,--backup=nevershould disable backups… Intest_cp_backup_control, options are always inserted between the source and destination… · New These///doc comments are now interleaved among#[case]attributes, so they no longer document… The new parameterizedtest_cp_backup_controlonly exercises the argument order `cp SRC <options>… Fix grammatical typo: change 'an file' to 'a file'. Same issue as intest_wc.rs: these///doc comments are now embedded inside arstestcase…
Review effort: Lite
| ucmd.arg(TEST_HELLO_WORLD_SOURCE) | ||
| .args(args) | ||
| .arg(TEST_HOW_ARE_YOU_SOURCE) | ||
| .arg("-b") | ||
| .succeeds(); | ||
| .succeeds() | ||
| .no_stderr(); |



No description provided.