diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-06-12 14:27:29 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-06-12 14:27:29 +0200 |
| commit | 5b50e0ba54c70f68f4e32d3ed0c3a6a7a5e7a7ac (patch) | |
| tree | 39e1070f20184893f287447cd233c0f2508baebb | |
| parent | fd50e1012f79eb93f661adc6f276335e4cfb34ea (diff) | |
| download | rust-5b50e0ba54c70f68f4e32d3ed0c3a6a7a5e7a7ac.tar.gz rust-5b50e0ba54c70f68f4e32d3ed0c3a6a7a5e7a7ac.zip | |
Add support for snapshot tests with insta
| -rw-r--r-- | src/bootstrap/Cargo.lock | 36 | ||||
| -rw-r--r-- | src/bootstrap/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/bootstrap/README.md | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 2 |
4 files changed, 43 insertions, 0 deletions
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock index 0c8e6633560..a6ca699e282 100644 --- a/src/bootstrap/Cargo.lock +++ b/src/bootstrap/Cargo.lock @@ -44,6 +44,7 @@ dependencies = [ "fd-lock", "home", "ignore", + "insta", "junction", "libc", "object", @@ -159,6 +160,18 @@ dependencies = [ ] [[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] name = "cpufeatures" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -219,6 +232,12 @@ dependencies = [ ] [[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] name = "errno" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -324,6 +343,17 @@ dependencies = [ ] [[package]] +name = "insta" +version = "1.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "154934ea70c58054b556dd430b99a98c2a7ff5309ac9891597e339b5c28f4371" +dependencies = [ + "console", + "once_cell", + "similar", +] + +[[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -676,6 +706,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index b12b3dfc7b2..9785a306c9b 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -84,6 +84,7 @@ features = [ [dev-dependencies] pretty_assertions = "1.4" tempfile = "3.15.0" +insta = "1.43" # We care a lot about bootstrap's compile times, so don't include debuginfo for # dependencies, only bootstrap itself. diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index f9d7c811f60..5ff999f01a9 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -200,6 +200,10 @@ please file issues on the [Rust issue tracker][rust-issue-tracker]. [rust-bootstrap-zulip]: https://rust-lang.zulipchat.com/#narrow/stream/t-infra.2Fbootstrap [rust-issue-tracker]: https://github.com/rust-lang/rust/issues +## Testing + +To run bootstrap tests, execute `x test bootstrap`. If you want to bless snapshot tests, then install `cargo-insta` (`cargo install cargo-insta`) and then run `cargo insta review --manifest-path src/bootstrap/Cargo.toml`. + ## Changelog Because we do not release bootstrap with versions, we also do not maintain CHANGELOG files. To diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index ebb926d81ce..cf69ab0fcdf 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3059,6 +3059,8 @@ impl Step for Bootstrap { cargo .rustflag("-Cdebuginfo=2") .env("CARGO_TARGET_DIR", builder.out.join("bootstrap")) + // Needed for insta to correctly write pending snapshots to the right directories. + .env("INSTA_WORKSPACE_ROOT", &builder.src) .env("RUSTC_BOOTSTRAP", "1"); // bootstrap tests are racy on directory creation so just run them one at a time. |
