-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add initial version of snapshot tests to bootstrap #142431
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
Conversation
The job Click to see the possible cause of the failure (guessed by this bot)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. Fully agreed that we really need some better testing infra here.
Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now.
I think it's important to land some testing infra support to help with fixing bootstrap, does not have to be perfect.
// FIXME: return the correct stage from the `Rustc` step, now it behaves weirdly | ||
render_compiler(Compiler::new(rustc.build_compiler.stage + 1, rustc.target)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: 😰
@bors r+ rollup |
…=jieyouxu Add initial version of snapshot tests to bootstrap When making any changes to bootstrap (steps), it is very difficult to realize how does it affect various common bootstrap commands, and if everything still works as we expect it to. We are far away from having actual end-to-end tests, but what we could at least do is have a way of testing what steps does bootstrap execute in dry run mode. Now, we already have something like this in `src/bootstrap/src/core/builder/tests.rs`, however that is quite limited, because it only checks executed steps for a specific impl of `Step` and it does not consider step order. Recently, when working on what I thought was one of the simplest possible step untanglings in bootstrap (rust-lang#142357), I ran into errors in tests that were quite hard to debug. Partly also because the current staging test diffs are multiline and use `Debug` output, so it's quite difficult for me to make sense of them. In this PR, I introduce `insta`, which allows writing snapshot tests in a very simple way. With it, I want to allow writing tests that will clearly show us what is going on during bootstrap execution, and then write golden tests for `build/check/test` stage `0/1/2` for compiler/std/tools etc., to make sure that we don't regress something, and also to help with [#t-infra/bootstrap > Proposal to cleanup stages and steps after the redesign](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Proposal.20to.20cleanup.20stages.20and.20steps.20after.20the.20redesign/with/523488806), to help avoid a situation where we would (again) have to make a flurry of staging changes because of unexpected consequences. In the snapshot tests, we currently render the build of rustc, std and LLVM. Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now. I implemented only a single test using the new machinery. Maybe if you take a look at it, you will understand why 😆 Bootstrap currently does some peculiar things, such as running a stage 0 std step (even though stage 0 std no longer exists) and running the Rustc stage 0 -> 1 step twice, once with a single crates, once with all rustc crates. So I think that even with this single step, there will be a bunch of things to fix in the near future... The way we currently prepare the Config test fixtures is far from ideal, this is something I think `@Shourya742` could work on as a part of their GSoC project (remove as much command execution from Config construction as possible, actually run bootstrap on a temporary directory instead of running it on the rustc checkout, create a Builder-like API for creating the Config test fixtures). r? `@jieyouxu`
Rollup of 8 pull requests Successful merges: - #140809 (Reduce special casing for the panic runtime) - #142082 (Refactor `rustc_attr_data_structures` documentation) - #142125 (Stabilize "file_lock" feature) - #142373 (Fix Debug for Location) - #142414 (ignore `run-make` tests that need `std` on targets without `std`) - #142416 (Assorted bootstrap cleanups (step 2)) - #142431 (Add initial version of snapshot tests to bootstrap) - #142528 (clarify `rustc_do_not_const_check` comment) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 12 pull requests Successful merges: - #141639 (Expose discriminant values in stable_mir) - #142082 (Refactor `rustc_attr_data_structures` documentation) - #142125 (Stabilize "file_lock" feature) - #142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls) - #142373 (Fix Debug for Location) - #142416 (Assorted bootstrap cleanups (step 2)) - #142431 (Add initial version of snapshot tests to bootstrap) - #142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`) - #142528 (clarify `rustc_do_not_const_check` comment) - #142530 (use `if let` guards where possible) - #142561 (Remove an `njn:` comment accidentaly left behind.) - #142566 (Fix `-nopt` CI jobs) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #142431 - Kobzol:bootstrap-snapshot-tests, r=jieyouxu Add initial version of snapshot tests to bootstrap When making any changes to bootstrap (steps), it is very difficult to realize how does it affect various common bootstrap commands, and if everything still works as we expect it to. We are far away from having actual end-to-end tests, but what we could at least do is have a way of testing what steps does bootstrap execute in dry run mode. Now, we already have something like this in `src/bootstrap/src/core/builder/tests.rs`, however that is quite limited, because it only checks executed steps for a specific impl of `Step` and it does not consider step order. Recently, when working on what I thought was one of the simplest possible step untanglings in bootstrap (#142357), I ran into errors in tests that were quite hard to debug. Partly also because the current staging test diffs are multiline and use `Debug` output, so it's quite difficult for me to make sense of them. In this PR, I introduce `insta`, which allows writing snapshot tests in a very simple way. With it, I want to allow writing tests that will clearly show us what is going on during bootstrap execution, and then write golden tests for `build/check/test` stage `0/1/2` for compiler/std/tools etc., to make sure that we don't regress something, and also to help with [#t-infra/bootstrap > Proposal to cleanup stages and steps after the redesign](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Proposal.20to.20cleanup.20stages.20and.20steps.20after.20the.20redesign/with/523488806), to help avoid a situation where we would (again) have to make a flurry of staging changes because of unexpected consequences. In the snapshot tests, we currently render the build of rustc, std and LLVM. Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now. I implemented only a single test using the new machinery. Maybe if you take a look at it, you will understand why 😆 Bootstrap currently does some peculiar things, such as running a stage 0 std step (even though stage 0 std no longer exists) and running the Rustc stage 0 -> 1 step twice, once with a single crates, once with all rustc crates. So I think that even with this single step, there will be a bunch of things to fix in the near future... The way we currently prepare the Config test fixtures is far from ideal, this is something I think ``@Shourya742`` could work on as a part of their GSoC project (remove as much command execution from Config construction as possible, actually run bootstrap on a temporary directory instead of running it on the rustc checkout, create a Builder-like API for creating the Config test fixtures). r? ``@jieyouxu``
Rollup of 12 pull requests Successful merges: - rust-lang#141639 (Expose discriminant values in stable_mir) - rust-lang#142082 (Refactor `rustc_attr_data_structures` documentation) - rust-lang#142125 (Stabilize "file_lock" feature) - rust-lang#142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls) - rust-lang#142373 (Fix Debug for Location) - rust-lang#142416 (Assorted bootstrap cleanups (step 2)) - rust-lang#142431 (Add initial version of snapshot tests to bootstrap) - rust-lang#142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`) - rust-lang#142528 (clarify `rustc_do_not_const_check` comment) - rust-lang#142530 (use `if let` guards where possible) - rust-lang#142561 (Remove an `njn:` comment accidentaly left behind.) - rust-lang#142566 (Fix `-nopt` CI jobs) r? `@ghost` `@rustbot` modify labels: rollup
When making any changes to bootstrap (steps), it is very difficult to realize how does it affect various common bootstrap commands, and if everything still works as we expect it to. We are far away from having actual end-to-end tests, but what we could at least do is have a way of testing what steps does bootstrap execute in dry run mode. Now, we already have something like this in
src/bootstrap/src/core/builder/tests.rs
, however that is quite limited, because it only checks executed steps for a specific impl ofStep
and it does not consider step order.Recently, when working on what I thought was one of the simplest possible step untanglings in bootstrap (#142357), I ran into errors in tests that were quite hard to debug. Partly also because the current staging test diffs are multiline and use
Debug
output, so it's quite difficult for me to make sense of them.In this PR, I introduce
insta
, which allows writing snapshot tests in a very simple way. With it, I want to allow writing tests that will clearly show us what is going on during bootstrap execution, and then write golden tests forbuild/check/test
stage0/1/2
for compiler/std/tools etc., to make sure that we don't regress something, and also to help with #t-infra/bootstrap > Proposal to cleanup stages and steps after the redesign, to help avoid a situation where we would (again) have to make a flurry of staging changes because of unexpected consequences.In the snapshot tests, we currently render the build of rustc, std and LLVM. Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now.
I implemented only a single test using the new machinery. Maybe if you take a look at it, you will understand why 😆 Bootstrap currently does some peculiar things, such as running a stage 0 std step (even though stage 0 std no longer exists) and running the Rustc stage 0 -> 1 step twice, once with a single crates, once with all rustc crates. So I think that even with this single step, there will be a bunch of things to fix in the near future...
The way we currently prepare the Config test fixtures is far from ideal, this is something I think @Shourya742 could work on as a part of their GSoC project (remove as much command execution from Config construction as possible, actually run bootstrap on a temporary directory instead of running it on the rustc checkout, create a Builder-like API for creating the Config test fixtures).
r? @jieyouxu