1
1
//! Tests for configuration values that point to programs.
2
2
3
- #![ allow( deprecated) ]
4
-
5
- use cargo_test_support:: { basic_lib_manifest, project, rustc_host, rustc_host_env} ;
3
+ use cargo_test_support:: { basic_lib_manifest, project, rustc_host, rustc_host_env, str} ;
6
4
7
5
#[ cargo_test]
8
6
fn pathless_tools ( ) {
@@ -24,13 +22,12 @@ fn pathless_tools() {
24
22
. build ( ) ;
25
23
26
24
foo. cargo ( "build --verbose" )
27
- . with_stderr (
28
- "\
29
- [COMPILING] foo v0.5.0 ([CWD])
30
- [RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
31
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
32
- " ,
33
- )
25
+ . with_stderr_data ( str![ [ r#"
26
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
27
+ [RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
28
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
29
+
30
+ "# ] ] )
34
31
. run ( ) ;
35
32
}
36
33
@@ -50,13 +47,12 @@ fn custom_linker_cfg() {
50
47
. build ( ) ;
51
48
52
49
foo. cargo ( "build --verbose" )
53
- . with_stderr (
54
- "\
55
- [COMPILING] foo v0.5.0 ([CWD])
56
- [RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
57
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
58
- " ,
59
- )
50
+ . with_stderr_data ( str![ [ r#"
51
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
52
+ [RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
53
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
54
+
55
+ "# ] ] )
60
56
. run ( ) ;
61
57
}
62
58
@@ -83,13 +79,12 @@ fn custom_linker_cfg_precedence() {
83
79
. build ( ) ;
84
80
85
81
foo. cargo ( "build --verbose" )
86
- . with_stderr (
87
- "\
88
- [COMPILING] foo v0.5.0 ([CWD])
89
- [RUNNING] `rustc [..] -C linker=nonexistent-linker [..]`
90
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
91
- " ,
92
- )
82
+ . with_stderr_data ( str![ [ r#"
83
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
84
+ [RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
85
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
86
+
87
+ "# ] ] )
93
88
. run ( ) ;
94
89
}
95
90
@@ -111,13 +106,12 @@ fn custom_linker_cfg_collision() {
111
106
112
107
foo. cargo ( "build --verbose" )
113
108
. with_status ( 101 )
114
- . with_stderr ( & format ! (
115
- "\
109
+ . with_stderr_data ( str![ [ r#"
116
110
[ERROR] several matching instances of `target.'cfg(..)'.linker` in configurations
117
- first match `cfg(not(target_arch = \ " avr\ " ))` located in [.. ]/foo/.cargo/config.toml
118
- second match `cfg(not(target_os = \ " none\ " ))` located in [.. ]/foo/.cargo/config.toml
119
- " ,
120
- ) )
111
+ first match `cfg(not(target_arch = "avr"))` located in [ROOT ]/foo/.cargo/config.toml
112
+ second match `cfg(not(target_os = "none"))` located in [ROOT ]/foo/.cargo/config.toml
113
+
114
+ "# ] ] )
121
115
. run ( ) ;
122
116
}
123
117
@@ -149,13 +143,12 @@ fn absolute_tools() {
149
143
. build ( ) ;
150
144
151
145
foo. cargo ( "build --verbose" )
152
- . with_stderr (
153
- "\
154
- [COMPILING] foo v0.5.0 ([CWD])
155
- [RUNNING] `rustc [..] -C linker=[..]bogus/nonexistent-linker [..]`
156
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
157
- " ,
158
- )
146
+ . with_stderr_data ( str![ [ r#"
147
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
148
+ [RUNNING] `rustc [..]-C linker=[..]/bogus/nonexistent-linker [..]`
149
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
150
+
151
+ "# ] ] )
159
152
. run ( ) ;
160
153
}
161
154
@@ -189,18 +182,14 @@ fn relative_tools() {
189
182
)
190
183
. build ( ) ;
191
184
192
- let prefix = p. root ( ) . into_os_string ( ) . into_string ( ) . unwrap ( ) ;
193
-
194
185
p. cargo ( "build --verbose" )
195
186
. cwd ( "bar" )
196
- . with_stderr ( & format ! (
197
- "\
198
- [COMPILING] bar v0.5.0 ([CWD])
199
- [RUNNING] `rustc [..] -C linker={prefix}/./tools/nonexistent-linker [..]`
200
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
201
- " ,
202
- prefix = prefix,
203
- ) )
187
+ . with_stderr_data ( str![ [ r#"
188
+ [COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
189
+ [RUNNING] `rustc [..]-C linker=[ROOT]/foo/./tools/nonexistent-linker [..]`
190
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
191
+
192
+ "# ] ] )
204
193
. run ( ) ;
205
194
}
206
195
@@ -226,38 +215,35 @@ fn custom_runner() {
226
215
227
216
p. cargo ( "run -- --param" )
228
217
. with_status ( 101 )
229
- . with_stderr_contains (
230
- "\
231
- [COMPILING] foo v0.0.1 ([CWD])
232
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
218
+ . with_stderr_data ( str![ [ r#"
219
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
220
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
233
221
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
234
- " ,
235
- )
222
+ ...
223
+ "# ] ] )
236
224
. run ( ) ;
237
225
238
226
p. cargo ( "test --test test --verbose -- --param" )
239
227
. with_status ( 101 )
240
- . with_stderr_contains (
241
- "\
242
- [COMPILING] foo v0.0.1 ([CWD])
228
+ . with_stderr_data ( str![ [ r#"
229
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
243
230
[RUNNING] `rustc [..]`
244
- [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..]
245
- [RUNNING] `nonexistent-runner -r [..]/ target/debug/deps/test-[.. ][EXE] --param`
246
- " ,
247
- )
231
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
232
+ [RUNNING] `nonexistent-runner -r [ROOT]/foo/ target/debug/deps/test-[HASH ][EXE] --param`
233
+ ...
234
+ "# ] ] )
248
235
. run ( ) ;
249
236
250
237
p. cargo ( "bench --bench bench --verbose -- --param" )
251
238
. with_status ( 101 )
252
- . with_stderr_contains (
253
- "\
254
- [COMPILING] foo v0.0.1 ([CWD])
239
+ . with_stderr_data ( str![ [ r#"
240
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
255
241
[RUNNING] `rustc [..]`
256
242
[RUNNING] `rustc [..]`
257
- [FINISHED] `bench` profile [optimized] target(s) in [..]
258
- [RUNNING] `nonexistent-runner -r [..]/ target/release/deps/bench-[.. ][EXE] --param --bench`
259
- " ,
260
- )
243
+ [FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s
244
+ [RUNNING] `nonexistent-runner -r [ROOT]/foo/ target/release/deps/bench-[HASH ][EXE] --param --bench`
245
+ ...
246
+ "# ] ] )
261
247
. run ( ) ;
262
248
}
263
249
@@ -277,13 +263,12 @@ fn custom_runner_cfg() {
277
263
278
264
p. cargo ( "run -- --param" )
279
265
. with_status ( 101 )
280
- . with_stderr_contains (
281
- "\
282
- [COMPILING] foo v0.0.1 ([CWD])
283
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
266
+ . with_stderr_data ( str![ [ r#"
267
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
268
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
284
269
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
285
- " ,
286
- )
270
+ ...
271
+ "# ] ] )
287
272
. run ( ) ;
288
273
}
289
274
@@ -311,13 +296,12 @@ fn custom_runner_cfg_precedence() {
311
296
312
297
p. cargo ( "run -- --param" )
313
298
. with_status ( 101 )
314
- . with_stderr_contains (
315
- "\
316
- [COMPILING] foo v0.0.1 ([CWD])
317
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
299
+ . with_stderr_data ( str![ [ r#"
300
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
301
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
318
302
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
319
- " ,
320
- )
303
+ ...
304
+ "# ] ] )
321
305
. run ( ) ;
322
306
}
323
307
@@ -339,13 +323,12 @@ fn custom_runner_cfg_collision() {
339
323
340
324
p. cargo ( "run -- --param" )
341
325
. with_status ( 101 )
342
- . with_stderr (
343
- "\
326
+ . with_stderr_data ( str![ [ r#"
344
327
[ERROR] several matching instances of `target.'cfg(..)'.runner` in configurations
345
- first match `cfg(not(target_arch = \ " avr\ " ))` located in [.. ]/foo/.cargo/config.toml
346
- second match `cfg(not(target_os = \ " none\ " ))` located in [.. ]/foo/.cargo/config.toml
347
- " ,
348
- )
328
+ first match `cfg(not(target_arch = "avr"))` located in [ROOT ]/foo/.cargo/config.toml
329
+ second match `cfg(not(target_os = "none"))` located in [ROOT ]/foo/.cargo/config.toml
330
+
331
+ "# ] ] )
349
332
. run ( ) ;
350
333
}
351
334
@@ -361,17 +344,16 @@ fn custom_runner_env() {
361
344
// FIXME: Update "Caused by" error message once rust/pull/87704 is merged.
362
345
// On Windows, changing to a custom executable resolver has changed the
363
346
// error messages.
364
- . with_stderr ( & format ! (
365
- "\
366
- [COMPILING] foo [..]
367
- [FINISHED] `dev` profile [..]
347
+ . with_stderr_data ( str![ [ r#"
348
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
349
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
368
350
[RUNNING] `nonexistent-runner --foo target/debug/foo[EXE]`
369
351
[ERROR] could not execute process `nonexistent-runner --foo target/debug/foo[EXE]` (never executed)
370
352
371
353
Caused by:
372
- [.. ]
373
- "
374
- ) )
354
+ [NOT_FOUND ]
355
+
356
+ "# ] ] )
375
357
. run ( ) ;
376
358
}
377
359
@@ -397,7 +379,11 @@ fn custom_runner_env_overrides_config() {
397
379
p. cargo ( "run" )
398
380
. env ( & key, "should-run --foo" )
399
381
. with_status ( 101 )
400
- . with_stderr_contains ( "[RUNNING] `should-run --foo target/debug/foo[EXE]`" )
382
+ . with_stderr_data ( str![ [ r#"
383
+ ...
384
+ [RUNNING] `should-run --foo target/debug/foo[EXE]`
385
+ ...
386
+ "# ] ] )
401
387
. run ( ) ;
402
388
}
403
389
@@ -412,7 +398,12 @@ fn custom_runner_env_true() {
412
398
413
399
p. cargo ( "run" )
414
400
. env ( & key, "true" )
415
- . with_stderr_contains ( "[RUNNING] `true target/debug/foo[EXE]`" )
401
+ . with_stderr_data ( str![ [ r#"
402
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
403
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
404
+ [RUNNING] `true target/debug/foo[EXE]`
405
+
406
+ "# ] ] )
416
407
. run ( ) ;
417
408
}
418
409
@@ -425,7 +416,11 @@ fn custom_linker_env() {
425
416
p. cargo ( "build -v" )
426
417
. env ( & key, "nonexistent-linker" )
427
418
. with_status ( 101 )
428
- . with_stderr_contains ( "[RUNNING] `rustc [..]-C linker=nonexistent-linker [..]" )
419
+ . with_stderr_data ( str![ [ r#"
420
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
421
+ [RUNNING] `rustc [..]-C linker=nonexistent-linker [..]`
422
+ ...
423
+ "# ] ] )
429
424
. run ( ) ;
430
425
}
431
426
@@ -442,11 +437,13 @@ fn target_in_environment_contains_lower_case() {
442
437
p. cargo ( "build -v --target" )
443
438
. arg ( target)
444
439
. env ( & env_key, "nonexistent-linker" )
445
- . with_stderr_contains ( format ! (
446
- "warning: environment variables are expected to use uppercase \
447
- letters and underscores, the variable `{}` will be ignored and \
448
- have no effect",
449
- env_key
440
+ . with_stderr_data ( format ! ( "\
441
+ [WARNING] environment variables are expected to use uppercase letters and underscores, the variable `{env_key}` will be ignored and have no effect
442
+ [WARNING] environment variables are expected to use uppercase letters and underscores, the variable `{env_key}` will be ignored and have no effect
443
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
444
+ [RUNNING] `rustc --crate-name foo --edition=2015 src/main.rs [..]`
445
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
446
+ "
450
447
) )
451
448
. run ( ) ;
452
449
}
@@ -476,15 +473,14 @@ fn cfg_ignored_fields() {
476
473
. build ( ) ;
477
474
478
475
p. cargo ( "check" )
479
- . with_stderr (
480
- "\
476
+ . with_stderr_data ( str![ [ r#"
481
477
[WARNING] unused key `somelib` in [target] config table `cfg(not(bar))`
482
- [WARNING] unused key `ar` in [target] config table `cfg(not(target_os = \ " none\ " ))`
483
- [WARNING] unused key `foo` in [target] config table `cfg(not(target_os = \ " none\ " ))`
484
- [WARNING] unused key `invalid` in [target] config table `cfg(not(target_os = \ " none\ " ))`
485
- [CHECKING] foo v0.0.1 ([..] )
486
- [FINISHED] [..]
487
- " ,
488
- )
478
+ [WARNING] unused key `ar` in [target] config table `cfg(not(target_os = "none"))`
479
+ [WARNING] unused key `foo` in [target] config table `cfg(not(target_os = "none"))`
480
+ [WARNING] unused key `invalid` in [target] config table `cfg(not(target_os = "none"))`
481
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
482
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
483
+
484
+ "# ] ] )
489
485
. run ( ) ;
490
486
}
0 commit comments