mirror of
https://github.com/rust-lang/cargo
synced 2024-10-01 21:43:45 +00:00
named-profiles: add backward compatibility if feature is disabled
The effects over the profile used by targets are made conditional in this commit, using the old scheme if the `named-profiles` feature is disabled. This also affects the `profile_targets` tests, which now have two modes - stable, and nightly with the feature enabled.
This commit is contained in:
parent
04804ea304
commit
e634ee549c
|
@ -6,7 +6,7 @@ use serde::Deserialize;
|
|||
|
||||
use crate::core::compiler::{CompileMode, ProfileKind};
|
||||
use crate::core::interning::InternedString;
|
||||
use crate::core::{Features, PackageId, PackageIdSpec, PackageSet, Shell};
|
||||
use crate::core::{Feature, Features, PackageId, PackageIdSpec, PackageSet, Shell};
|
||||
use crate::util::errors::CargoResultExt;
|
||||
use crate::util::toml::{ProfilePackageSpec, StringOrBool, TomlProfile, TomlProfiles, U32OrBool};
|
||||
use crate::util::{closest_msg, CargoResult, Config};
|
||||
|
@ -20,6 +20,7 @@ pub struct Profiles {
|
|||
incremental: Option<bool>,
|
||||
dir_names: HashMap<String, String>,
|
||||
by_name: HashMap<String, ProfileMaker>,
|
||||
named_profiles_enabled: bool,
|
||||
}
|
||||
|
||||
impl Profiles {
|
||||
|
@ -40,8 +41,85 @@ impl Profiles {
|
|||
None => config.get::<Option<bool>>("build.incremental")?,
|
||||
};
|
||||
|
||||
if !features.is_enabled(Feature::named_profiles()) {
|
||||
let mut profile_makers = Profiles {
|
||||
incremental,
|
||||
named_profiles_enabled: false,
|
||||
dir_names: Self::predefined_dir_names(),
|
||||
by_name: HashMap::new(),
|
||||
};
|
||||
|
||||
profile_makers.by_name.insert(
|
||||
"dev".to_owned(),
|
||||
ProfileMaker {
|
||||
toml: profiles.and_then(|p| p.get("dev").cloned()),
|
||||
inherits: vec![],
|
||||
config: config_profiles.dev.clone(),
|
||||
default: Profile::default_dev(),
|
||||
},
|
||||
);
|
||||
profile_makers
|
||||
.dir_names
|
||||
.insert("dev".to_owned(), "debug".to_owned());
|
||||
|
||||
profile_makers.by_name.insert(
|
||||
"release".to_owned(),
|
||||
ProfileMaker {
|
||||
toml: profiles.and_then(|p| p.get("release").cloned()),
|
||||
inherits: vec![],
|
||||
config: config_profiles.release.clone(),
|
||||
default: Profile::default_release(),
|
||||
},
|
||||
);
|
||||
profile_makers
|
||||
.dir_names
|
||||
.insert("release".to_owned(), "release".to_owned());
|
||||
|
||||
profile_makers.by_name.insert(
|
||||
"test".to_owned(),
|
||||
ProfileMaker {
|
||||
toml: profiles.and_then(|p| p.get("test").cloned()),
|
||||
inherits: vec![],
|
||||
config: None,
|
||||
default: Profile::default_test(),
|
||||
},
|
||||
);
|
||||
profile_makers
|
||||
.dir_names
|
||||
.insert("test".to_owned(), "debug".to_owned());
|
||||
|
||||
profile_makers.by_name.insert(
|
||||
"bench".to_owned(),
|
||||
ProfileMaker {
|
||||
toml: profiles.and_then(|p| p.get("bench").cloned()),
|
||||
inherits: vec![],
|
||||
config: None,
|
||||
default: Profile::default_bench(),
|
||||
},
|
||||
);
|
||||
profile_makers
|
||||
.dir_names
|
||||
.insert("bench".to_owned(), "release".to_owned());
|
||||
|
||||
profile_makers.by_name.insert(
|
||||
"doc".to_owned(),
|
||||
ProfileMaker {
|
||||
toml: profiles.and_then(|p| p.get("doc").cloned()),
|
||||
inherits: vec![],
|
||||
config: None,
|
||||
default: Profile::default_doc(),
|
||||
},
|
||||
);
|
||||
profile_makers
|
||||
.dir_names
|
||||
.insert("doc".to_owned(), "debug".to_owned());
|
||||
|
||||
return Ok(profile_makers);
|
||||
}
|
||||
|
||||
let mut profile_makers = Profiles {
|
||||
incremental,
|
||||
named_profiles_enabled: true,
|
||||
dir_names: Self::predefined_dir_names(),
|
||||
by_name: HashMap::new(),
|
||||
};
|
||||
|
@ -236,8 +314,47 @@ impl Profiles {
|
|||
mode: CompileMode,
|
||||
profile_kind: ProfileKind,
|
||||
) -> Profile {
|
||||
let maker = match self.by_name.get(profile_kind.name()) {
|
||||
None => panic!("Profile {} undefined", profile_kind.name()),
|
||||
let profile_name = if !self.named_profiles_enabled {
|
||||
// With the feature disabled, we degrade `--profile` back to the
|
||||
// `--release` and `--debug` predicates, and convert back from
|
||||
// ProfileKind::Custom instantiation.
|
||||
|
||||
let release = match profile_kind {
|
||||
ProfileKind::Release => true,
|
||||
ProfileKind::Custom(ref s) if s == "bench" => true,
|
||||
ProfileKind::Custom(ref s) if s == "test" => false,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
match mode {
|
||||
CompileMode::Test | CompileMode::Bench => {
|
||||
if release {
|
||||
"bench"
|
||||
} else {
|
||||
"test"
|
||||
}
|
||||
}
|
||||
CompileMode::Build
|
||||
| CompileMode::Check { .. }
|
||||
| CompileMode::Doctest
|
||||
| CompileMode::RunCustomBuild => {
|
||||
// Note: `RunCustomBuild` doesn't normally use this code path.
|
||||
// `build_unit_profiles` normally ensures that it selects the
|
||||
// ancestor's profile. However, `cargo clean -p` can hit this
|
||||
// path.
|
||||
if release {
|
||||
"release"
|
||||
} else {
|
||||
"dev"
|
||||
}
|
||||
}
|
||||
CompileMode::Doc { .. } => "doc",
|
||||
}
|
||||
} else {
|
||||
profile_kind.name()
|
||||
};
|
||||
let maker = match self.by_name.get(profile_name) {
|
||||
None => panic!("Profile {} undefined", profile_name),
|
||||
Some(r) => r,
|
||||
};
|
||||
let mut profile = maker.get_profile(Some(pkg_id), is_member, unit_for);
|
||||
|
@ -666,6 +783,29 @@ impl Profile {
|
|||
}
|
||||
}
|
||||
|
||||
// NOTE: Remove the following three once `named_profiles` is default:
|
||||
|
||||
fn default_test() -> Profile {
|
||||
Profile {
|
||||
name: "test",
|
||||
..Profile::default_dev()
|
||||
}
|
||||
}
|
||||
|
||||
fn default_bench() -> Profile {
|
||||
Profile {
|
||||
name: "bench",
|
||||
..Profile::default_release()
|
||||
}
|
||||
}
|
||||
|
||||
fn default_doc() -> Profile {
|
||||
Profile {
|
||||
name: "doc",
|
||||
..Profile::default_dev()
|
||||
}
|
||||
}
|
||||
|
||||
/// Compares all fields except `name`, which doesn't affect compilation.
|
||||
/// This is necessary for `Unit` deduplication for things like "test" and
|
||||
/// "dev" which are essentially the same.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use cargo_test_support::{basic_manifest, project, Project};
|
||||
use cargo_test_support::{basic_manifest, is_nightly, project, Project};
|
||||
|
||||
// These tests try to exercise exactly which profiles are selected for every target.
|
||||
|
||||
|
@ -8,16 +8,19 @@ fn all_target_project() -> Project {
|
|||
project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
&format!(
|
||||
r#"
|
||||
cargo-features = [{named_profiles}]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
|
||||
[dependencies]
|
||||
bar = { path = "bar" }
|
||||
bar = {{ path = "bar" }}
|
||||
|
||||
[build-dependencies]
|
||||
bdep = { path = "bdep" }
|
||||
bdep = {{ path = "bdep" }}
|
||||
|
||||
[profile.dev]
|
||||
codegen-units = 1
|
||||
|
@ -30,6 +33,12 @@ fn all_target_project() -> Project {
|
|||
[profile.bench]
|
||||
codegen-units = 4
|
||||
"#,
|
||||
named_profiles = if is_nightly() {
|
||||
"\"named-profiles\", "
|
||||
} else {
|
||||
""
|
||||
}
|
||||
),
|
||||
)
|
||||
.file("src/lib.rs", "extern crate bar;")
|
||||
.file("src/main.rs", "extern crate foo; fn main() {}")
|
||||
|
@ -76,7 +85,7 @@ fn profile_selection_build() {
|
|||
// NOTES:
|
||||
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
||||
// - build_script_build is built without panic because it thinks `build.rs` is a plugin.
|
||||
p.cargo("build -vv").with_stderr_unordered("\
|
||||
p.cargo("build -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
|
||||
|
@ -91,6 +100,7 @@ fn profile_selection_build() {
|
|||
[FINISHED] dev [unoptimized + debuginfo] [..]
|
||||
").run();
|
||||
p.cargo("build -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -107,7 +117,7 @@ fn profile_selection_build_release() {
|
|||
let p = all_target_project();
|
||||
|
||||
// `build --release`
|
||||
p.cargo("build --release -vv").with_stderr_unordered("\
|
||||
p.cargo("build --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
|
@ -122,6 +132,7 @@ fn profile_selection_build_release() {
|
|||
[FINISHED] release [optimized] [..]
|
||||
").run();
|
||||
p.cargo("build --release -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -136,6 +147,7 @@ fn profile_selection_build_release() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_build_all_targets() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 1 } else { 3 };
|
||||
// `build`
|
||||
// NOTES:
|
||||
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
||||
|
@ -158,12 +170,12 @@ fn profile_selection_build_all_targets() {
|
|||
// lib dev+panic build (a normal lib target)
|
||||
// lib dev-panic build (used by tests/benches)
|
||||
// lib dev dev
|
||||
// test dev dev
|
||||
// test dev dev
|
||||
// bench dev dev
|
||||
// bin dev dev
|
||||
// bin dev build
|
||||
// example dev build
|
||||
p.cargo("build --all-targets -vv").with_stderr_unordered("\
|
||||
p.cargo("build --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
|
||||
|
@ -174,16 +186,17 @@ fn profile_selection_build_all_targets() {
|
|||
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
|
||||
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C codegen-units=1 -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C codegen-units={affected} -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C codegen-units=1 -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C codegen-units=1 -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C codegen-units=1 -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C codegen-units={affected} -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C codegen-units={affected} -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C codegen-units={affected} -C debuginfo=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]`
|
||||
[FINISHED] dev [unoptimized + debuginfo] [..]
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
p.cargo("build -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -198,6 +211,7 @@ fn profile_selection_build_all_targets() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_build_all_targets_release() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 2 } else { 4 };
|
||||
// `build --all-targets --release`
|
||||
// NOTES:
|
||||
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
|
||||
|
@ -228,7 +242,7 @@ fn profile_selection_build_all_targets_release() {
|
|||
// bin release test (bench/test de-duped)
|
||||
// bin release build
|
||||
// example release build
|
||||
p.cargo("build --all-targets --release -vv").with_stderr_unordered("\
|
||||
p.cargo("build --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
|
||||
|
@ -239,16 +253,17 @@ fn profile_selection_build_all_targets_release() {
|
|||
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
|
||||
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]`
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]`
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]`
|
||||
[FINISHED] release [optimized] [..]
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
p.cargo("build --all-targets --release -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -263,6 +278,7 @@ fn profile_selection_build_all_targets_release() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_test() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 3 } else { 1 };
|
||||
// `test`
|
||||
// NOTES:
|
||||
// - Dependency profiles:
|
||||
|
@ -284,31 +300,32 @@ fn profile_selection_test() {
|
|||
// bin test test
|
||||
// bin test build
|
||||
//
|
||||
p.cargo("test -vv").with_stderr_unordered("\
|
||||
p.cargo("test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[COMPILING] bdep [..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[COMPILING] foo [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
|
||||
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[FINISHED] test [unoptimized + debuginfo] [..]
|
||||
[RUNNING] `[..]/deps/foo-[..]`
|
||||
[RUNNING] `[..]/deps/foo-[..]`
|
||||
[RUNNING] `[..]/deps/test1-[..]`
|
||||
[DOCTEST] foo
|
||||
[RUNNING] `rustdoc [..]--test [..]
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
p.cargo("test -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -328,6 +345,8 @@ fn profile_selection_test() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_test_release() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 2 } else { 4 };
|
||||
|
||||
// `test --release`
|
||||
// NOTES:
|
||||
// - Dependency profiles:
|
||||
|
@ -349,7 +368,7 @@ fn profile_selection_test_release() {
|
|||
// bin release test
|
||||
// bin release build
|
||||
//
|
||||
p.cargo("test --release -vv").with_stderr_unordered("\
|
||||
p.cargo("test --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
|
||||
|
@ -361,9 +380,9 @@ fn profile_selection_test_release() {
|
|||
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units={affected} --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
|
||||
[FINISHED] release [optimized] [..]
|
||||
|
@ -372,8 +391,9 @@ fn profile_selection_test_release() {
|
|||
[RUNNING] `[..]/deps/test1-[..]`
|
||||
[DOCTEST] foo
|
||||
[RUNNING] `rustdoc [..]--test [..]`
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
p.cargo("test --release -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -393,6 +413,7 @@ fn profile_selection_test_release() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_bench() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 4 } else { 2 };
|
||||
|
||||
// `bench`
|
||||
// NOTES:
|
||||
|
@ -414,28 +435,29 @@ fn profile_selection_bench() {
|
|||
// bin bench test(bench)
|
||||
// bin bench build
|
||||
//
|
||||
p.cargo("bench -vv").with_stderr_unordered("\
|
||||
p.cargo("bench -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units={affected} [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units={affected} [..]
|
||||
[COMPILING] bdep [..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units={affected} [..]
|
||||
[COMPILING] foo [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C codegen-units={affected} [..]
|
||||
[RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
|
||||
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units={affected} [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units={affected} [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=4 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=4 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3 -C codegen-units=4 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units=4 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort -C codegen-units={affected} [..]
|
||||
[FINISHED] bench [optimized] [..]
|
||||
[RUNNING] `[..]/deps/foo-[..] --bench`
|
||||
[RUNNING] `[..]/deps/foo-[..] --bench`
|
||||
[RUNNING] `[..]/deps/bench1-[..] --bench`
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
p.cargo("bench -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -478,7 +500,7 @@ fn profile_selection_check_all_targets() {
|
|||
// bin dev check
|
||||
// bin dev-panic check-test (checking bin as a unittest)
|
||||
//
|
||||
p.cargo("check --all-targets -vv").with_stderr_unordered("\
|
||||
p.cargo("check --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C codegen-units=1 -C debuginfo=2 [..]
|
||||
|
@ -504,6 +526,7 @@ fn profile_selection_check_all_targets() {
|
|||
// rechecked.
|
||||
// See PR rust-lang/rust#49289 and issue rust-lang/cargo#3624.
|
||||
p.cargo("check --all-targets -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -523,7 +546,7 @@ fn profile_selection_check_all_targets_release() {
|
|||
// This is a pretty straightforward variant of
|
||||
// `profile_selection_check_all_targets` that uses `release` instead of
|
||||
// `dev` for all targets.
|
||||
p.cargo("check --all-targets --release -vv").with_stderr_unordered("\
|
||||
p.cargo("check --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C codegen-units=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3 -C codegen-units=2 [..]
|
||||
|
@ -546,6 +569,7 @@ fn profile_selection_check_all_targets_release() {
|
|||
").run();
|
||||
|
||||
p.cargo("check --all-targets --release -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -560,6 +584,8 @@ fn profile_selection_check_all_targets_release() {
|
|||
#[cargo_test]
|
||||
fn profile_selection_check_all_targets_test() {
|
||||
let p = all_target_project();
|
||||
let affected = if is_nightly() { 3 } else { 1 };
|
||||
|
||||
// `check --profile=test`
|
||||
// - Dependency profiles:
|
||||
// Pkg Target Profile Action Reason
|
||||
|
@ -581,26 +607,27 @@ fn profile_selection_check_all_targets_test() {
|
|||
// bench test-panic check-test
|
||||
// bin test-panic check-test
|
||||
//
|
||||
p.cargo("check --all-targets --profile=test -vv").with_stderr_unordered("\
|
||||
p.cargo("check --all-targets --profile=test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\
|
||||
[COMPILING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[COMPILING] bdep[..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[COMPILING] foo [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
|
||||
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C codegen-units=3 -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata -C codegen-units=3 -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 --test [..]
|
||||
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata -C codegen-units={affected} -C debuginfo=2 --test [..]
|
||||
[FINISHED] test [unoptimized + debuginfo] [..]
|
||||
").run();
|
||||
", affected=affected)).run();
|
||||
|
||||
p.cargo("check --all-targets --profile=test -vv")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[FRESH] bar [..]
|
||||
|
@ -626,7 +653,7 @@ fn profile_selection_doc() {
|
|||
// foo custom dev* link For build.rs
|
||||
//
|
||||
// `*` = wants panic, but it is cleared when args are built.
|
||||
p.cargo("doc -vv").with_stderr_unordered("\
|
||||
p.cargo("doc -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\
|
||||
[COMPILING] bar [..]
|
||||
[DOCUMENTING] bar [..]
|
||||
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C codegen-units=1 -C debuginfo=2 [..]
|
||||
|
|
Loading…
Reference in a new issue