|
| 1 | +//! Tests for `-Zbuild-analysis`. |
| 2 | +
|
| 3 | +use crate::prelude::*; |
| 4 | + |
| 5 | +use cargo_test_support::basic_manifest; |
| 6 | +use cargo_test_support::project; |
| 7 | +use cargo_test_support::str; |
| 8 | + |
| 9 | +#[cargo_test] |
| 10 | +fn gated() { |
| 11 | + let p = project() |
| 12 | + .file("Cargo.toml", &basic_manifest("foo", "0.0.0")) |
| 13 | + .file("src/lib.rs", "") |
| 14 | + .build(); |
| 15 | + |
| 16 | + // Expect no warnings and no analysis status |
| 17 | + p.cargo("check") |
| 18 | + .env("CARGO_BUILD_ANALYSIS_ENABLED", "true") |
| 19 | + .with_stderr_data(str![[r#" |
| 20 | +[CHECKING] foo v0.0.0 ([ROOT]/foo) |
| 21 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 22 | +
|
| 23 | +"#]]) |
| 24 | + .run(); |
| 25 | +} |
| 26 | + |
| 27 | +#[cargo_test] |
| 28 | +fn gated_no_z_flag() { |
| 29 | + let p = project() |
| 30 | + .file("Cargo.toml", &basic_manifest("foo", "0.0.0")) |
| 31 | + .file("src/lib.rs", "") |
| 32 | + .build(); |
| 33 | + |
| 34 | + p.cargo("check") |
| 35 | + .env("CARGO_BUILD_ANALYSIS_ENABLED", "true") |
| 36 | + .masquerade_as_nightly_cargo(&["build-analysis"]) |
| 37 | + .with_stderr_data(str![[r#" |
| 38 | +[CHECKING] foo v0.0.0 ([ROOT]/foo) |
| 39 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 40 | +
|
| 41 | +"#]]) |
| 42 | + .run(); |
| 43 | +} |
| 44 | + |
| 45 | +#[cargo_test] |
| 46 | +fn simple() { |
| 47 | + let p = project() |
| 48 | + .file("Cargo.toml", &basic_manifest("foo", "0.0.0")) |
| 49 | + .file("src/lib.rs", "") |
| 50 | + .build(); |
| 51 | + |
| 52 | + p.cargo("check -Zbuild-analysis") |
| 53 | + .env("CARGO_BUILD_ANALYSIS_ENABLED", "true") |
| 54 | + .masquerade_as_nightly_cargo(&["build-analysis"]) |
| 55 | + .with_stderr_data(str![[r#" |
| 56 | +[CHECKING] foo v0.0.0 ([ROOT]/foo) |
| 57 | +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s |
| 58 | +
|
| 59 | +"#]]) |
| 60 | + .run(); |
| 61 | +} |
0 commit comments