1
1
//! Tests for profiles defined in config files.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: paths:: CargoPathExt ;
4
+ use cargo_test_support:: prelude:: * ;
6
5
use cargo_test_support:: registry:: Package ;
7
- use cargo_test_support:: { basic_lib_manifest, paths, project} ;
6
+ use cargo_test_support:: { basic_lib_manifest, paths, project, str } ;
8
7
use cargo_util_schemas:: manifest:: TomlDebugInfo ;
9
8
10
9
// TODO: this should be remove once -Zprofile-rustflags is stabilized
@@ -33,18 +32,23 @@ fn rustflags_works_with_zflag() {
33
32
p. cargo ( "check -v" )
34
33
. masquerade_as_nightly_cargo ( & [ "profile-rustflags" ] )
35
34
. with_status ( 101 )
36
- . with_stderr_contains ( "[..]feature `profile-rustflags` is required[..]" )
35
+ . with_stderr_data ( str![ [ r#"
36
+ [ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`)
37
+
38
+ Caused by:
39
+ feature `profile-rustflags` is required
40
+ ...
41
+ "# ] ] )
37
42
. run ( ) ;
38
43
39
44
p. cargo ( "check -v -Zprofile-rustflags" )
40
45
. masquerade_as_nightly_cargo ( & [ "profile-rustflags" ] )
41
- . with_stderr (
42
- "\
43
- [CHECKING] foo [..]
44
- [RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]
45
- [FINISHED] [..]
46
- " ,
47
- )
46
+ . with_stderr_data ( str![ [ r#"
47
+ [CHECKING] foo v0.0.1 ([ROOT]/foo)
48
+ [RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]`
49
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
50
+
51
+ "# ] ] )
48
52
. run ( ) ;
49
53
50
54
p. change_file (
@@ -60,12 +64,11 @@ fn rustflags_works_with_zflag() {
60
64
61
65
p. cargo ( "check -v" )
62
66
. masquerade_as_nightly_cargo ( & [ "profile-rustflags" ] )
63
- . with_stderr (
64
- "\
65
- [FRESH] foo [..]
66
- [FINISHED] [..]
67
- " ,
68
- )
67
+ . with_stderr_data ( str![ [ r#"
68
+ [FRESH] foo v0.0.1 ([ROOT]/foo)
69
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
70
+
71
+ "# ] ] )
69
72
. run ( ) ;
70
73
}
71
74
@@ -95,17 +98,14 @@ fn profile_config_validate_warnings() {
95
98
)
96
99
. build ( ) ;
97
100
98
- p. cargo ( "build" )
99
- . with_stderr_unordered (
100
- "\
101
- [WARNING] unused config key `profile.dev.bad-key` in `[..].cargo/config.toml`
102
- [WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[..].cargo/config.toml`
103
- [WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[..].cargo/config.toml`
104
- [COMPILING] foo [..]
105
- [FINISHED] [..]
106
- " ,
107
- )
108
- . run ( ) ;
101
+ p. cargo ( "build" ) . with_stderr_data ( str![ [ r#"
102
+ [WARNING] unused config key `profile.dev.bad-key` in `[ROOT]/foo/.cargo/config.toml`
103
+ [WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[ROOT]/foo/.cargo/config.toml`
104
+ [WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[ROOT]/foo/.cargo/config.toml`
105
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
106
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
107
+
108
+ "# ] ] . unordered ( ) ) . run ( ) ;
109
109
}
110
110
111
111
#[ cargo_test]
@@ -132,14 +132,13 @@ fn profile_config_error_paths() {
132
132
133
133
p. cargo ( "build" )
134
134
. with_status ( 101 )
135
- . with_stderr (
136
- "\
137
- [ERROR] error in [..]/foo/.cargo/config.toml: could not load config key `profile.dev`
135
+ . with_stderr_data ( str![ [ r#"
136
+ [ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev`
138
137
139
138
Caused by:
140
- error in [.. ]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string
141
- " ,
142
- )
139
+ error in [ROOT ]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string
140
+
141
+ "# ] ] )
143
142
. run ( ) ;
144
143
}
145
144
@@ -159,14 +158,13 @@ fn profile_config_validate_errors() {
159
158
160
159
p. cargo ( "build" )
161
160
. with_status ( 101 )
162
- . with_stderr (
163
- "\
164
- [ERROR] config profile `dev` is not valid (defined in `[..]/foo/.cargo/config.toml`)
161
+ . with_stderr_data ( str![ [ r#"
162
+ [ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`)
165
163
166
164
Caused by:
167
165
`panic` may not be specified in a `package` profile
168
- " ,
169
- )
166
+
167
+ "# ] ] )
170
168
. run ( ) ;
171
169
}
172
170
@@ -186,14 +184,13 @@ fn profile_config_syntax_errors() {
186
184
187
185
p. cargo ( "build" )
188
186
. with_status ( 101 )
189
- . with_stderr (
190
- "\
191
- [ERROR] error in [..]/.cargo/config.toml: could not load config key `profile.dev`
187
+ . with_stderr_data ( str![ [ r#"
188
+ [ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev`
192
189
193
190
Caused by:
194
- error in [.. ]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string
195
- " ,
196
- )
191
+ error in [ROOT ]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string
192
+
193
+ "# ] ] )
197
194
. run ( ) ;
198
195
}
199
196
@@ -231,12 +228,12 @@ fn profile_config_override_spec_multiple() {
231
228
// much of a problem.
232
229
p. cargo ( "build -v" )
233
230
. with_status ( 101 )
234
- . with_stderr (
235
- "\
231
+ . with_stderr_data ( str![ [ r#"
236
232
[LOCKING] 2 packages to latest compatible versions
237
- [ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([..])`
238
- found package specs: bar, [email protected] " ,
239
- )
233
+ [ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([ROOT]/foo/bar)`
234
+ found package specs: bar, [email protected]
235
+
236
+ "# ] ] )
240
237
. run ( ) ;
241
238
}
242
239
@@ -264,22 +261,12 @@ fn profile_config_all_options() {
264
261
265
262
p. cargo ( "build --release -v" )
266
263
. env_remove ( "CARGO_INCREMENTAL" )
267
- . with_stderr (
268
- "\
269
- [COMPILING] foo [..]
270
- [RUNNING] `rustc --crate-name foo [..] \
271
- -C opt-level=1 \
272
- -C panic=abort \
273
- -C lto[..]\
274
- -C codegen-units=2 \
275
- -C debuginfo=2 [..]\
276
- -C debug-assertions=on \
277
- -C overflow-checks=off [..]\
278
- -C rpath [..]\
279
- -C incremental=[..]
280
- [FINISHED] `release` profile [optimized + debuginfo] [..]
281
- " ,
282
- )
264
+ . with_stderr_data ( str![ [ r#"
265
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
266
+ [RUNNING] `rustc --crate-name foo [..] -C opt-level=1 -C panic=abort -C lto[..]-C codegen-units=2 -C debuginfo=2 [..]-C debug-assertions=on -C overflow-checks=off [..]-C rpath --out-dir [ROOT]/foo/target/release/deps -C incremental=[ROOT]/foo/target/release/incremental[..]`
267
+ [FINISHED] `release` profile [optimized + debuginfo] target(s) in [ELAPSED]s
268
+
269
+ "# ] ] )
283
270
. run ( ) ;
284
271
}
285
272
@@ -318,18 +305,19 @@ fn profile_config_override_precedence() {
318
305
. build ( ) ;
319
306
320
307
p. cargo ( "build -v" )
321
- . with_stderr (
322
- "\
308
+ . with_stderr_data ( str![ [ r#"
323
309
[LOCKING] 2 packages to latest compatible versions
324
- [COMPILING] bar [..]
325
- [RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..]
326
- [COMPILING] foo [..]
327
- [RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..]
328
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]" ,
329
- )
310
+ [COMPILING] bar v0.5.0 ([ROOT]/foo/bar)
311
+ [RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..]`
312
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
313
+ [RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..]`
314
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
315
+
316
+ "# ] ] )
330
317
. run ( ) ;
331
318
}
332
319
320
+ #[ allow( deprecated) ]
333
321
#[ cargo_test]
334
322
fn profile_config_no_warn_unknown_override ( ) {
335
323
let p = project ( )
@@ -371,7 +359,12 @@ fn profile_config_mixed_types() {
371
359
. build ( ) ;
372
360
373
361
p. cargo ( "build -v" )
374
- . with_stderr_contains ( "[..]-C opt-level=3 [..]" )
362
+ . with_stderr_data ( str![ [ r#"
363
+ [COMPILING] foo v0.5.0 ([ROOT]/foo)
364
+ [RUNNING] `rustc [..]-C opt-level=3 [..]`
365
+ [FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s
366
+
367
+ "# ] ] )
375
368
. run ( ) ;
376
369
}
377
370
@@ -486,10 +479,16 @@ fn named_env_profile() {
486
479
p. cargo ( "build -v --profile=other" )
487
480
. env ( "CARGO_PROFILE_OTHER_CODEGEN_UNITS" , "1" )
488
481
. env ( "CARGO_PROFILE_OTHER_INHERITS" , "dev" )
489
- . with_stderr_contains ( "[..]-C codegen-units=1 [..]" )
482
+ . with_stderr_data ( str![ [ r#"
483
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
484
+ [RUNNING] `rustc [..]-C codegen-units=1 [..]`
485
+ [FINISHED] `other` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
486
+
487
+ "# ] ] )
490
488
. run ( ) ;
491
489
}
492
490
491
+ #[ allow( deprecated) ]
493
492
#[ cargo_test]
494
493
fn test_with_dev_profile ( ) {
495
494
// The `test` profile inherits from `dev` for both local crates and
@@ -512,20 +511,19 @@ fn test_with_dev_profile() {
512
511
. build ( ) ;
513
512
p. cargo ( "test --lib --no-run -v" )
514
513
. env ( "CARGO_PROFILE_DEV_DEBUG" , "0" )
515
- . with_stderr (
516
- "\
517
- [UPDATING] [..]
514
+ . with_stderr_data ( str![ [ r#"
515
+ [UPDATING] `dummy-registry` index
518
516
[LOCKING] 2 packages to latest compatible versions
519
- [DOWNLOADING] [..]
520
- [DOWNLOADED] [..]
517
+ [DOWNLOADING] crates ...
518
+ [DOWNLOADED] somedep v1.0.0 (registry `dummy-registry`)
521
519
[COMPILING] somedep v1.0.0
522
- [RUNNING] `rustc --crate-name somedep [..]
523
- [COMPILING] foo v0.1.0 [..]
524
- [RUNNING] `rustc --crate-name foo [..]
525
- [FINISHED] [..]
526
- [EXECUTABLE] `[..]/ target/debug/deps/foo-[.. ][EXE]`
527
- " ,
528
- )
520
+ [RUNNING] `rustc --crate-name somedep [..]`
521
+ [COMPILING] foo v0.1.0 ([ROOT]/foo)
522
+ [RUNNING] `rustc --crate-name foo [..]`
523
+ [FINISHED] `test` profile [unoptimized] target(s) in [ELAPSED]s
524
+ [EXECUTABLE] `[ROOT]/foo/ target/debug/deps/foo-[HASH ][EXE]`
525
+
526
+ "# ] ] )
529
527
. with_stdout_does_not_contain ( "[..] -C debuginfo=0[..]" )
530
528
. run ( ) ;
531
529
}
0 commit comments