@@ -18,12 +18,22 @@ fn single_bin() {
18
18
fn main() { println!("hello"); }
19
19
"# ) ;
20
20
21
- assert_that ( p. cargo_process ( "run" ) . env ( "CARGO_PRINT_RUN" , "1" ) ,
21
+ assert_that ( p. cargo_process ( "run" ) . env ( "CARGO_PRINT_RUN" , "1" ) . arg ( "--message-format=json" ) ,
22
22
execs ( ) . with_status ( 0 )
23
23
. with_stderr ( & "\
24
24
[COMPILING] foo v0.0.1 ([..])
25
25
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" )
26
26
. with_json ( r#"
27
+ {
28
+ "features": [],
29
+ "filenames": ["[..]target[/]debug[/]foo"],
30
+ "fresh": false,
31
+ "package_id": "foo 0.0.1 ([..])",
32
+ "profile": "{...}",
33
+ "reason": "compiler-artifact",
34
+ "target": "{...}"
35
+ }
36
+
27
37
{
28
38
"reason": "run-profile",
29
39
"program": "[..][/]foo[/]target[/]debug[/]foo",
@@ -87,9 +97,26 @@ fn several_tests() {
87
97
"CARGO_MANIFEST_DIR": "[..]",
88
98
"CARGO": "[..]"
89
99
}"# ;
90
- assert_that ( p. cargo_process ( "test" ) . env ( "CARGO_PRINT_RUN" , "1" ) ,
100
+ let artifact = r#"{
101
+ "features": [],
102
+ "filenames": "{...}",
103
+ "fresh": false,
104
+ "package_id": "foo 0.0.1 ([..])",
105
+ "profile": "{...}",
106
+ "reason": "compiler-artifact",
107
+ "target": "{...}"
108
+ }"# ;
109
+ assert_that ( p. cargo_process ( "test" ) . env ( "CARGO_PRINT_RUN" , "1" ) . arg ( "--message-format=json" ) ,
91
110
execs ( ) . with_status ( 0 )
92
111
. with_json ( & format ! ( r#"
112
+ {artifact}
113
+
114
+ {artifact}
115
+
116
+ {artifact}
117
+
118
+ {artifact}
119
+
93
120
{{
94
121
"reason": "run-profile",
95
122
"program": "[..]bar-[..]",
@@ -113,6 +140,29 @@ fn several_tests() {
113
140
"cwd": "[..]",
114
141
"args": []
115
142
}}
116
- "# , env=env) ) ) ;
143
+ "# , env=env, artifact=artifact ) ) ) ;
117
144
}
118
145
146
+ #[ test]
147
+ fn print_run_needs_json ( ) {
148
+ let p = project ( "foo" )
149
+ . file ( "Cargo.toml" , r#"
150
+ [project]
151
+ name = "foo"
152
+ version = "0.0.1"
153
+ authors = []
154
+ "# )
155
+ . file ( "src/main.rs" , r#"
156
+ fn main() { println!("hello"); }
157
+ "# ) ;
158
+ p. build ( ) ;
159
+
160
+ assert_that ( p. cargo ( "run" ) . env ( "CARGO_PRINT_RUN" , "1" ) ,
161
+ execs ( ) . with_status ( 101 ) . with_stderr_contains ( "\
162
+ [ERROR] CARGO_PRINT_RUN requires --message-format=json") ) ;
163
+
164
+ assert_that ( p. cargo ( "test" ) . env ( "CARGO_PRINT_RUN" , "1" ) ,
165
+ execs ( ) . with_status ( 101 ) . with_stderr_contains ( "\
166
+ [ERROR] CARGO_PRINT_RUN requires --message-format=json") ) ;
167
+
168
+ }
0 commit comments