Skip to content

Commit efbcbb0

Browse files
committed
test: migrate testsuite message_format to snapbox
This reverts commit 2fbba53.
1 parent a67f4ed commit efbcbb0

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

tests/testsuite/message_format.rs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Tests for --message-format flag.
22
3-
#![allow(deprecated)]
4-
5-
use cargo_test_support::{basic_lib_manifest, basic_manifest, project};
3+
use cargo_test_support::{basic_lib_manifest, basic_manifest, project, str};
64

75
#[cargo_test]
86
fn cannot_specify_two() {
@@ -13,12 +11,14 @@ fn cannot_specify_two() {
1311

1412
let formats = ["human", "json", "short"];
1513

16-
let two_kinds = "error: cannot specify two kinds of `message-format` arguments\n";
1714
for a in formats.iter() {
1815
for b in formats.iter() {
1916
p.cargo(&format!("build --message-format {},{}", a, b))
2017
.with_status(101)
21-
.with_stderr(two_kinds)
18+
.with_stderr_data(str![[r#"
19+
[ERROR] cannot specify two kinds of `message-format` arguments
20+
21+
"#]])
2222
.run();
2323
}
2424
}
@@ -45,6 +45,7 @@ fn double_json_works() {
4545
.run();
4646
}
4747

48+
#[allow(deprecated)]
4849
#[cargo_test]
4950
fn cargo_renders() {
5051
let p = project()
@@ -89,17 +90,17 @@ fn cargo_renders_short() {
8990

9091
p.cargo("check --message-format json-render-diagnostics,json-diagnostic-short")
9192
.with_status(101)
92-
.with_stderr_contains(
93-
"\
94-
[CHECKING] foo [..]
95-
error[..]`main`[..]
96-
",
97-
)
98-
.with_stderr_does_not_contain("note:")
93+
.with_stderr_data(str![[r#"
94+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
95+
error[E0601]: `main` function not found in crate `foo`
96+
[ERROR] could not compile `foo` (bin "foo") due to 1 previous error
97+
98+
"#]])
9999
.run();
100100
}
101101

102102
#[cargo_test]
103+
#[allow(deprecated)]
103104
fn cargo_renders_ansi() {
104105
let p = project()
105106
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
@@ -129,7 +130,24 @@ fn cargo_renders_doctests() {
129130

130131
p.cargo("test --doc --message-format short")
131132
.with_status(101)
132-
.with_stdout_contains("src/lib.rs:2:1: error[E0425]:[..]")
133-
.with_stdout_contains("[..]src/lib.rs - bar (line 1)[..]")
133+
.with_stdout_data(str![[r#"
134+
135+
running 1 test
136+
test src/lib.rs - bar (line 1) ... FAILED
137+
138+
failures:
139+
140+
---- src/lib.rs - bar (line 1) stdout ----
141+
src/lib.rs:2:1: error[E0425]: cannot find function `bar` in this scope
142+
[ERROR] aborting due to 1 previous error
143+
Couldn't compile the test.
144+
145+
failures:
146+
src/lib.rs - bar (line 1)
147+
148+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
149+
150+
151+
"#]])
134152
.run();
135153
}

0 commit comments

Comments
 (0)