|
1 | 1 | //! Tests for profile overrides (build-override and per-package overrides).
|
2 | 2 |
|
3 |
| -#![allow(deprecated)] |
4 |
| - |
| 3 | +use cargo_test_support::prelude::*; |
5 | 4 | use cargo_test_support::registry::Package;
|
6 |
| -use cargo_test_support::{basic_lib_manifest, basic_manifest, project}; |
| 5 | +use cargo_test_support::{basic_lib_manifest, basic_manifest, project, str}; |
7 | 6 |
|
8 | 7 | #[cargo_test]
|
9 | 8 | fn profile_override_basic() {
|
@@ -33,15 +32,15 @@ fn profile_override_basic() {
|
33 | 32 | .build();
|
34 | 33 |
|
35 | 34 | p.cargo("check -v")
|
36 |
| - .with_stderr( |
37 |
| - "\ |
| 35 | + .with_stderr_data(str![[r#" |
38 | 36 | [LOCKING] 2 packages to latest compatible versions
|
39 |
| -[CHECKING] bar [..] |
| 37 | +[CHECKING] bar v0.5.0 ([ROOT]/foo/bar) |
40 | 38 | [RUNNING] `rustc --crate-name bar [..] -C opt-level=3 [..]`
|
41 |
| -[CHECKING] foo [..] |
| 39 | +[CHECKING] foo v0.0.1 ([ROOT]/foo) |
42 | 40 | [RUNNING] `rustc --crate-name foo [..] -C opt-level=1 [..]`
|
43 |
| -[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [..]", |
44 |
| - ) |
| 41 | +[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s |
| 42 | +
|
| 43 | +"#]]) |
45 | 44 | .run();
|
46 | 45 | }
|
47 | 46 |
|
@@ -74,20 +73,18 @@ fn profile_override_warnings() {
|
74 | 73 | .file("bar/src/lib.rs", "")
|
75 | 74 | .build();
|
76 | 75 |
|
77 |
| - p.cargo("build") |
78 |
| - .with_stderr_contains( |
79 |
| - "\ |
80 |
| -[WARNING] profile package spec `[email protected]` in profile `dev` \ |
81 |
| - has a version or URL that does not match any of the packages: \ |
82 |
| - bar v0.5.0 ([..]/foo/bar) |
| 76 | + p.cargo("build").with_stderr_data(str![[r#" |
| 77 | +... |
| 78 | +[WARNING] profile package spec `[email protected]` in profile `dev` has a version or URL that does not match any of the packages: bar v0.5.0 ([ROOT]/foo/bar) |
83 | 79 | [WARNING] profile package spec `bart` in profile `dev` did not match any packages
|
84 | 80 |
|
85 |
| -<tab>Did you mean `bar`? |
| 81 | + Did you mean `bar`? |
86 | 82 | [WARNING] profile package spec `no-suggestion` in profile `dev` did not match any packages
|
87 |
| -[COMPILING] [..] |
88 |
| -", |
89 |
| - ) |
90 |
| - .run(); |
| 83 | +[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) |
| 84 | +[COMPILING] foo v0.0.1 ([ROOT]/foo) |
| 85 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 86 | +
|
| 87 | +"#]]).run(); |
91 | 88 | }
|
92 | 89 |
|
93 | 90 | #[cargo_test]
|
@@ -134,7 +131,13 @@ fn profile_override_bad_settings() {
|
134 | 131 |
|
135 | 132 | p.cargo("check")
|
136 | 133 | .with_status(101)
|
137 |
| - .with_stderr_contains(format!("Caused by:\n {}", expected)) |
| 134 | + .with_stderr_data(format!( |
| 135 | + "\ |
| 136 | +... |
| 137 | +Caused by:\n {} |
| 138 | +", |
| 139 | + expected |
| 140 | + )) |
138 | 141 | .run();
|
139 | 142 | }
|
140 | 143 | }
|
@@ -221,24 +224,25 @@ fn profile_override_hierarchy() {
|
221 | 224 | // m2: 2 (as [profile.dev.package.m2])
|
222 | 225 | // m1: 1 (as [profile.dev])
|
223 | 226 |
|
224 |
| - p.cargo("build -v").with_stderr_unordered("\ |
| 227 | + p.cargo("build -v") |
| 228 | + .with_stderr_data(str![[r#" |
225 | 229 | [LOCKING] 4 packages to latest compatible versions
|
226 |
| -[COMPILING] m3 [..] |
227 |
| -[COMPILING] dep [..] |
228 |
| -[RUNNING] `rustc --crate-name m3 --edition=2015 m3/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=4 [..] |
229 |
| -[RUNNING] `rustc --crate-name dep[..]dep/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=3 [..] |
230 |
| -[RUNNING] `rustc --crate-name m3 --edition=2015 m3/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=1 [..] |
231 |
| -[RUNNING] `rustc --crate-name build_script_build --edition=2015 m1/build.rs [..] --crate-type bin --emit=[..]link[..]-C codegen-units=4 [..] |
232 |
| -[COMPILING] m2 [..] |
233 |
| -[RUNNING] `rustc --crate-name build_script_build --edition=2015 m2/build.rs [..] --crate-type bin --emit=[..]link[..]-C codegen-units=2 [..] |
234 |
| -[RUNNING] `[..]/m1-[..]/build-script-build` |
235 |
| -[RUNNING] `[..]/m2-[..]/build-script-build` |
236 |
| -[RUNNING] `rustc --crate-name m2 --edition=2015 m2/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=2 [..] |
237 |
| -[COMPILING] m1 [..] |
238 |
| -[RUNNING] `rustc --crate-name m1 --edition=2015 m1/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=1 [..] |
239 |
| -[FINISHED] `dev` profile [unoptimized + debuginfo] [..] |
240 |
| -", |
241 |
| - ) |
| 230 | +[COMPILING] m3 v0.5.0 ([ROOT]/foo/m3) |
| 231 | +[COMPILING] dep v0.5.0 ([ROOT]/dep) |
| 232 | +[RUNNING] `rustc --crate-name m3 --edition=2015 m3/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=4 [..]` |
| 233 | +[RUNNING] `rustc --crate-name dep [..][ROOT]/dep/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=3 [..]` |
| 234 | +[RUNNING] `rustc --crate-name m3 --edition=2015 m3/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=1 [..]` |
| 235 | +[RUNNING] `rustc --crate-name build_script_build --edition=2015 m1/build.rs [..] --crate-type bin --emit=[..]link[..]-C codegen-units=4 [..]` |
| 236 | +[COMPILING] m2 v0.0.1 ([ROOT]/foo/m2) |
| 237 | +[RUNNING] `rustc --crate-name build_script_build --edition=2015 m2/build.rs [..] --crate-type bin --emit=[..]link[..]-C codegen-units=2 [..]` |
| 238 | +[RUNNING] `[ROOT]/foo/target/debug/build/m1-[HASH]/build-script-build` |
| 239 | +[RUNNING] `[ROOT]/foo/target/debug/build/m2-[HASH]/build-script-build` |
| 240 | +[RUNNING] `rustc --crate-name m2 --edition=2015 m2/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=2 [..]` |
| 241 | +[COMPILING] m1 v0.0.1 ([ROOT]/foo/m1) |
| 242 | +[RUNNING] `rustc --crate-name m1 --edition=2015 m1/src/lib.rs [..] --crate-type lib --emit=[..]link[..]-C codegen-units=1 [..]` |
| 243 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 244 | +
|
| 245 | +"#]].unordered()) |
242 | 246 | .run();
|
243 | 247 | }
|
244 | 248 |
|
@@ -270,11 +274,12 @@ fn profile_override_spec_multiple() {
|
270 | 274 |
|
271 | 275 | p.cargo("check -v")
|
272 | 276 | .with_status(101)
|
273 |
| - .with_stderr_contains( |
274 |
| - "\ |
275 |
| -[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([..])` |
276 |
| -found package specs: bar, [email protected]", |
277 |
| - ) |
| 277 | + .with_stderr_data(str![[r#" |
| 278 | +... |
| 279 | +[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([ROOT]/foo/bar)` |
| 280 | +found package specs: bar, [email protected] |
| 281 | +
|
| 282 | +"#]]) |
278 | 283 | .run();
|
279 | 284 | }
|
280 | 285 |
|
@@ -302,7 +307,12 @@ fn profile_override_spec_with_version() {
|
302 | 307 | .build();
|
303 | 308 |
|
304 | 309 | p.cargo("check -v")
|
305 |
| - .with_stderr_contains("[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]") |
| 310 | + .with_stderr_data(str![[r#" |
| 311 | +... |
| 312 | +[CHECKING] bar v0.5.0 ([ROOT]/foo/bar) |
| 313 | +[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]` |
| 314 | +... |
| 315 | +"#]]) |
306 | 316 | .run();
|
307 | 317 | }
|
308 | 318 |
|
@@ -330,7 +340,12 @@ fn profile_override_spec_with_partial_version() {
|
330 | 340 | .build();
|
331 | 341 |
|
332 | 342 | p.cargo("check -v")
|
333 |
| - .with_stderr_contains("[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]") |
| 343 | + .with_stderr_data(str![[r#" |
| 344 | +... |
| 345 | +[CHECKING] bar v0.5.0 ([ROOT]/foo/bar) |
| 346 | +[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]` |
| 347 | +... |
| 348 | +"#]]) |
334 | 349 | .run();
|
335 | 350 | }
|
336 | 351 |
|
@@ -393,11 +408,19 @@ fn profile_override_spec() {
|
393 | 408 | .build();
|
394 | 409 |
|
395 | 410 | p.cargo("check -v")
|
396 |
| - .with_stderr_contains("[RUNNING] `rustc [..]dep1/src/lib.rs [..] -C codegen-units=1 [..]") |
397 |
| - .with_stderr_contains("[RUNNING] `rustc [..]dep2/src/lib.rs [..] -C codegen-units=2 [..]") |
| 411 | + .with_stderr_data( |
| 412 | + str![[r#" |
| 413 | +... |
| 414 | +[RUNNING] `rustc [..][ROOT]/dep1/src/lib.rs [..] -C codegen-units=1 [..]` |
| 415 | +[RUNNING] `rustc [..][ROOT]/dep2/src/lib.rs [..] -C codegen-units=2 [..]` |
| 416 | +... |
| 417 | +"#]] |
| 418 | + .unordered(), |
| 419 | + ) |
398 | 420 | .run();
|
399 | 421 | }
|
400 | 422 |
|
| 423 | +#[allow(deprecated)] |
401 | 424 | #[cargo_test]
|
402 | 425 | fn override_proc_macro() {
|
403 | 426 | Package::new("shared", "1.0.0").publish();
|
@@ -450,13 +473,18 @@ fn override_proc_macro() {
|
450 | 473 |
|
451 | 474 | p.cargo("check -v")
|
452 | 475 | // Shared built for the proc-macro.
|
453 |
| - .with_stderr_contains("[RUNNING] `rustc [..]--crate-name shared [..]-C codegen-units=4[..]") |
| 476 | + .with_stderr_data(str![[r#" |
| 477 | +... |
| 478 | +[RUNNING] `rustc [..]--crate-name shared [..] -C codegen-units=4[..]` |
| 479 | +... |
| 480 | +[RUNNING] `rustc [..]--crate-name pm [..] -C codegen-units=4[..]` |
| 481 | +... |
| 482 | +"#]]) |
454 | 483 | // Shared built for the library.
|
455 | 484 | .with_stderr_line_without(
|
456 | 485 | &["[RUNNING] `rustc --crate-name shared --edition=2015"],
|
457 | 486 | &["-C codegen-units"],
|
458 | 487 | )
|
459 |
| - .with_stderr_contains("[RUNNING] `rustc [..]--crate-name pm [..]-C codegen-units=4[..]") |
460 | 488 | .with_stderr_line_without(
|
461 | 489 | &["[RUNNING] `rustc [..]--crate-name foo"],
|
462 | 490 | &["-C codegen-units"],
|
@@ -485,13 +513,12 @@ fn no_warning_ws() {
|
485 | 513 | .build();
|
486 | 514 |
|
487 | 515 | p.cargo("check -p b")
|
488 |
| - .with_stderr( |
489 |
| - "\ |
| 516 | + .with_stderr_data(str![[r#" |
490 | 517 | [LOCKING] 2 packages to latest compatible versions
|
491 |
| -[CHECKING] b [..] |
492 |
| -[FINISHED] [..] |
493 |
| -", |
494 |
| - ) |
| 518 | +[CHECKING] b v0.1.0 ([ROOT]/foo/b) |
| 519 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 520 | +
|
| 521 | +"#]]) |
495 | 522 | .run();
|
496 | 523 | }
|
497 | 524 |
|
|
0 commit comments