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

Passing --no-doc to ./x.py test causes panic_abort tests to fail #80124

Open
jacob-hughes opened this issue Dec 17, 2020 · 4 comments
Open

Passing --no-doc to ./x.py test causes panic_abort tests to fail #80124

jacob-hughes opened this issue Dec 17, 2020 · 4 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@jacob-hughes
Copy link
Contributor

Running ./x.py test --stage 1 --no-doc on the latest version of nightly (#80114) causes the test suite to crash with the following error:

error: building tests with panic=abort is not supported without `-Zpanic_abort_tests`

error: aborting due to previous error

error: could not compile `panic_abort`

This seems like a bug in the bootstrapper where --no-doc causes tests to be erroneously compiled with the abort panic strategy, since tests pass as expected with ./x.py test --stage 1 (--no-doc omitted)

This error can be also triggered with a subset of the test suite by running ./x.py test library/panic_abort --stage 1 --no-doc

@jacob-hughes jacob-hughes added the C-bug Category: This is a bug. label Dec 17, 2020
@jyn514 jyn514 added A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Dec 17, 2020
@jyn514
Copy link
Member

jyn514 commented May 1, 2021

This also reproduces with --stage 0.

@jyn514
Copy link
Member

jyn514 commented May 1, 2021

I think the issue is that bootstrap passes --lib", "--bins", "--examples", "--tests", "--benches" to the target, and that isn't valid for this target. This fixes the issue:

diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 965d1162145..2b6266be7ee 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -1887,7 +1887,7 @@ fn run(self, builder: &Builder<'_>) {
                 cargo.arg("--doc");
             }
             DocTests::No => {
-                cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
+                cargo.args(&["--bins", "--examples", "--tests", "--benches"]);
             }
             DocTests::Yes => {}
         }

I've suggested "--no-doc" (and similar things) to the cargo team before, but I don't think there's currently an RFC for it.

@jyn514
Copy link
Member

jyn514 commented May 1, 2021

Also it seems like a bug that cargo tries to compile unit tests for the crate even though they're disabled:


@ehuss do you happen to know if there's an open issue for that?

@ehuss
Copy link
Contributor

ehuss commented May 1, 2021

For now, that is intentional behavior, so that you can override the setting via the command-line. I feel like it is a toss-up which behavior is better, but for now it's working as intended.

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 added a commit to rust-lang-ci/rust that referenced this issue Apr 29, 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`.
@Enselic Enselic added A-testsuite Area: The testsuite used to check the correctness of rustc and removed A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows labels Dec 17, 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-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

4 participants