1
- #! [ allow ( deprecated ) ]
1
+ //! Tests for `cargo-features = ["different-binary-name"]`.
2
2
3
- use cargo_test_support:: install:: {
4
- assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
5
- } ;
3
+ use cargo_test_support:: install:: assert_has_installed_exe;
4
+ use cargo_test_support:: install:: assert_has_not_installed_exe;
5
+ use cargo_test_support:: install:: cargo_home;
6
+ use cargo_test_support:: prelude:: * ;
6
7
use cargo_test_support:: project;
8
+ use cargo_test_support:: str;
7
9
8
10
#[ cargo_test]
9
11
fn gated ( ) {
@@ -29,7 +31,17 @@ fn gated() {
29
31
p. cargo ( "build" )
30
32
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
31
33
. with_status ( 101 )
32
- . with_stderr_contains ( "[..]feature `different-binary-name` is required" )
34
+ . with_stderr_data ( str![ [ r#"
35
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
36
+
37
+ Caused by:
38
+ feature `different-binary-name` is required
39
+
40
+ The package requires the Cargo feature called `different-binary-name`, but that feature is not stabilized in this version of Cargo ([..]).
41
+ Consider adding `cargo-features = ["different-binary-name"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature.
42
+ See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#different-binary-name for more information about the status of this feature.
43
+
44
+ "# ] ] )
33
45
. run ( ) ;
34
46
}
35
47
@@ -97,12 +109,11 @@ fn binary_name1() {
97
109
// Run cargo second time, to verify fingerprint.
98
110
p. cargo ( "build -p foo -v" )
99
111
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
100
- . with_stderr (
101
- "\
102
- [FRESH] foo [..]
103
- [FINISHED] [..]
104
- " ,
105
- )
112
+ . with_stderr_data ( str![ [ r#"
113
+ [FRESH] foo v0.0.1 ([ROOT]/foo)
114
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
115
+
116
+ "# ] ] )
106
117
. run ( ) ;
107
118
108
119
// Run cargo clean.
@@ -180,19 +191,30 @@ fn binary_name2() {
180
191
// Check if `cargo test` works
181
192
p. cargo ( "test" )
182
193
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
183
- . with_stderr (
184
- "\
185
- [COMPILING] foo v0.0.1 ([CWD])
186
- [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]
187
- [RUNNING] [..] (target/debug/deps/foo-[..][EXE])" ,
188
- )
189
- . with_stdout_contains ( "test tests::check_crabs ... ok" )
194
+ . with_stderr_data ( str![ [ r#"
195
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
196
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
197
+ [RUNNING] unittests src/main.rs (target/debug/deps/foo-[..][EXE])
198
+
199
+ "# ] ] )
200
+ . with_stdout_data ( str![ [ r#"
201
+
202
+ running 1 test
203
+ test tests::check_crabs ... ok
204
+
205
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
206
+
207
+
208
+ "# ] ] )
190
209
. run ( ) ;
191
210
192
211
// Check if `cargo run` is able to execute the binary
193
212
p. cargo ( "run" )
194
213
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
195
- . with_stdout ( "Hello, crabs!" )
214
+ . with_stdout_data ( str![ [ r#"
215
+ Hello, crabs!
216
+
217
+ "# ] ] )
196
218
. run ( ) ;
197
219
198
220
p. cargo ( "install" )
@@ -202,7 +224,10 @@ fn binary_name2() {
202
224
assert_has_installed_exe ( cargo_home ( ) , "007bar" ) ;
203
225
204
226
p. cargo ( "uninstall" )
205
- . with_stderr ( "[REMOVING] [ROOT]/home/.cargo/bin/007bar[EXE]" )
227
+ . with_stderr_data ( str![ [ r#"
228
+ [REMOVING] [ROOT]/home/.cargo/bin/007bar[EXE]
229
+
230
+ "# ] ] )
206
231
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
207
232
. run ( ) ;
208
233
@@ -253,7 +278,10 @@ fn check_env_vars() {
253
278
. run ( ) ;
254
279
p. cargo ( "run" )
255
280
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
256
- . with_stdout ( "007bar" )
281
+ . with_stdout_data ( str![ [ r#"
282
+ 007bar
283
+
284
+ "# ] ] )
257
285
. run ( ) ;
258
286
p. cargo ( "test" )
259
287
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
@@ -284,25 +312,13 @@ fn check_msg_format_json() {
284
312
. file ( "src/main.rs" , "fn main() { assert!(true) }" )
285
313
. build ( ) ;
286
314
287
- let output = r#"
288
- {
289
- "reason": "compiler-artifact",
290
- "package_id": "path+file:///[..]/foo#0.0.1",
291
- "manifest_path": "[CWD]/Cargo.toml",
292
- "target": "{...}",
293
- "profile": "{...}",
294
- "features": [],
295
- "filenames": "{...}",
296
- "executable": "[ROOT]/foo/target/debug/007bar[EXE]",
297
- "fresh": false
298
- }
299
-
300
- {"reason":"build-finished", "success":true}
301
- "# ;
302
-
303
315
// Run cargo build.
304
316
p. cargo ( "build --message-format=json" )
305
317
. masquerade_as_nightly_cargo ( & [ "different-binary-name" ] )
306
- . with_json ( output)
318
+ . with_stdout_data ( str![ [ r#"
319
+ {"executable":"[ROOT]/foo/target/debug/007bar","features":[],"filenames":["[ROOT]/foo/target/debug/007bar[EXE]"],"fresh":false,"manifest_path":"[ROOT]/foo/Cargo.toml","package_id":"path+[ROOTURL]/foo#0.0.1","profile":{"debug_assertions":true,"debuginfo":2,"opt_level":"0","overflow_checks":true,"test":false},"reason":"compiler-artifact","target":{"crate_types":["bin"],"doc":true,"doctest":false,"edition":"2015","kind":["bin"],"name":"foo","src_path":"[ROOT]/foo/src/main.rs","test":true}}
320
+ {"reason":"build-finished","success":true}
321
+
322
+ "# ] ] . json_lines ( ) )
307
323
. run ( ) ;
308
324
}
0 commit comments