1
1
//! Tests for --message-format flag.
2
2
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} ;
6
4
7
5
#[ cargo_test]
8
6
fn cannot_specify_two ( ) {
@@ -13,12 +11,14 @@ fn cannot_specify_two() {
13
11
14
12
let formats = [ "human" , "json" , "short" ] ;
15
13
16
- let two_kinds = "error: cannot specify two kinds of `message-format` arguments\n " ;
17
14
for a in formats. iter ( ) {
18
15
for b in formats. iter ( ) {
19
16
p. cargo ( & format ! ( "build --message-format {},{}" , a, b) )
20
17
. 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
+ "# ] ] )
22
22
. run ( ) ;
23
23
}
24
24
}
@@ -45,6 +45,7 @@ fn double_json_works() {
45
45
. run ( ) ;
46
46
}
47
47
48
+ #[ allow( deprecated) ]
48
49
#[ cargo_test]
49
50
fn cargo_renders ( ) {
50
51
let p = project ( )
@@ -89,17 +90,17 @@ fn cargo_renders_short() {
89
90
90
91
p. cargo ( "check --message-format json-render-diagnostics,json-diagnostic-short" )
91
92
. 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
+ "# ] ] )
99
99
. run ( ) ;
100
100
}
101
101
102
102
#[ cargo_test]
103
+ #[ allow( deprecated) ]
103
104
fn cargo_renders_ansi ( ) {
104
105
let p = project ( )
105
106
. file ( "Cargo.toml" , & basic_manifest ( "foo" , "0.1.0" ) )
@@ -129,7 +130,24 @@ fn cargo_renders_doctests() {
129
130
130
131
p. cargo ( "test --doc --message-format short" )
131
132
. 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
+ "# ] ] )
134
152
. run ( ) ;
135
153
}
0 commit comments