Skip to content

merge the tests into rstest cases - #15537

Open
sylvestre wants to merge 8 commits into
mainfrom
tests-rstest-dedup
Open

sylvestre wants to merge 8 commits into
mainfrom
tests-rstest-dedup

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
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

Comment on lines +1237 to +1241
#[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>) {
Comment thread tests/by-util/test_mv.rs
Comment on lines +850 to +854
#[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>) {
Comment thread tests/by-util/test_cp.rs
Comment on lines +1544 to +1550
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()
Comment thread tests/by-util/test_wc.rs Outdated
Comment on lines +117 to +121
/// 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")]
Comment thread tests/by-util/test_fold.rs Outdated
Comment on lines +128 to +132
/// 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) {
Comment thread tests/by-util/test_wc.rs Outdated
#[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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread tests/by-util/test_cp.rs
Comment on lines 1547 to +1551
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
.args(args)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("-b")
.succeeds();
.succeeds()
.no_stderr();

This branch has not been deployed

No deployments
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