Skip to content

Commit 5b50e0b

Browse files
committed
Add support for snapshot tests with insta
1 parent fd50e10 commit 5b50e0b

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

src/bootstrap/Cargo.lock

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = [
4444
"fd-lock",
4545
"home",
4646
"ignore",
47+
"insta",
4748
"junction",
4849
"libc",
4950
"object",
@@ -158,6 +159,18 @@ dependencies = [
158159
"cc",
159160
]
160161

162+
[[package]]
163+
name = "console"
164+
version = "0.15.11"
165+
source = "registry+https://github.com/rust-lang/crates.io-index"
166+
checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8"
167+
dependencies = [
168+
"encode_unicode",
169+
"libc",
170+
"once_cell",
171+
"windows-sys 0.59.0",
172+
]
173+
161174
[[package]]
162175
name = "cpufeatures"
163176
version = "0.2.15"
@@ -218,6 +231,12 @@ dependencies = [
218231
"crypto-common",
219232
]
220233

234+
[[package]]
235+
name = "encode_unicode"
236+
version = "1.0.0"
237+
source = "registry+https://github.com/rust-lang/crates.io-index"
238+
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
239+
221240
[[package]]
222241
name = "errno"
223242
version = "0.3.11"
@@ -323,6 +342,17 @@ dependencies = [
323342
"winapi-util",
324343
]
325344

345+
[[package]]
346+
name = "insta"
347+
version = "1.43.1"
348+
source = "registry+https://github.com/rust-lang/crates.io-index"
349+
checksum = "154934ea70c58054b556dd430b99a98c2a7ff5309ac9891597e339b5c28f4371"
350+
dependencies = [
351+
"console",
352+
"once_cell",
353+
"similar",
354+
]
355+
326356
[[package]]
327357
name = "itoa"
328358
version = "1.0.11"
@@ -675,6 +705,12 @@ version = "1.3.0"
675705
source = "registry+https://github.com/rust-lang/crates.io-index"
676706
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
677707

708+
[[package]]
709+
name = "similar"
710+
version = "2.7.0"
711+
source = "registry+https://github.com/rust-lang/crates.io-index"
712+
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
713+
678714
[[package]]
679715
name = "smallvec"
680716
version = "1.13.2"

src/bootstrap/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ features = [
8484
[dev-dependencies]
8585
pretty_assertions = "1.4"
8686
tempfile = "3.15.0"
87+
insta = "1.43"
8788

8889
# We care a lot about bootstrap's compile times, so don't include debuginfo for
8990
# dependencies, only bootstrap itself.

src/bootstrap/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ please file issues on the [Rust issue tracker][rust-issue-tracker].
200200
[rust-bootstrap-zulip]: https://rust-lang.zulipchat.com/#narrow/stream/t-infra.2Fbootstrap
201201
[rust-issue-tracker]: https://github.com/rust-lang/rust/issues
202202

203+
## Testing
204+
205+
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`.
206+
203207
## Changelog
204208

205209
Because we do not release bootstrap with versions, we also do not maintain CHANGELOG files. To

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,6 +3059,8 @@ impl Step for Bootstrap {
30593059
cargo
30603060
.rustflag("-Cdebuginfo=2")
30613061
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))
3062+
// Needed for insta to correctly write pending snapshots to the right directories.
3063+
.env("INSTA_WORKSPACE_ROOT", &builder.src)
30623064
.env("RUSTC_BOOTSTRAP", "1");
30633065

30643066
// bootstrap tests are racy on directory creation so just run them one at a time.

0 commit comments

Comments
 (0)