Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify test code in bootstrap #104198

Closed
jyn514 opened this issue Nov 9, 2022 · 8 comments · Fixed by #110576
Closed

Unify test code in bootstrap #104198

jyn514 opened this issue Nov 9, 2022 · 8 comments · Fixed by #110576
Assignees
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jyn514
Copy link
Member

jyn514 commented Nov 9, 2022

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)

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. labels Nov 9, 2022
@dotdot0
Copy link
Contributor

dotdot0 commented Nov 9, 2022

@jyn514 Can I work on this issue?

@jyn514
Copy link
Member Author

jyn514 commented Nov 9, 2022

Sure :)

@dotdot0
Copy link
Contributor

dotdot0 commented Nov 9, 2022

So what are the things need to be done. Can you guide me?

@jyn514
Copy link
Member Author

jyn514 commented Nov 9, 2022

@pratushrai0309 no, sorry, I don't have more time available to work on this issue. If you have specific questions about the things I wrote in the issue description I can answer those.

@dotdot0 dotdot0 removed their assignment Nov 9, 2022
@dotdot0
Copy link
Contributor

dotdot0 commented Nov 10, 2022

@jyn514 So we just have to create a function test_args with the code you have linked in the comment right??

@jyn514
Copy link
Member Author

jyn514 commented Nov 10, 2022

That is one part of the work, yes. There is other duplicated code I don't remember off the top of my head, glancing around test.rs should show several examples. But adding and using the function I mentioned would be a good start.

@dotdot0
Copy link
Contributor

dotdot0 commented Nov 10, 2022

@rustbot claim

@Ezrashaw
Copy link
Contributor

Not sure if @pratushrai0309 is still working on this, I'll also do some work here

@rustbot claim

@rustbot rustbot assigned Ezrashaw and unassigned dotdot0 Jan 13, 2023
@jyn514 jyn514 assigned jyn514 and unassigned Ezrashaw Apr 20, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 22, 2023
bootstrap: Unify test argument handling

Fixes rust-lang#104198. Does *not* help with rust-lang#80124 because I couldn't figure out a reasonable way to omit `--lib` only for `panic_abort` and not other `std` dependencies.

- Remove unnecessary `test_kind` field and `TestKind` struct. These are just subsets of the existing `builder.kind` / `Kind` struct.
- Add a new `run_cargo_test` function which handles passing arguments to cargo based on `builder.config`
- Switch all Steps in `mod test` to `run_cargo_test` where possible
- Combine several steps into one `CrateBootstrap` step. These tests all do the same thing, just with different crate names.
- Fix `x test --no-doc`. This is much simpler after the refactors mentioned earlier, but I'm happy to split it into a separate PR if desired. Before, this would panic a lot because steps forgot to pass `--lib`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 22, 2023
bootstrap: Unify test argument handling

Fixes rust-lang#104198. Does *not* help with rust-lang#80124 because I couldn't figure out a reasonable way to omit `--lib` only for `panic_abort` and not other `std` dependencies.

- Remove unnecessary `test_kind` field and `TestKind` struct. These are just subsets of the existing `builder.kind` / `Kind` struct.
- Add a new `run_cargo_test` function which handles passing arguments to cargo based on `builder.config`
- Switch all Steps in `mod test` to `run_cargo_test` where possible
- Combine several steps into one `CrateBootstrap` step. These tests all do the same thing, just with different crate names.
- Fix `x test --no-doc`. This is much simpler after the refactors mentioned earlier, but I'm happy to split it into a separate PR if desired. Before, this would panic a lot because steps forgot to pass `--lib`.
compiler-errors added a commit to compiler-errors/rust that referenced this issue Apr 22, 2023
bootstrap: Unify test argument handling

Fixes rust-lang#104198. Does *not* help with rust-lang#80124 because I couldn't figure out a reasonable way to omit `--lib` only for `panic_abort` and not other `std` dependencies.

- Remove unnecessary `test_kind` field and `TestKind` struct. These are just subsets of the existing `builder.kind` / `Kind` struct.
- Add a new `run_cargo_test` function which handles passing arguments to cargo based on `builder.config`
- Switch all Steps in `mod test` to `run_cargo_test` where possible
- Combine several steps into one `CrateBootstrap` step. These tests all do the same thing, just with different crate names.
- Fix `x test --no-doc`. This is much simpler after the refactors mentioned earlier, but I'm happy to split it into a separate PR if desired. Before, this would panic a lot because steps forgot to pass `--lib`.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 23, 2023
bootstrap: Unify test argument handling

Fixes rust-lang#104198. Does *not* help with rust-lang#80124 because I couldn't figure out a reasonable way to omit `--lib` only for `panic_abort` and not other `std` dependencies.

- Remove unnecessary `test_kind` field and `TestKind` struct. These are just subsets of the existing `builder.kind` / `Kind` struct.
- Add a new `run_cargo_test` function which handles passing arguments to cargo based on `builder.config`
- Switch all Steps in `mod test` to `run_cargo_test` where possible
- Combine several steps into one `CrateBootstrap` step. These tests all do the same thing, just with different crate names.
- Fix `x test --no-doc`. This is much simpler after the refactors mentioned earlier, but I'm happy to split it into a separate PR if desired. Before, this would panic a lot because steps forgot to pass `--lib`.
@bors bors closed this as completed in 87b1f89 Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants