Skip to content

Unify test code in bootstrap #104198

Closed
@jyn514

Description

@jyn514

Right now, we copy paste a bunch of code in various places and it ends up with not all test suites supporting the same arguments. See for example #66458. We should refactor all these Steps to use the same logic for the flags to pass to cargo.

rust/src/bootstrap/test.rs

Lines 2448 to 2464 in 131ef95

if !builder.fail_fast {
cmd.arg("--no-fail-fast");
}
match builder.doc_tests {
DocTests::Only => {
cmd.arg("--doc");
}
DocTests::No => {
cmd.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
}
DocTests::Yes => {}
}
cmd.arg("--").args(&builder.config.cmd.test_args());
// rustbuild tests are racy on directory creation so just run them one at a time.
// Since there's not many this shouldn't be a problem.
cmd.arg("--test-threads=1");
is an example of code that's repeated nearly verbatim 5+ times in test.rs. It would be nice to have a fn test_args(cargo: &mut Cargo) {} that we call instead of trying to keep these in sync.

Originally posted by @jyn514 in #72536 (comment)

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustcC-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions