Skip to content

Commit e5e36fd

Browse files
committed
Auto merge of #14175 - heisen-li:edition_err, r=weihanglo
test:migrate `edition/error` to snapbox ### What does this PR try to resolve? The last two documents: ``` tests/testsuite/edition.rs tests/testsuite/error.rs ``` part of #14039
2 parents 6bd64c4 + 7254452 commit e5e36fd

File tree

2 files changed

+30
-41
lines changed

2 files changed

+30
-41
lines changed

tests/testsuite/edition.rs

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Tests for edition setting.
22
3-
#![allow(deprecated)]
4-
53
use cargo::core::Edition;
6-
use cargo_test_support::{basic_lib_manifest, project};
4+
use cargo_test_support::{basic_lib_manifest, project, str};
75

86
#[cargo_test]
97
fn edition_works_for_build_script() {
@@ -66,21 +64,17 @@ fn edition_unstable_gated() {
6664

6765
p.cargo("check")
6866
.with_status(101)
69-
.with_stderr(&format!(
67+
.with_stderr_data(format!(
7068
"\
71-
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
69+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
7270
7371
Caused by:
7472
feature `edition{next}` is required
7573
76-
The package requires the Cargo feature called `edition{next}`, \
77-
but that feature is not stabilized in this version of Cargo (1.[..]).
74+
The package requires the Cargo feature called `edition{next}`, but that feature is not stabilized in this version of Cargo (1.[..]).
7875
Consider trying a newer version of Cargo (this may require the nightly release).
79-
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} \
80-
for more information about the status of this feature.
81-
",
82-
next = next
83-
))
76+
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-{next} for more information about the status of this feature.
77+
"))
8478
.run();
8579
}
8680

@@ -116,12 +110,11 @@ fn edition_unstable() {
116110

117111
p.cargo("check")
118112
.masquerade_as_nightly_cargo(&["always_nightly"])
119-
.with_stderr(
120-
"\
121-
[CHECKING] foo [..]
122-
[FINISHED] [..]
123-
",
124-
)
113+
.with_stderr_data(str![[r#"
114+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
115+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
116+
117+
"#]])
125118
.run();
126119
}
127120

@@ -140,14 +133,13 @@ fn unset_edition_with_unset_rust_version() {
140133
.build();
141134

142135
p.cargo("check -v")
143-
.with_stderr(
144-
"\
136+
.with_stderr_data(str![[r#"
145137
[WARNING] no edition set: defaulting to the 2015 edition while the latest is 2021
146-
[CHECKING] foo [..]
138+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
147139
[RUNNING] `rustc [..] --edition=2015 [..]`
148-
[FINISHED] [..]
149-
",
150-
)
140+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
141+
142+
"#]])
151143
.run();
152144
}
153145

@@ -167,13 +159,12 @@ fn unset_edition_works_with_no_newer_compatible_edition() {
167159
.build();
168160

169161
p.cargo("check -v")
170-
.with_stderr(
171-
"\
172-
[CHECKING] foo [..]
162+
.with_stderr_data(str![[r#"
163+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
173164
[RUNNING] `rustc [..] --edition=2015 [..]`
174-
[FINISHED] [..]
175-
",
176-
)
165+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
166+
167+
"#]])
177168
.run();
178169
}
179170

@@ -193,13 +184,12 @@ fn unset_edition_works_on_old_msrv() {
193184
.build();
194185

195186
p.cargo("check -v")
196-
.with_stderr(
197-
"\
187+
.with_stderr_data(str![[r#"
198188
[WARNING] no edition set: defaulting to the 2015 edition while 2018 is compatible with `rust-version`
199-
[CHECKING] foo [..]
189+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
200190
[RUNNING] `rustc [..] --edition=2015 [..]`
201-
[FINISHED] [..]
202-
",
203-
)
191+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
192+
193+
"#]])
204194
.run();
205195
}

tests/testsuite/error.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
//! General error tests that don't belong anywhere else.
22
3-
#![allow(deprecated)]
4-
53
use cargo_test_support::cargo_process;
64

75
#[cargo_test]
86
fn internal_error() {
97
cargo_process("init")
108
.env("__CARGO_TEST_INTERNAL_ERROR", "1")
119
.with_status(101)
12-
.with_stderr(
10+
.with_stderr_data(format!(
1311
"\
1412
[ERROR] internal error test
1513
[NOTE] this is an unexpected cargo internal error
1614
[NOTE] we would appreciate a bug report: https://github.com/rust-lang/cargo/issues/
17-
[NOTE] cargo [..]
15+
[NOTE] cargo {}
1816
",
19-
)
17+
cargo::version()
18+
))
2019
.run();
2120
}

0 commit comments

Comments
 (0)