diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index 6e96cf08f9f..036f1a457f1 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -73,9 +73,18 @@ Compilation can be customized with the `bench` profile in the manifest. pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; - let mut compile_opts = args.compile_options(config, CompileMode::Bench, Some(&ws))?; + let mut compile_opts = args.compile_options( + config, + CompileMode::Bench, + Some(&ws), + ProfileChecking::Checked, + )?; - compile_opts.build_config.release = true; + compile_opts.build_config.profile_kind = args.get_profile_kind( + config, + ProfileKind::Custom("bench".to_owned()), + ProfileChecking::Checked, + )?; let ops = TestOptions { no_run: args.is_present("no-run"), diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index 5dee4e03984..df3a69c18d0 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -27,6 +27,7 @@ pub fn cli() -> App { "Build all targets", ) .arg_release("Build artifacts in release mode, with optimizations") + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() @@ -55,7 +56,12 @@ the --release flag will use the `release` profile instead. pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; - let mut compile_opts = args.compile_options(config, CompileMode::Build, Some(&ws))?; + let mut compile_opts = args.compile_options( + config, + CompileMode::Build, + Some(&ws), + ProfileChecking::Checked, + )?; compile_opts.export_dir = args.value_of_path("out-dir", config); if compile_opts.export_dir.is_some() { diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs index 74c1a688927..d93fe19fbc4 100644 --- a/src/bin/cargo/commands/check.rs +++ b/src/bin/cargo/commands/check.rs @@ -27,7 +27,7 @@ pub fn cli() -> App { "Check all targets", ) .arg_release("Check artifacts in release mode, with optimizations") - .arg(opt("profile", "Profile to build the selected target for").value_name("PROFILE")) + .arg_profile("Check artifacts with the specified profile") .arg_features() .arg_target_triple("Check for the target triple") .arg_target_dir() @@ -69,7 +69,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { } }; let mode = CompileMode::Check { test }; - let compile_opts = args.compile_options(config, mode, Some(&ws))?; + let compile_opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?; ops::compile(&ws, &compile_opts)?; Ok(()) diff --git a/src/bin/cargo/commands/clean.rs b/src/bin/cargo/commands/clean.rs index e336f73a031..0cce5725767 100644 --- a/src/bin/cargo/commands/clean.rs +++ b/src/bin/cargo/commands/clean.rs @@ -11,6 +11,7 @@ pub fn cli() -> App { .arg_target_triple("Target triple to clean output for") .arg_target_dir() .arg_release("Whether or not to clean release artifacts") + .arg_profile("Clean artifacts of the specified profile") .arg_doc("Whether or not to clean just the documentation directory") .after_help( "\ @@ -28,7 +29,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { config, spec: values(args, "package"), target: args.target(), - release: args.is_present("release"), + profile_kind: args.get_profile_kind(config, ProfileKind::Dev, ProfileChecking::Checked)?, + profile_specified: args.is_present("profile") || args.is_present("release"), doc: args.is_present("doc"), }; ops::clean(&ws, &opts)?; diff --git a/src/bin/cargo/commands/clippy.rs b/src/bin/cargo/commands/clippy.rs index 4aa412ceeca..bd263d3b232 100644 --- a/src/bin/cargo/commands/clippy.rs +++ b/src/bin/cargo/commands/clippy.rs @@ -26,6 +26,7 @@ pub fn cli() -> App { "Check all targets", ) .arg_release("Check artifacts in release mode, with optimizations") + .arg_profile("Check artifacts with the specified profile") .arg_features() .arg_target_triple("Check for the target triple") .arg_target_dir() @@ -61,7 +62,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; let mode = CompileMode::Check { test: false }; - let mut compile_opts = args.compile_options(config, mode, Some(&ws))?; + let mut compile_opts = + args.compile_options(config, mode, Some(&ws), ProfileChecking::Checked)?; if !config.cli_unstable().unstable_options { return Err(failure::format_err!( diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs index 6e880ba9245..a284e572947 100644 --- a/src/bin/cargo/commands/doc.rs +++ b/src/bin/cargo/commands/doc.rs @@ -24,6 +24,7 @@ pub fn cli() -> App { "Document all binaries", ) .arg_release("Build artifacts in release mode, with optimizations") + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() @@ -52,7 +53,8 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let mode = CompileMode::Doc { deps: !args.is_present("no-deps"), }; - let mut compile_opts = args.compile_options(config, mode, Some(&ws))?; + let mut compile_opts = + args.compile_options(config, mode, Some(&ws), ProfileChecking::Checked)?; compile_opts.local_rustdoc_args = if args.is_present("document-private-items") { Some(vec!["--document-private-items".to_string()]) } else { diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 471d05a4c95..9f78319d387 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -25,7 +25,7 @@ pub fn cli() -> App { "Fix all targets (default)", ) .arg_release("Fix artifacts in release mode, with optimizations") - .arg(opt("profile", "Profile to build the selected target for").value_name("PROFILE")) + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Fix for the target triple") .arg_target_dir() @@ -132,7 +132,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { // Unlike other commands default `cargo fix` to all targets to fix as much // code as we can. - let mut opts = args.compile_options(config, mode, Some(&ws))?; + let mut opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?; let use_clippy = args.is_present("clippy"); diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 5dd0c49e093..005bd7fe6ca 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -51,6 +51,7 @@ pub fn cli() -> App { "Do not save tracking information (unstable)", )) .arg_features() + .arg_profile("Install artifacts with from the specified profile") .arg(opt("debug", "Build in debug mode instead of release mode")) .arg_targets_bins_examples( "Install only the specified binary", @@ -115,9 +116,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { } let workspace = args.workspace(config).ok(); - let mut compile_opts = args.compile_options(config, CompileMode::Build, workspace.as_ref())?; - - compile_opts.build_config.release = !args.is_present("debug"); + let mut compile_opts = args.compile_options( + config, + CompileMode::Build, + workspace.as_ref(), + ProfileChecking::Checked, + )?; + + compile_opts.build_config.profile_kind = + args.get_profile_kind(config, ProfileKind::Release, ProfileChecking::Checked)?; let krates = args .values_of("crate") diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index f30e8570d01..29478d2a3af 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -18,6 +18,7 @@ pub fn cli() -> App { .arg_package("Package with the target to run") .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() @@ -40,7 +41,12 @@ run. If you're passing arguments to both Cargo and the binary, the ones after pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; - let mut compile_opts = args.compile_options(config, CompileMode::Build, Some(&ws))?; + let mut compile_opts = args.compile_options( + config, + CompileMode::Build, + Some(&ws), + ProfileChecking::Checked, + )?; if !args.is_present("example") && !args.is_present("bin") { let default_runs: Vec<_> = compile_opts diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index 5cb7f94e09b..b2121caf869 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -23,7 +23,7 @@ pub fn cli() -> App { "Build all targets", ) .arg_release("Build artifacts in release mode, with optimizations") - .arg(opt("profile", "Profile to build the selected target for").value_name("PROFILE")) + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Target triple which compiles will be for") .arg_target_dir() @@ -63,7 +63,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { return Err(CliError::new(err, 101)); } }; - let mut compile_opts = args.compile_options_for_single_package(config, mode, Some(&ws))?; + let mut compile_opts = args.compile_options_for_single_package( + config, + mode, + Some(&ws), + ProfileChecking::Unchecked, + )?; let target_args = values(args, "args"); compile_opts.target_rustc_args = if target_args.is_empty() { None diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index 6616dc70e18..f3c691658da 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -27,6 +27,7 @@ pub fn cli() -> App { "Build all targets", ) .arg_release("Build artifacts in release mode, with optimizations") + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() @@ -55,6 +56,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { config, CompileMode::Doc { deps: false }, Some(&ws), + ProfileChecking::Checked, )?; let target_args = values(args, "args"); compile_opts.target_rustdoc_args = if target_args.is_empty() { diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index c9457023986..95981caacf2 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -47,6 +47,7 @@ pub fn cli() -> App { ) .arg_jobs() .arg_release("Build artifacts in release mode, with optimizations") + .arg_profile("Build artifacts with the specified profile") .arg_features() .arg_target_triple("Build for the target triple") .arg_target_dir() @@ -99,7 +100,18 @@ To get the list of all options available for the test binaries use this: pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; - let mut compile_opts = args.compile_options(config, CompileMode::Test, Some(&ws))?; + let mut compile_opts = args.compile_options( + config, + CompileMode::Test, + Some(&ws), + ProfileChecking::Checked, + )?; + + compile_opts.build_config.profile_kind = args.get_profile_kind( + config, + ProfileKind::Custom("test".to_owned()), + ProfileChecking::Checked, + )?; // `TESTNAME` is actually an argument of the test binary, but it's // important, so we explicitly mention it and reconfigure. diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index d39294660ce..0ba59ecc947 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -6,6 +6,23 @@ use crate::core::compiler::{CompileKind, CompileTarget}; use crate::util::ProcessBuilder; use crate::util::{CargoResult, Config, RustfixDiagnosticServer}; +#[derive(Debug, Clone)] +pub enum ProfileKind { + Dev, + Release, + Custom(String), +} + +impl ProfileKind { + pub fn name(&self) -> &str { + match self { + ProfileKind::Dev => "dev", + ProfileKind::Release => "release", + ProfileKind::Custom(name) => &name, + } + } +} + /// Configuration information for a rustc build. #[derive(Debug)] pub struct BuildConfig { @@ -13,8 +30,8 @@ pub struct BuildConfig { pub requested_kind: CompileKind, /// Number of rustc jobs to run in parallel. pub jobs: u32, - /// `true` if we are building for release. - pub release: bool, + /// Build profile + pub profile_kind: ProfileKind, /// The mode we are compiling in. pub mode: CompileMode, /// `true` to print stdout in JSON format (for machine reading). @@ -77,7 +94,7 @@ impl BuildConfig { Ok(BuildConfig { requested_kind, jobs, - release: false, + profile_kind: ProfileKind::Dev, mode, message_format: MessageFormat::Human, force_rebuild: false, @@ -102,6 +119,10 @@ impl BuildConfig { } } + pub fn profile_name(&self) -> &str { + self.profile_kind.name() + } + pub fn test(&self) -> bool { self.mode == CompileMode::Test || self.mode == CompileMode::Bench } diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index 1600644b55d..d7327df3cbd 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -298,15 +298,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> { export_dir: Option, units: &[Unit<'a>], ) -> CargoResult<()> { - let dest = if self.bcx.build_config.release { - "release" - } else { - "debug" - }; - let host_layout = Layout::new(self.bcx.ws, None, dest)?; + let profile_kind = &self.bcx.build_config.profile_kind; + let dest = self.bcx.profiles.get_dir_name(profile_kind); + let host_layout = Layout::new(self.bcx.ws, None, &dest)?; let mut targets = HashMap::new(); if let CompileKind::Target(target) = self.bcx.build_config.requested_kind { - let layout = Layout::new(self.bcx.ws, Some(target), dest)?; + let layout = Layout::new(self.bcx.ws, Some(target), &dest)?; standard_lib::prepare_sysroot(&layout)?; targets.insert(target, layout); } diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index f65d133ecf7..289372d10f8 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -6,7 +6,7 @@ use std::str; use std::sync::Arc; use crate::core::compiler::job_queue::JobState; -use crate::core::PackageId; +use crate::core::{profiles::ProfileRoot, PackageId}; use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::machine_message::{self, Message}; use crate::util::{self, internal, paths, profile}; @@ -163,10 +163,9 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes .env("OPT_LEVEL", &unit.profile.opt_level.to_string()) .env( "PROFILE", - if bcx.build_config.release { - "release" - } else { - "debug" + match unit.profile.root { + ProfileRoot::Release => "release", + ProfileRoot::Debug => "debug", }, ) .env("HOST", &bcx.host_triple()) diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 1bc33185fcd..f7a65b963a1 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -20,6 +20,7 @@ use super::job::{ use super::standard_lib; use super::timings::Timings; use super::{BuildContext, BuildPlan, CompileMode, Context, Unit}; +use crate::core::compiler::ProfileKind; use crate::core::{PackageId, TargetKind}; use crate::handle_error; use crate::util; @@ -41,10 +42,10 @@ pub struct JobQueue<'a, 'cfg> { compiled: HashSet, documented: HashSet, counts: HashMap, - is_release: bool, progress: Progress<'cfg>, next_id: u32, timings: Timings<'a, 'cfg>, + profile_kind: ProfileKind, } pub struct JobState<'a> { @@ -145,10 +146,10 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> { compiled: HashSet::new(), documented: HashSet::new(), counts: HashMap::new(), - is_release: bcx.build_config.release, progress, next_id: 0, timings, + profile_kind: bcx.build_config.profile_kind.clone(), } } @@ -416,7 +417,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> { } self.progress.clear(); - let build_type = if self.is_release { "release" } else { "dev" }; + let build_type = self.profile_kind.name(); // NOTE: this may be a bit inaccurate, since this may not display the // profile for what was actually built. Profile overrides can change // these settings, and in some cases different targets are built with @@ -424,7 +425,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> { // list of Units built, and maybe display a list of the different // profiles used. However, to keep it simple and compatible with old // behavior, we just display what the base profile is. - let profile = cx.bcx.profiles.base_profile(self.is_release); + let profile = cx.bcx.profiles.base_profile(&self.profile_kind)?; let mut opt_type = String::from(if profile.opt_level.as_str() == "0" { "unoptimized" } else { diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 542427d9f80..ac1ef3f25f7 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -27,7 +27,7 @@ use failure::Error; use lazycell::LazyCell; use log::debug; -pub use self::build_config::{BuildConfig, CompileMode, MessageFormat}; +pub use self::build_config::{BuildConfig, CompileMode, MessageFormat, ProfileKind}; pub use self::build_context::{BuildContext, FileFlavor, TargetConfig, TargetInfo}; use self::build_plan::BuildPlan; pub use self::compilation::{Compilation, Doctest}; diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index fca77282b8b..fc874eba223 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -141,7 +141,7 @@ pub fn generate_std_roots<'a>( /*is_member*/ false, unit_for, mode, - bcx.build_config.release, + bcx.build_config.profile_kind.clone(), ); let features = std_resolve.features_sorted(pkg.package_id()); Ok(bcx.units.intern( diff --git a/src/cargo/core/compiler/timings.rs b/src/cargo/core/compiler/timings.rs index 1d0191c39c9..81ead5f353a 100644 --- a/src/cargo/core/compiler/timings.rs +++ b/src/cargo/core/compiler/timings.rs @@ -116,12 +116,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> { }) .collect(); let start_str = humantime::format_rfc3339_seconds(SystemTime::now()).to_string(); - let profile = if bcx.build_config.release { - "release" - } else { - "dev" - } - .to_string(); + let profile = bcx.build_config.profile_kind.name().to_owned(); Timings { config: bcx.config, diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index 085c41e97cc..1fb61cc5625 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -543,7 +543,7 @@ fn new_unit_dep<'a>( state.bcx.ws.is_member(pkg), unit_for, mode, - state.bcx.build_config.release, + state.bcx.build_config.profile_kind.clone(), ); new_unit_dep_with_profile(state, parent, pkg, target, unit_for, kind, mode, profile) } diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index ce29d0c5323..56d42258828 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -203,6 +203,9 @@ features! { // Specifying the 'public' attribute on dependencies [unstable] public_dependency: bool, + + // Allow to specify profiles other than 'dev', 'release', 'test', etc. + [unstable] named_profiles: bool, } } @@ -333,6 +336,7 @@ pub struct CliUnstable { pub mtime_on_use: bool, pub install_upgrade: bool, pub cache_messages: bool, + pub named_profiles: bool, pub binary_dep_depinfo: bool, pub build_std: Option>, pub timings: Option>, @@ -390,6 +394,7 @@ impl CliUnstable { "mtime-on-use" => self.mtime_on_use = true, "install-upgrade" => self.install_upgrade = true, "cache-messages" => self.cache_messages = true, + "named-profiles" => self.named_profiles = true, "binary-dep-depinfo" => self.binary_dep_depinfo = true, "build-std" => { self.build_std = Some(crate::core::compiler::standard_lib::parse_unstable_flag(v)) diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs index c7083b48ee7..7ea1cd1cf6c 100644 --- a/src/cargo/core/profiles.rs +++ b/src/cargo/core/profiles.rs @@ -1,11 +1,12 @@ use std::collections::HashSet; +use std::collections::{BTreeMap, HashMap}; use std::{cmp, env, fmt, hash}; use serde::Deserialize; -use crate::core::compiler::CompileMode; +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}; @@ -13,15 +14,13 @@ use crate::util::{closest_msg, CargoResult, Config}; /// Collection of all user profiles. #[derive(Clone, Debug)] pub struct Profiles { - dev: ProfileMaker, - release: ProfileMaker, - test: ProfileMaker, - bench: ProfileMaker, - doc: ProfileMaker, /// Incremental compilation can be overridden globally via: /// - `CARGO_INCREMENTAL` environment variable. /// - `build.incremental` config value. incremental: Option, + dir_names: HashMap, + by_name: HashMap, + named_profiles_enabled: bool, } impl Profiles { @@ -42,34 +41,266 @@ impl Profiles { None => config.get::>("build.incremental")?, }; - Ok(Profiles { - dev: ProfileMaker { + 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(), + }; + + Self::add_root_profiles(&mut profile_makers, profiles, config_profiles); + + let mut profiles = if let Some(profiles) = profiles { + profiles.get_all().clone() + } else { + BTreeMap::new() + }; + + // Merge with predefined profiles + use std::collections::btree_map::Entry; + for (predef_name, mut predef_prof) in Self::predefined_profiles().into_iter() { + match profiles.entry(predef_name.to_owned()) { + Entry::Vacant(vac) => { + vac.insert(predef_prof); + } + Entry::Occupied(mut oc) => { + // Override predefined with the user-provided Toml. + let r = oc.get_mut(); + predef_prof.merge(r); + *r = predef_prof; + } + } + } + + profile_makers.process_customs(&profiles)?; + + Ok(profile_makers) + } + + fn predefined_dir_names() -> HashMap { + let mut dir_names = HashMap::new(); + dir_names.insert("dev".to_owned(), "debug".to_owned()); + dir_names.insert("check".to_owned(), "debug".to_owned()); + dir_names.insert("test".to_owned(), "debug".to_owned()); + dir_names.insert("bench".to_owned(), "release".to_owned()); + dir_names + } + + fn add_root_profiles( + profile_makers: &mut Profiles, + profiles: Option<&TomlProfiles>, + config_profiles: &ConfigProfiles, + ) { + let profile_name = "dev"; + profile_makers.by_name.insert( + profile_name.to_owned(), + ProfileMaker { default: Profile::default_dev(), - toml: profiles.and_then(|p| p.dev.clone()), + toml: profiles.and_then(|p| p.get(profile_name).cloned()), config: config_profiles.dev.clone(), + inherits: vec![], }, - release: ProfileMaker { + ); + + let profile_name = "release"; + profile_makers.by_name.insert( + profile_name.to_owned(), + ProfileMaker { default: Profile::default_release(), - toml: profiles.and_then(|p| p.release.clone()), + toml: profiles.and_then(|p| p.get(profile_name).cloned()), config: config_profiles.release.clone(), + inherits: vec![], }, - test: ProfileMaker { - default: Profile::default_test(), - toml: profiles.and_then(|p| p.test.clone()), - config: None, - }, - bench: ProfileMaker { - default: Profile::default_bench(), - toml: profiles.and_then(|p| p.bench.clone()), - config: None, - }, - doc: ProfileMaker { - default: Profile::default_doc(), - toml: profiles.and_then(|p| p.doc.clone()), - config: None, - }, - incremental, - }) + ); + } + + fn predefined_profiles() -> Vec<(&'static str, TomlProfile)> { + vec![ + ( + "bench", + TomlProfile { + inherits: Some(String::from("release")), + ..TomlProfile::default() + }, + ), + ( + "test", + TomlProfile { + inherits: Some(String::from("dev")), + ..TomlProfile::default() + }, + ), + ( + "check", + TomlProfile { + inherits: Some(String::from("dev")), + ..TomlProfile::default() + }, + ), + ( + "doc", + TomlProfile { + inherits: Some(String::from("dev")), + ..TomlProfile::default() + }, + ), + ] + } + + fn process_customs(&mut self, profiles: &BTreeMap) -> CargoResult<()> { + for (name, profile) in profiles { + let mut set = HashSet::new(); + let mut result = Vec::new(); + + set.insert(name.as_str().to_owned()); + match &profile.dir_name { + None => {} + Some(dir_name) => { + self.dir_names.insert(name.clone(), dir_name.to_owned()); + } + } + match name.as_str() { + "dev" | "release" => { + match &profile.inherits { + None => {} + Some(_) => { + failure::bail!( + "An 'inherits' must not specified root profile '{}'", + name + ); + } + } + continue; + } + _ => {} + }; + + let mut maker = self.process_chain(name, &profile, &mut set, &mut result, profiles)?; + result.reverse(); + maker.inherits = result; + + self.by_name.insert(name.as_str().to_owned(), maker); + } + + Ok(()) + } + + fn process_chain( + &mut self, + name: &String, + profile: &TomlProfile, + set: &mut HashSet, + result: &mut Vec, + profiles: &BTreeMap, + ) -> CargoResult { + result.push(profile.clone()); + match profile.inherits.as_ref().map(|x| x.as_str()) { + Some(name @ "dev") | Some(name @ "release") => { + // These are the root profiles + return Ok(self.by_name.get(name).unwrap().clone()); + } + Some(name) => { + let name = name.to_owned(); + if set.get(&name).is_some() { + failure::bail!( + "Inheritance loop of profiles cycles with profile '{}'", + name + ); + } + + set.insert(name.clone()); + match profiles.get(&name) { + None => { + failure::bail!("Profile '{}' not found in Cargo.toml", name); + } + Some(parent) => self.process_chain(&name, parent, set, result, profiles), + } + } + None => { + failure::bail!( + "An 'inherits' directive is needed for all \ + profiles that are not 'dev' or 'release'. Here \ + it is missing from '{}'", + name + ); + } + } } /// Retrieves the profile for a target. @@ -81,31 +312,49 @@ impl Profiles { is_member: bool, unit_for: UnitFor, mode: CompileMode, - release: bool, + profile_kind: ProfileKind, ) -> Profile { - let maker = match mode { - CompileMode::Test | CompileMode::Bench => { - if release { - &self.bench - } else { - &self.test + 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, + _ => 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 { - &self.release - } else { - &self.dev + 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", } - CompileMode::Doc { .. } => &self.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); // `panic` should not be set for tests/benches, or any of their @@ -137,19 +386,37 @@ impl Profiles { /// times). pub fn get_profile_run_custom_build(&self, for_unit_profile: &Profile) -> Profile { let mut result = Profile::default(); + result.root = for_unit_profile.root; result.debuginfo = for_unit_profile.debuginfo; result.opt_level = for_unit_profile.opt_level; result } - /// This returns a generic base profile. This is currently used for the + /// This returns the base profile. This is currently used for the /// `[Finished]` line. It is not entirely accurate, since it doesn't /// select for the package that was actually built. - pub fn base_profile(&self, release: bool) -> Profile { - if release { - self.release.get_profile(None, true, UnitFor::new_normal()) + pub fn base_profile(&self, profile_kind: &ProfileKind) -> CargoResult { + let profile_name = if !self.named_profiles_enabled { + match profile_kind { + ProfileKind::Release => "release", + ProfileKind::Custom(ref s) if s == "bench" => "bench", + _ => "dev", + } } else { - self.dev.get_profile(None, true, UnitFor::new_normal()) + profile_kind.name() + }; + + match self.by_name.get(profile_name) { + None => failure::bail!("Profile `{}` undefined", profile_kind.name()), + Some(r) => Ok(r.get_profile(None, true, UnitFor::new_normal())), + } + } + + pub fn get_dir_name(&self, profile_kind: &ProfileKind) -> String { + let dest = profile_kind.name(); + match self.dir_names.get(dest) { + None => dest.to_owned(), + Some(s) => s.clone(), } } @@ -159,11 +426,9 @@ impl Profiles { shell: &mut Shell, packages: &PackageSet<'_>, ) -> CargoResult<()> { - self.dev.validate_packages(shell, packages)?; - self.release.validate_packages(shell, packages)?; - self.test.validate_packages(shell, packages)?; - self.bench.validate_packages(shell, packages)?; - self.doc.validate_packages(shell, packages)?; + for profile in self.by_name.values() { + profile.validate_packages(shell, packages)?; + } Ok(()) } } @@ -184,6 +449,11 @@ struct ProfileMaker { default: Profile, /// The profile from the `Cargo.toml` manifest. toml: Option, + + /// Profiles from which we inherit, in the order from which + /// we inherit. + inherits: Vec, + /// Profile loaded from `.cargo/config` files. config: Option, } @@ -196,12 +466,31 @@ impl ProfileMaker { unit_for: UnitFor, ) -> Profile { let mut profile = self.default; + + let mut tomls = vec![]; if let Some(ref toml) = self.toml { - merge_toml(pkg_id, is_member, unit_for, &mut profile, toml); + tomls.push(toml); } + for toml in &self.inherits { + tomls.push(toml); + } + + // First merge the profiles + for toml in &tomls { + merge_profile(&mut profile, toml); + } + + // Then their overrides + for toml in &tomls { + merge_toml_overrides(pkg_id, is_member, unit_for, &mut profile, toml); + } + + // '.cargo/config' can still overrides everything we had so far. if let Some(ref toml) = self.config { - merge_toml(pkg_id, is_member, unit_for, &mut profile, toml); + merge_profile(&mut profile, toml); + merge_toml_overrides(pkg_id, is_member, unit_for, &mut profile, toml); } + profile } @@ -308,14 +597,13 @@ impl ProfileMaker { } } -fn merge_toml( +fn merge_toml_overrides( pkg_id: Option, is_member: bool, unit_for: UnitFor, profile: &mut Profile, toml: &TomlProfile, ) { - merge_profile(profile, toml); if unit_for.is_build() { if let Some(ref build_override) = toml.build_override { merge_profile(profile, build_override); @@ -394,12 +682,19 @@ fn merge_profile(profile: &mut Profile, toml: &TomlProfile) { } } +#[derive(Clone, Copy, Eq, PartialOrd, Ord, PartialEq, Debug)] +pub enum ProfileRoot { + Release, + Debug, +} + /// Profile settings used to determine which compiler flags to use for a /// target. #[derive(Clone, Copy, Eq, PartialOrd, Ord)] pub struct Profile { pub name: &'static str, pub opt_level: InternedString, + pub root: ProfileRoot, pub lto: Lto, // `None` means use rustc default. pub codegen_units: Option, @@ -416,6 +711,7 @@ impl Default for Profile { Profile { name: "", opt_level: InternedString::new("0"), + root: ProfileRoot::Debug, lto: Lto::Bool(false), codegen_units: None, debuginfo: None, @@ -434,15 +730,13 @@ compact_debug! { let (default, default_name) = match self.name { "dev" => (Profile::default_dev(), "default_dev()"), "release" => (Profile::default_release(), "default_release()"), - "test" => (Profile::default_test(), "default_test()"), - "bench" => (Profile::default_bench(), "default_bench()"), - "doc" => (Profile::default_doc(), "default_doc()"), _ => (Profile::default(), "default()"), }; [debug_the_fields( name opt_level lto + root codegen_units debuginfo debug_assertions @@ -480,6 +774,7 @@ impl Profile { fn default_dev() -> Profile { Profile { name: "dev", + root: ProfileRoot::Debug, debuginfo: Some(2), debug_assertions: true, overflow_checks: true, @@ -491,11 +786,14 @@ impl Profile { fn default_release() -> Profile { Profile { name: "release", + root: ProfileRoot::Release, opt_level: InternedString::new("3"), ..Profile::default() } } + // NOTE: Remove the following three once `named_profiles` is default: + fn default_test() -> Profile { Profile { name: "test", diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 7adc7d2fe07..c6b937f1e7b 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -4,7 +4,9 @@ use std::path::Path; use crate::core::compiler::unit_dependencies; use crate::core::compiler::UnitInterner; -use crate::core::compiler::{BuildConfig, BuildContext, CompileKind, CompileMode, Context}; +use crate::core::compiler::{ + BuildConfig, BuildContext, CompileKind, CompileMode, Context, ProfileKind, +}; use crate::core::profiles::UnitFor; use crate::core::Workspace; use crate::ops; @@ -19,7 +21,9 @@ pub struct CleanOptions<'a> { /// The target arch triple to clean, or None for the host arch pub target: Option, /// Whether to clean the release directory - pub release: bool, + pub profile_specified: bool, + /// Whether to clean the directory of a certain build profile + pub profile_kind: ProfileKind, /// Whether to just clean the doc directory pub doc: bool, } @@ -35,9 +39,18 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { return rm_rf(&target_dir.into_path_unlocked(), config); } - // If the release option is set, we set target to release directory - if opts.release { - target_dir = target_dir.join("release"); + let (packages, resolve) = ops::resolve_ws(ws)?; + let profiles = ws.profiles(); + + // Check for whether the profile is defined. + let _ = profiles.base_profile(&opts.profile_kind)?; + + if opts.profile_specified { + // After parsing profiles we know the dir-name of the profile, if a profile + // was passed from the command line. If so, delete only the directory of + // that profile. + let dir_name = profiles.get_dir_name(&opts.profile_kind); + target_dir = target_dir.join(dir_name); } // If we have a spec, then we need to delete some packages, otherwise, just @@ -49,12 +62,10 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { return rm_rf(&target_dir.into_path_unlocked(), config); } - let (packages, resolve) = ops::resolve_ws(ws)?; - - let profiles = ws.profiles(); let interner = UnitInterner::new(); let mut build_config = BuildConfig::new(config, Some(1), &opts.target, CompileMode::Build)?; - build_config.release = opts.release; + let profile_kind = opts.profile_kind.clone(); + build_config.profile_kind = profile_kind.clone(); let bcx = BuildContext::new( ws, &packages, @@ -82,7 +93,7 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { ws.is_member(pkg), *unit_for, CompileMode::Build, - opts.release, + profile_kind.clone(), )) } else { profiles.get_profile( @@ -90,7 +101,7 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { ws.is_member(pkg), *unit_for, *mode, - opts.release, + profile_kind.clone(), ) }; let features = resolve.features_sorted(pkg.package_id()); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 8233f6ceaeb..9895adef2cf 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -296,6 +296,9 @@ pub fn compile_ws<'a>( let profiles = ws.profiles(); + // Early check for whether the profile is defined. + let _ = profiles.base_profile(&build_config.profile_kind)?; + let specs = spec.to_package_id_specs(ws)?; let dev_deps = ws.require_optional_deps() || filter.need_dev_deps(build_config.mode); let opts = ResolveOpts::new(dev_deps, features, all_features, !no_default_features); @@ -699,7 +702,7 @@ fn generate_targets<'a>( ws.is_member(pkg), unit_for, target_mode, - bcx.build_config.release, + bcx.build_config.profile_kind.clone(), ); let features = resolve.features_sorted(pkg.package_id()); bcx.units.intern( diff --git a/src/cargo/ops/common_for_install_and_uninstall.rs b/src/cargo/ops/common_for_install_and_uninstall.rs index af79e551311..3fec1ee436c 100644 --- a/src/cargo/ops/common_for_install_and_uninstall.rs +++ b/src/cargo/ops/common_for_install_and_uninstall.rs @@ -455,7 +455,7 @@ impl CrateListingV2 { info.features = feature_set(&opts.features); info.all_features = opts.all_features; info.no_default_features = opts.no_default_features; - info.profile = profile_name(opts.build_config.release).to_string(); + info.profile = opts.build_config.profile_name().to_string(); info.target = Some(target.to_string()); info.rustc = Some(rustc.to_string()); } else { @@ -467,7 +467,7 @@ impl CrateListingV2 { features: feature_set(&opts.features), all_features: opts.all_features, no_default_features: opts.no_default_features, - profile: profile_name(opts.build_config.release).to_string(), + profile: opts.build_config.profile_name().to_string(), target: Some(target.to_string()), rustc: Some(rustc.to_string()), other: BTreeMap::new(), @@ -527,7 +527,7 @@ impl InstallInfo { self.features == feature_set(&opts.features) && self.all_features == opts.all_features && self.no_default_features == opts.no_default_features - && self.profile == profile_name(opts.build_config.release) + && self.profile == opts.build_config.profile_name().to_string() && (self.target.is_none() || self.target.as_ref().map(|t| t.as_ref()) == Some(target)) && &self.bins == exes } @@ -720,14 +720,6 @@ where } } -fn profile_name(release: bool) -> &'static str { - if release { - "release" - } else { - "dev" - } -} - /// Helper to convert features Vec to a BTreeSet. fn feature_set(features: &[String]) -> BTreeSet { features.iter().cloned().collect() diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index a403c7efaab..2d0a9b3fc5e 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -3,7 +3,7 @@ use crate::core::Workspace; use crate::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl}; use crate::sources::CRATES_IO_REGISTRY; use crate::util::important_paths::find_root_manifest_for_wd; -use crate::util::{paths, validate_package_name}; +use crate::util::{paths, toml::TomlProfile, validate_package_name}; use crate::util::{ print_available_benches, print_available_binaries, print_available_examples, print_available_tests, @@ -15,7 +15,7 @@ use std::ffi::{OsStr, OsString}; use std::fs; use std::path::PathBuf; -pub use crate::core::compiler::CompileMode; +pub use crate::core::compiler::{CompileMode, ProfileKind}; pub use crate::{CliError, CliResult, Config}; pub use clap::{AppSettings, Arg, ArgMatches}; @@ -116,6 +116,10 @@ pub trait AppExt: Sized { self._arg(opt("release", release)) } + fn arg_profile(self, profile: &'static str) -> Self { + self._arg(opt("profile", profile).value_name("PROFILE-NAME")) + } + fn arg_doc(self, doc: &'static str) -> Self { self._arg(opt("doc", doc)) } @@ -232,6 +236,12 @@ pub fn subcommand(name: &'static str) -> App { ]) } +// Determines whether or not to gate `--profile` as unstable when resolving it. +pub enum ProfileChecking { + Checked, + Unchecked, +} + pub trait ArgMatchesExt { fn value_of_u32(&self, name: &str) -> CargoResult> { let arg = match self._value_of(name) { @@ -284,11 +294,54 @@ pub trait ArgMatchesExt { self._value_of("target").map(|s| s.to_string()) } + fn get_profile_kind( + &self, + config: &Config, + default: ProfileKind, + profile_checking: ProfileChecking, + ) -> CargoResult { + let specified_profile = match self._value_of("profile") { + None => None, + Some("dev") => Some(ProfileKind::Dev), + Some("release") => Some(ProfileKind::Release), + Some(name) => { + TomlProfile::validate_name(name, "profile name")?; + Some(ProfileKind::Custom(name.to_string())) + } + }; + + match profile_checking { + ProfileChecking::Unchecked => {} + ProfileChecking::Checked => { + if specified_profile.is_some() { + if !config.cli_unstable().unstable_options { + failure::bail!("Usage of `--profile` requires `-Z unstable-options`") + } + } + } + } + + if self._is_present("release") { + match specified_profile { + None | Some(ProfileKind::Release) => Ok(ProfileKind::Release), + _ => failure::bail!("Conflicting usage of --profile and --release"), + } + } else if self._is_present("debug") { + match specified_profile { + None | Some(ProfileKind::Dev) => Ok(ProfileKind::Dev), + _ => failure::bail!("Conflicting usage of --profile and --debug"), + } + } else { + Ok(specified_profile.unwrap_or(default)) + } + } + fn compile_options<'a>( &self, config: &'a Config, mode: CompileMode, workspace: Option<&Workspace<'a>>, + profile_checking: ProfileChecking, ) -> CargoResult> { let spec = Packages::from_flags( // TODO Integrate into 'workspace' @@ -361,7 +414,8 @@ pub trait ArgMatchesExt { let mut build_config = BuildConfig::new(config, self.jobs()?, &self.target(), mode)?; build_config.message_format = message_format.unwrap_or(MessageFormat::Human); - build_config.release = self._is_present("release"); + build_config.profile_kind = + self.get_profile_kind(config, ProfileKind::Dev, profile_checking)?; build_config.build_plan = self._is_present("build-plan"); if build_config.build_plan { config @@ -406,8 +460,9 @@ pub trait ArgMatchesExt { config: &'a Config, mode: CompileMode, workspace: Option<&Workspace<'a>>, + profile_checking: ProfileChecking, ) -> CargoResult> { - let mut compile_opts = self.compile_options(config, mode, workspace)?; + let mut compile_opts = self.compile_options(config, mode, workspace, profile_checking)?; compile_opts.spec = Packages::Packages(self._values_of("package")); Ok(compile_opts) } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 922ff7959f0..d69831752c8 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -68,7 +68,7 @@ fn do_read_manifest( let add_unused = |warnings: &mut Warnings| { for key in unused { warnings.add_warning(format!("unused manifest key: {}", key)); - if key == "profile.debug" || key == "profiles.debug" { + if key == "profiles.debug" { warnings.add_warning("use `[profile.dev]` to configure debug builds".to_string()); } } @@ -270,30 +270,24 @@ pub struct TomlManifest { } #[derive(Deserialize, Serialize, Clone, Debug, Default)] -pub struct TomlProfiles { - pub test: Option, - pub doc: Option, - pub bench: Option, - pub dev: Option, - pub release: Option, -} +pub struct TomlProfiles(BTreeMap); impl TomlProfiles { + pub fn get_all(&self) -> &BTreeMap { + &self.0 + } + + pub fn get(&self, name: &'static str) -> Option<&TomlProfile> { + self.0.get(&String::from(name)) + } + pub fn validate(&self, features: &Features, warnings: &mut Vec) -> CargoResult<()> { - if let Some(ref test) = self.test { - test.validate("test", features, warnings)?; - } - if let Some(ref doc) = self.doc { - doc.validate("doc", features, warnings)?; - } - if let Some(ref bench) = self.bench { - bench.validate("bench", features, warnings)?; - } - if let Some(ref dev) = self.dev { - dev.validate("dev", features, warnings)?; - } - if let Some(ref release) = self.release { - release.validate("release", features, warnings)?; + for (name, profile) in &self.0 { + if name == "debug" { + warnings.push("use `[profile.dev]` to configure debug builds".to_string()); + } + + profile.validate(&name, features, warnings)?; } Ok(()) } @@ -416,6 +410,8 @@ pub struct TomlProfile { pub incremental: Option, pub overrides: Option>, pub build_override: Option>, + pub dir_name: Option, + pub inherits: Option, } #[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)] @@ -470,16 +466,39 @@ impl TomlProfile { } } + // Feature gate definition of named profiles match name { - "dev" | "release" => {} + "dev" | "release" | "bench" | "test" | "doc" => {} _ => { - if self.overrides.is_some() || self.build_override.is_some() { - bail!( - "Profile overrides may only be specified for \ - `dev` or `release` profile, not `{}`.", - name - ); - } + features.require(Feature::named_profiles())?; + } + } + + // Profile name validation + Self::validate_name(name, "profile name")?; + + // Feature gate on uses of keys related to named profiles + if self.inherits.is_some() { + features.require(Feature::named_profiles())?; + } + + if self.dir_name.is_some() { + features.require(Feature::named_profiles())?; + } + + // `dir-name` validation + match &self.dir_name { + None => {} + Some(dir_name) => { + Self::validate_name(&dir_name, "dir-name")?; + } + } + + // `inherits` validation + match &self.inherits { + None => {} + Some(inherits) => { + Self::validate_name(&inherits, "inherits")?; } } @@ -507,6 +526,35 @@ impl TomlProfile { Ok(()) } + /// Validate dir-names and profile names according to RFC 2678. + pub fn validate_name(name: &str, what: &str) -> CargoResult<()> { + if let Some(ch) = name + .chars() + .find(|ch| !ch.is_alphanumeric() && *ch != '_' && *ch != '-') + { + failure::bail!("Invalid character `{}` in {}: `{}`", ch, what, name); + } + + match name { + "package" | "build" => { + failure::bail!("Invalid {}: `{}`", what, name); + } + "debug" if what == "profile" => { + if what == "profile name" { + // Allowed, but will emit warnings + } else { + failure::bail!("Invalid {}: `{}`", what, name); + } + } + "doc" if what == "dir-name" => { + failure::bail!("Invalid {}: `{}`", what, name); + } + _ => {} + } + + Ok(()) + } + fn validate_override(&self) -> CargoResult<()> { if self.overrides.is_some() || self.build_override.is_some() { bail!("Profile overrides cannot be nested."); @@ -522,6 +570,60 @@ impl TomlProfile { } Ok(()) } + + pub fn merge(&mut self, profile: &TomlProfile) { + if let Some(v) = &profile.opt_level { + self.opt_level = Some(v.clone()); + } + + if let Some(v) = &profile.lto { + self.lto = Some(v.clone()); + } + + if let Some(v) = profile.codegen_units { + self.codegen_units = Some(v.clone()); + } + + if let Some(v) = &profile.debug { + self.debug = Some(v.clone()); + } + + if let Some(v) = profile.debug_assertions { + self.debug_assertions = Some(v.clone()); + } + + if let Some(v) = profile.rpath { + self.rpath = Some(v.clone()); + } + + if let Some(v) = &profile.panic { + self.panic = Some(v.clone()); + } + + if let Some(v) = profile.overflow_checks { + self.overflow_checks = Some(v.clone()); + } + + if let Some(v) = profile.incremental { + self.incremental = Some(v.clone()); + } + + if let Some(v) = &profile.overrides { + self.overrides = Some(v.clone()); + } + + if let Some(v) = &profile.build_override { + self.build_override = Some(v.clone()); + } + + if let Some(v) = &profile.inherits { + self.inherits = Some(v.clone()); + } + + if let Some(v) = &profile.dir_name { + self.dir_name = Some(v.clone()); + } + } } #[derive(Clone, Debug, Serialize, Eq, PartialEq)] diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index 7071645ecec..7509a58c446 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -119,7 +119,66 @@ opt-level = 2 opt-level = 3 ``` -Overrides can only be specified for dev and release profiles. +Overrides can be specified for any profile, including custom named profiles. + + +### Custom named profiles + +* Tracking Issue: [rust-lang/cargo#6988](https://github.com/rust-lang/cargo/issues/6988) +* RFC: [#2678](https://github.com/rust-lang/rfcs/pull/2678) + +With this feature you can define custom profiles having new names. With the +custom profile enabled, build artifacts can be emitted by default to +directories other than `release` or `debug`, based on the custom profile's +name. + +For example: + +```toml +cargo-features = ["named-profiles"] + +[profile.release-lto] +inherits = "release" +lto = true +```` + +An `inherits` key is used in order to receive attributes from other profiles, +so that a new custom profile can be based on the standard `dev` or `release` +profile presets. Cargo emits errors in case `inherits` loops are detected. When +considering inheritance hierarchy, all profiles directly or indirectly inherit +from either from `release` or from `dev`. + +Valid profile names are: must not be empty, use only alphanumeric characters or +`-` or `_`. + +Passing `--profile` with the profile's name to various Cargo commands, directs +operations to use the profile's attributes. Overrides that are specified in the +profiles from which the custom profile inherits are inherited too. + +For example, using `cargo build` with `--profile` and the manifest from above: + +``` +cargo +nightly build --profile release-lto -Z unstable-options +``` + +When a custom profile is used, build artifcats go to a different target by +default. In the example above, you can expect to see the outputs under +`target/release-lto`. + + +#### New `dir-name` attribute + +Some of the paths generated under `target/` have resulted in a de-facto "build +protocol", where `cargo` is invoked as a part of a larger project build. So, to +preserve the existing behavior, there is also a new attribute `dir-name`, which +when left unspecified, defaults to the name of the profile. For example: + +```toml +[profile.release-lto] +inherits = "release" +dir-name = "lto" # Emits to target/lto instead of target/release-lto +lto = true +``` ### Config Profiles diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index e932b68a353..eb522c0ba87 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -692,6 +692,8 @@ warning: unused manifest key: target.foo.bar .file( "Cargo.toml", r#" + cargo-features = ["named-profiles"] + [package] name = "foo" version = "0.1.0" @@ -699,21 +701,26 @@ warning: unused manifest key: target.foo.bar [profile.debug] debug = 1 + inherits = "dev" "#, ) .file("src/lib.rs", "") .build(); - p.cargo("build") + p.cargo("build -Z named-profiles") + .masquerade_as_nightly_cargo() .with_stderr( "\ -warning: unused manifest key: profile.debug warning: use `[profile.dev]` to configure debug builds [..] [..]", ) .run(); + p.cargo("build -Z named-profiles") + .masquerade_as_nightly_cargo() + .run(); + let p = project() .file( "Cargo.toml", diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 17574dc91f9..d3d5bb93bda 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -41,7 +41,7 @@ fn cargo_bench_simple() { .with_stderr( "\ [COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench_hello ... bench: [..]") @@ -84,7 +84,7 @@ fn bench_bench_implicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/mybench-[..][EXE] ", @@ -129,7 +129,7 @@ fn bench_bin_implicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] ", ) @@ -164,7 +164,7 @@ fn bench_tarname() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/bin2-[..][EXE] ", ) @@ -234,7 +234,7 @@ fn cargo_bench_verbose() { "\ [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc [..] src/main.rs [..]` -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] hello --bench`", ) .with_stdout_contains("test bench_hello ... bench: [..]") @@ -328,7 +328,7 @@ fn cargo_bench_failing_test() { .with_stderr_contains( "\ [COMPILING] foo v0.5.0 ([CWD])[..] -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_either_contains( @@ -400,7 +400,7 @@ fn bench_with_lib_dep() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/baz-[..][EXE]", ) @@ -465,7 +465,7 @@ fn bench_with_deep_lib_dep() { "\ [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/bar-[..][EXE]", ) .with_stdout_contains("test bar_bench ... bench: [..]") @@ -522,7 +522,7 @@ fn external_bench_explicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/bench-[..][EXE]", ) @@ -569,7 +569,7 @@ fn external_bench_implicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/external-[..][EXE]", ) @@ -645,7 +645,7 @@ automatically infer them to be a target, such as in subfolders. For more information on this warning you can consult https://github.com/rust-lang/cargo/issues/5330 [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] ", ) @@ -692,7 +692,7 @@ fn pass_through_command_line() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bar ... bench: [..]") @@ -700,7 +700,7 @@ fn pass_through_command_line() { p.cargo("bench foo") .with_stderr( - "[FINISHED] release [optimized] target(s) in [..] + "[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test foo ... bench: [..]") @@ -785,7 +785,7 @@ fn lib_bin_same_name() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/foo-[..][EXE]", ) @@ -834,7 +834,7 @@ fn lib_with_standard_name() { .with_stderr( "\ [COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/syntax-[..][EXE] [RUNNING] target/release/deps/bench-[..][EXE]", ) @@ -886,7 +886,7 @@ fn lib_with_standard_name2() { .with_stderr( "\ [COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/syntax-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -966,7 +966,7 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", ) @@ -979,7 +979,7 @@ fn bench_dylib() { "\ [FRESH] bar v0.0.1 ([CWD]/bar) [FRESH] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", ) @@ -1021,7 +1021,7 @@ fn bench_twice_with_build_cmd() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test foo ... bench: [..]") @@ -1029,7 +1029,7 @@ fn bench_twice_with_build_cmd() { p.cargo("bench") .with_stderr( - "[FINISHED] release [optimized] target(s) in [..] + "[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test foo ... bench: [..]") @@ -1114,7 +1114,7 @@ fn bench_with_examples() { [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] `[CWD]/target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[CWD]/target/release/deps/testb1-[..][EXE] --bench`", ) @@ -1156,7 +1156,7 @@ fn test_a_bench() { .with_stderr( "\ [COMPILING] foo v0.1.0 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/b-[..][EXE]", ) .with_stdout_contains("test foo ... ok") @@ -1190,7 +1190,7 @@ fn test_bench_no_run() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] ", ) .run(); diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index dd92d73d527..76b36b66221 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -810,7 +810,7 @@ fn testing_and_such() { [RUNNING] `[..]/build-script-build` [RUNNING] `rustc --crate-name foo [..]` [RUNNING] `rustc --crate-name foo [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..]`", @@ -1907,7 +1907,7 @@ fn cfg_test() { [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]` [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo @@ -2018,7 +2018,7 @@ fn cfg_override_test() { [RUNNING] `[..]` [RUNNING] `[..]` [RUNNING] `[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]` [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo @@ -2154,7 +2154,7 @@ fn env_test() { [RUNNING] [..] --crate-name foo[..] [RUNNING] [..] --crate-name foo[..] [RUNNING] [..] --crate-name test[..] -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]` [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo @@ -2255,7 +2255,7 @@ fn flags_go_into_tests() { [COMPILING] foo v0.5.0 ([..] [RUNNING] `rustc [..] src/lib.rs [..] -L test[..]` [RUNNING] `rustc [..] tests/foo.rs [..] -L test[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]`", ) .with_stdout_contains("running 0 tests") @@ -2267,7 +2267,7 @@ fn flags_go_into_tests() { [FRESH] a v0.5.0 ([..] [COMPILING] b v0.5.0 ([..] [RUNNING] `rustc [..] b/src/lib.rs [..] -L test[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/b-[..][EXE]`", ) .with_stdout_contains("running 0 tests") diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index d65fe7a9af0..4d4d14ff2ff 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -304,6 +304,11 @@ opt-level = 1 [profile.dev.overrides.bar] codegen-units = 9 + +[profile.no-lto] +inherits = 'dev' +dir-name = 'without-lto' +lto = false ", ); @@ -320,31 +325,14 @@ codegen-units = 9 let key = toml::ProfilePackageSpec::Spec(::cargo::core::PackageIdSpec::parse("bar").unwrap()); let o_profile = toml::TomlProfile { opt_level: Some(toml::TomlOptLevel("2".to_string())), - lto: None, codegen_units: Some(9), - debug: None, - debug_assertions: None, - rpath: None, - panic: None, - overflow_checks: None, - incremental: None, - overrides: None, - build_override: None, + ..Default::default() }; overrides.insert(key, o_profile); let key = toml::ProfilePackageSpec::Spec(::cargo::core::PackageIdSpec::parse("env").unwrap()); let o_profile = toml::TomlProfile { - opt_level: None, - lto: None, codegen_units: Some(13), - debug: None, - debug_assertions: None, - rpath: None, - panic: None, - overflow_checks: None, - incremental: None, - overrides: None, - build_override: None, + ..Default::default() }; overrides.insert(key, o_profile); @@ -363,17 +351,21 @@ codegen-units = 9 overrides: Some(overrides), build_override: Some(Box::new(toml::TomlProfile { opt_level: Some(toml::TomlOptLevel("1".to_string())), - lto: None, codegen_units: Some(11), - debug: None, - debug_assertions: None, - rpath: None, - panic: None, - overflow_checks: None, - incremental: None, - overrides: None, - build_override: None - })) + ..Default::default() + })), + ..Default::default() + } + ); + + let p: toml::TomlProfile = config.get("profile.no-lto").unwrap(); + assert_eq!( + p, + toml::TomlProfile { + lto: Some(toml::StringOrBool::Bool(false)), + dir_name: Some("without-lto".to_string()), + inherits: Some("dev".to_string()), + ..Default::default() } ); } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 671afe7003a..1a0a839412d 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -533,7 +533,7 @@ fn cross_tests() { .with_stderr(&format!( "\ [COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/{triple}/debug/deps/foo-[..][EXE] [RUNNING] target/{triple}/debug/deps/bar-[..][EXE]", triple = target @@ -563,7 +563,7 @@ fn no_cross_doctests() { let host_output = "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo "; @@ -578,7 +578,7 @@ fn no_cross_doctests() { .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/{triple}/debug/deps/foo-[..][EXE] [DOCTEST] foo ", @@ -593,7 +593,7 @@ fn no_cross_doctests() { .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/{triple}/debug/deps/foo-[..][EXE] ", triple = target @@ -1221,7 +1221,7 @@ fn cross_test_dylib() { "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/{arch}/debug/deps/foo-[..][EXE] [RUNNING] target/{arch}/debug/deps/test-[..][EXE]", arch = cross_compile::alternate() diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 7b4d0631a9f..cf500971b17 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -231,7 +231,7 @@ fn changing_profiles_caches_targets() { .with_stderr( "\ [..]Compiling foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] [DOCTEST] foo ", @@ -247,7 +247,7 @@ fn changing_profiles_caches_targets() { p.cargo("test foo") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] ", ) @@ -572,7 +572,7 @@ fn no_rebuild_transitive_target_deps() { [COMPILING] c v0.0.1 ([..]) [COMPILING] b v0.0.1 ([..]) [COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 523fbb79434..3b81677d93b 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -1299,7 +1299,7 @@ fn dev_deps_with_testing() { "\ [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..] -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test tests::foo ... ok") diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 2e28305d137..75048c5378a 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -68,6 +68,7 @@ mod path; mod plugins; mod proc_macro; mod profile_config; +mod profile_custom; mod profile_overrides; mod profile_targets; mod profiles; diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 362531ee592..d983b7c29f4 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -186,7 +186,7 @@ fn cargo_compile_with_root_dev_deps_with_testing() { "\ [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("running 0 tests") @@ -782,7 +782,7 @@ fn dev_deps_no_rebuild_lib() { "\ [COMPILING] [..] v0.5.0 ([CWD][..]) [COMPILING] [..] v0.5.0 ([CWD][..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("running 0 tests") diff --git a/tests/testsuite/profile_custom.rs b/tests/testsuite/profile_custom.rs new file mode 100644 index 00000000000..9fcb43f831c --- /dev/null +++ b/tests/testsuite/profile_custom.rs @@ -0,0 +1,477 @@ +use cargo_test_support::{basic_lib_manifest, project}; + +#[cargo_test] +fn inherits_on_release() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release] + inherits = "dev" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + An 'inherits' must not specified root profile 'release' +", + ) + .run(); +} + +#[cargo_test] +fn missing_inherits() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release-lto] + codegen-units = 7 + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + An 'inherits' directive is needed for all profiles that are not 'dev' or 'release'. Here it is missing from 'release-lto'", + ) + .run(); +} + +#[cargo_test] +fn invalid_profile_name() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.'.release-lto'] + inherits = "release" + codegen-units = 7 + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Invalid character `.` in profile name: `.release-lto`", + ) + .run(); +} + +#[cargo_test] +fn invalid_dir_name() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.'release-lto'] + inherits = "release" + dir-name = ".subdir" + codegen-units = 7 + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Invalid character `.` in dir-name: `.subdir`", + ) + .run(); +} + +#[cargo_test] +fn invalid_inherits() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.'release-lto'] + inherits = ".release" + codegen-units = 7 + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Invalid character `.` in inherits: `.release`", + ) + .run(); +} + +#[cargo_test] +fn non_existent_inherits() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release-lto] + codegen-units = 7 + inherits = "non-existent" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Profile 'non-existent' not found in Cargo.toml", + ) + .run(); +} + +#[cargo_test] +fn self_inherits() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release-lto] + codegen-units = 7 + inherits = "release-lto" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Inheritance loop of profiles cycles with profile 'release-lto'", + ) + .run(); +} + +#[cargo_test] +fn inherits_loop() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release-lto] + codegen-units = 7 + inherits = "release-lto2" + + [profile.release-lto2] + codegen-units = 7 + inherits = "release-lto" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at [..] + +Caused by: + Inheritance loop of profiles cycles with profile 'release-lto'", + ) + .run(); +} + +#[cargo_test] +fn overrides_with_custom() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["profile-overrides", "named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + xxx = {path = "xxx"} + yyy = {path = "yyy"} + + [profile.dev] + codegen-units = 7 + + [profile.dev.overrides.xxx] + codegen-units = 5 + [profile.dev.overrides.yyy] + codegen-units = 3 + + [profile.other] + inherits = "dev" + codegen-units = 2 + + [profile.other.overrides.yyy] + codegen-units = 6 + "#, + ) + .file("src/lib.rs", "") + .file("xxx/Cargo.toml", &basic_lib_manifest("xxx")) + .file("xxx/src/lib.rs", "") + .file("yyy/Cargo.toml", &basic_lib_manifest("yyy")) + .file("yyy/src/lib.rs", "") + .build(); + + // profile overrides are inherited between profiles using inherits and have a + // higher priority than profile options provided by custom profiles + p.cargo("build -v") + .masquerade_as_nightly_cargo() + .with_stderr_unordered( + "\ +[COMPILING] xxx [..] +[COMPILING] yyy [..] +[COMPILING] foo [..] +[RUNNING] `rustc --crate-name xxx [..] -C codegen-units=5 [..]` +[RUNNING] `rustc --crate-name yyy [..] -C codegen-units=3 [..]` +[RUNNING] `rustc --crate-name foo [..] -C codegen-units=7 [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); + + // This also verifies that the custom profile names appears in the finished line. + p.cargo("build --profile=other -Z unstable-options -v") + .masquerade_as_nightly_cargo() + .with_stderr_unordered( + "\ +[COMPILING] xxx [..] +[COMPILING] yyy [..] +[COMPILING] foo [..] +[RUNNING] `rustc --crate-name xxx [..] -C codegen-units=5 [..]` +[RUNNING] `rustc --crate-name yyy [..] -C codegen-units=6 [..]` +[RUNNING] `rustc --crate-name foo [..] -C codegen-units=2 [..]` +[FINISHED] other [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn conflicting_usage() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build -Z unstable-options --profile=dev --release") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr_unordered("error: Conflicting usage of --profile and --release") + .run(); + + p.cargo("install -Z unstable-options --profile=release --debug") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr_unordered("error: Conflicting usage of --profile and --debug") + .run(); +} + +#[cargo_test] +fn clean_custom_dirname() { + let p = project() + .file( + "Cargo.toml", + r#" + cargo-features = ["named-profiles"] + + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.other] + inherits = "release" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("build --release") + .masquerade_as_nightly_cargo() + .with_stdout("") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([..]) +[FINISHED] release [optimized] target(s) in [..] +", + ) + .run(); + + p.cargo("clean -p foo").masquerade_as_nightly_cargo().run(); + + p.cargo("build --release") + .masquerade_as_nightly_cargo() + .with_stdout("") + .with_stderr( + "\ +[FINISHED] release [optimized] target(s) in [..] +", + ) + .run(); + + p.cargo("clean -p foo --release") + .masquerade_as_nightly_cargo() + .run(); + + p.cargo("build --release") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([..]) +[FINISHED] release [optimized] target(s) in [..] +", + ) + .run(); + + p.cargo("build") + .masquerade_as_nightly_cargo() + .with_stdout("") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([..]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); + + p.cargo("build -Z unstable-options --profile=other") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([..]) +[FINISHED] other [optimized] target(s) in [..] +", + ) + .run(); + + p.cargo("clean") + .arg("--release") + .masquerade_as_nightly_cargo() + .run(); + + // Make sure that 'other' was not cleaned + assert!(p.build_dir().is_dir()); + assert!(p.build_dir().join("debug").is_dir()); + assert!(p.build_dir().join("other").is_dir()); + assert!(!p.build_dir().join("release").is_dir()); + + // This should clean 'other' + p.cargo("clean -Z unstable-options --profile=other") + .masquerade_as_nightly_cargo() + .with_stderr("") + .run(); + assert!(p.build_dir().join("debug").is_dir()); + assert!(!p.build_dir().join("other").is_dir()); +} diff --git a/tests/testsuite/profile_overrides.rs b/tests/testsuite/profile_overrides.rs index a3f867a64da..fd9124ad69b 100644 --- a/tests/testsuite/profile_overrides.rs +++ b/tests/testsuite/profile_overrides.rs @@ -149,42 +149,6 @@ fn profile_override_warnings() { .run(); } -#[cargo_test] -fn profile_override_dev_release_only() { - let p = project() - .file( - "Cargo.toml", - r#" - cargo-features = ["profile-overrides"] - - [package] - name = "foo" - version = "0.0.1" - - [dependencies] - bar = {path = "bar"} - - [profile.test.overrides.bar] - opt-level = 3 - "#, - ) - .file("src/lib.rs", "") - .file("bar/Cargo.toml", &basic_lib_manifest("bar")) - .file("bar/src/lib.rs", "") - .build(); - - p.cargo("build") - .masquerade_as_nightly_cargo() - .with_status(101) - .with_stderr_contains( - "\ -Caused by: - Profile overrides may only be specified for `dev` or `release` profile, not `test`. -", - ) - .run(); -} - #[cargo_test] fn profile_override_bad_settings() { let bad_values = [ diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 0532656a35c..2fc76b66775 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -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. @@ -157,13 +169,13 @@ fn profile_selection_build_all_targets() { // ------ ------- ---- // lib dev+panic build (a normal lib target) // lib dev-panic build (used by tests/benches) - // lib test test - // test test test - // bench test test - // bin test test + // lib 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=3 -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=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 bench1 benches/bench1.rs [..]--emit=[..]link -C codegen-units=3 -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. @@ -222,13 +236,13 @@ fn profile_selection_build_all_targets_release() { // ------ ------- ---- // lib release+panic build (a normal lib target) // lib release-panic build (used by tests/benches) - // lib bench test (bench/test de-duped) - // test bench test - // bench bench test - // bin bench test (bench/test de-duped) + // lib release test (bench/test de-duped) + // test release test + // bench release test + // 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=4 --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=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 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,58 +278,60 @@ 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: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib dev For foo-bin - // bar lib dev-panic For tests/benches and bdep - // bdep lib dev-panic For foo build.rs - // foo custom dev-panic + // bar lib test For foo-bin + // bar lib test-panic For tests/benches and bdep + // bdep lib test-panic For foo build.rs + // foo custom test-panic // // - `foo` target list is: // Target Profile Mode // ------ ------- ---- - // lib dev-panic build (for tests) - // lib dev build (for bins) + // lib test-panic build (for tests) + // lib test build (for bins) // lib test test // test test test - // example dev-panic build + // example test-panic build // bin test test - // bin dev build + // 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=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 [..] +[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=1 -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=1 -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=1 -C debuginfo=2 [..] -[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/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=1 -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=1 -C debuginfo=2 [..] -[FINISHED] dev [unoptimized + debuginfo] [..] +[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 [..] [FRESH] bdep [..] [FRESH] foo [..] -[FINISHED] dev [unoptimized + debuginfo] [..] +[FINISHED] test [unoptimized + debuginfo] [..] [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/test1-[..]` @@ -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: @@ -343,13 +362,13 @@ fn profile_selection_test_release() { // ------ ------- ---- // lib release-panic build (for tests) // lib release build (for bins) - // lib bench test - // test bench test + // lib release test + // test release test // example release-panic build - // bin bench test + // 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=4 --test [..] -[RUNNING] `[..] rustc --crate-name test1 tests/test1.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/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,55 +413,57 @@ 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: // - Dependency profiles: // Pkg Target Profile Reason // --- ------ ------- ------ - // bar lib release For foo-bin - // bar lib release-panic For tests/benches and bdep - // bdep lib release-panic For foo build.rs - // foo custom release-panic + // bar lib bench For foo-bin + // bar lib bench-panic For tests/benches and bdep + // bdep lib bench-panic For foo build.rs + // foo custom bench-panic // // - `foo` target list is: // Target Profile Mode // ------ ------- ---- - // lib release-panic build (for benches) - // lib release build (for bins) + // lib bench-panic build (for benches) + // lib bench build (for bins) // lib bench test(bench) // bench bench test(bench) // bin bench test(bench) - // bin release build + // 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=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 [..] +[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=2 [..] +[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=2 [..] +[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=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 [..]--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=2 [..] -[FINISHED] release [optimized] [..] +[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 [..] [FRESH] bdep [..] [FRESH] foo [..] -[FINISHED] release [optimized] [..] +[FINISHED] bench [optimized] [..] [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/bench1-[..] --bench` @@ -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,56 +584,56 @@ 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` - // NOTES: - // - This doesn't actually use the "test" profile. Everything uses "dev". - // It should probably use "test", although it probably doesn't really matter. // - Dependency profiles: // Pkg Target Profile Action Reason // --- ------ ------- ------ ------ - // bar lib dev* link For bdep - // bar lib dev-panic metadata For tests/benches - // bdep lib dev* link For foo build.rs - // foo custom dev* link For build.rs + // bar lib test* link For bdep + // bar lib test-panic metdata For tests/benches + // bdep lib test* link For foo build.rs + // foo custom test* link For build.rs // // `*` = wants panic, but it is cleared when args are built. // // - foo target list is: - // Target Profile Mode - // ------ ------- ---- - // lib dev-panic check-test (for tests/benches) - // lib dev-panic check-test (checking lib as a unittest) - // example dev-panic check-test - // test dev-panic check-test - // bench dev-panic check-test - // bin dev-panic check-test + // Target Profile Mode + // ------ ------- ---- + // lib test-panic check-test (for tests/benches) + // lib test-panic check-test (checking lib as a unittest) + // example test-panic check-test + // test test-panic check-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=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 [..] +[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=1 -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=1 -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=1 -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata -C codegen-units=1 -C debuginfo=2 --test [..] -[FINISHED] dev [unoptimized + debuginfo] [..] -").run(); +[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] [..] +", affected=affected)).run(); p.cargo("check --all-targets --profile=test -vv") + .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] [FRESH] bdep [..] [FRESH] foo [..] -[FINISHED] dev [unoptimized + debuginfo] [..] +[FINISHED] test [unoptimized + debuginfo] [..] ", ) .run(); @@ -629,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 [..] diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 4fbbefa120c..422cfec6c73 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -343,8 +343,8 @@ fn profile_panic_test_bench() { p.cargo("build") .with_stderr_contains( "\ -[WARNING] `panic` setting is ignored for `test` profile [WARNING] `panic` setting is ignored for `bench` profile +[WARNING] `panic` setting is ignored for `test` profile ", ) .run(); diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index fd3d72c676c..5384ba755d4 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -290,21 +290,21 @@ fn test_default_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test ... ok") .run(); p.cargo("test --no-default-features") - .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") + .with_stderr("[FINISHED] test [unoptimized + debuginfo] target(s) in [..]") .with_stdout("") .run(); p.cargo("test --test=foo") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -347,7 +347,7 @@ fn test_arg_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -388,7 +388,7 @@ fn test_multiple_required_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo_2-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -398,7 +398,7 @@ fn test_multiple_required_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo_1-[..][EXE] [RUNNING] target/debug/deps/foo_2-[..][EXE]", ) @@ -406,7 +406,7 @@ fn test_multiple_required_features() { .run(); p.cargo("test --no-default-features") - .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") + .with_stderr("[FINISHED] test [unoptimized + debuginfo] target(s) in [..]") .with_stdout("") .run(); } @@ -451,21 +451,21 @@ fn bench_default_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") .run(); p.cargo("bench --no-default-features") - .with_stderr("[FINISHED] release [optimized] target(s) in [..]".to_string()) + .with_stderr("[FINISHED] bench [optimized] target(s) in [..]".to_string()) .with_stdout("") .run(); p.cargo("bench --bench=foo") .with_stderr( "\ -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -521,7 +521,7 @@ fn bench_arg_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -584,7 +584,7 @@ fn bench_multiple_required_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo_2-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -594,7 +594,7 @@ fn bench_multiple_required_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo_1-[..][EXE] [RUNNING] target/release/deps/foo_2-[..][EXE]", ) @@ -602,7 +602,7 @@ fn bench_multiple_required_features() { .run(); p.cargo("bench --no-default-features") - .with_stderr("[FINISHED] release [optimized] target(s) in [..]") + .with_stderr("[FINISHED] bench [optimized] target(s) in [..]") .with_stdout("") .run(); } @@ -849,7 +849,7 @@ fn dep_feature_in_toml() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -862,7 +862,7 @@ fn dep_feature_in_toml() { "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -966,7 +966,7 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` // test p.cargo("test") - .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]") + .with_stderr("[FINISHED] test [unoptimized + debuginfo] target(s) in [..]") .with_stdout("") .run(); @@ -974,7 +974,7 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -983,7 +983,7 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` // bench if is_nightly() { p.cargo("bench") - .with_stderr("[FINISHED] release [optimized] target(s) in [..]") + .with_stderr("[FINISHED] bench [optimized] target(s) in [..]") .with_stdout("") .run(); @@ -992,7 +992,7 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("test bench ... bench: [..]") @@ -1046,7 +1046,7 @@ fn test_skips_compiling_bin_with_missing_required_features() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("running 0 tests") @@ -1066,7 +1066,7 @@ error[E0463]: can't find crate for `bar`", .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", ) .with_stdout_contains("running 0 tests") diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 47221bd2a1c..30c3685c742 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -1096,7 +1096,7 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -1108,7 +1108,7 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] ", ) .run(); @@ -1178,7 +1178,7 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -1190,7 +1190,7 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` [RUNNING] `rustc [..] --cfg bar[..]` -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] ", ) .run(); diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 7c408ad4f74..51223fd01de 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -42,7 +42,7 @@ fn cargo_test_simple() { .with_stderr( "\ [COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("test test_hello ... ok") @@ -234,7 +234,7 @@ fn cargo_test_verbose() { "\ [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc [..] src/main.rs [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[CWD]/target/debug/deps/foo-[..] hello` ", ) @@ -307,7 +307,7 @@ fn cargo_test_failing_test_in_bin() { .with_stderr( "\ [COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [ERROR] test failed, to rerun pass '--bin foo'", ) @@ -355,7 +355,7 @@ fn cargo_test_failing_test_in_test() { .with_stderr( "\ [COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/footest-[..][EXE] [ERROR] test failed, to rerun pass '--test footest'", @@ -394,7 +394,7 @@ fn cargo_test_failing_test_in_lib() { .with_stderr( "\ [COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [ERROR] test failed, to rerun pass '--lib'", ) @@ -468,7 +468,7 @@ fn test_with_lib_dep() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/baz-[..][EXE] [DOCTEST] foo", @@ -522,7 +522,7 @@ fn test_with_deep_lib_dep() { "\ [COMPILING] bar v0.0.1 ([..]) [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[..] [DOCTEST] foo", ) @@ -571,7 +571,7 @@ fn external_test_explicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE] [DOCTEST] foo", @@ -631,7 +631,7 @@ fn external_test_implicit() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/external-[..][EXE] [DOCTEST] foo", @@ -672,7 +672,7 @@ fn pass_through_command_line() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] ", ) @@ -683,7 +683,7 @@ fn pass_through_command_line() { p.cargo("test foo") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] ", ) @@ -748,7 +748,7 @@ fn lib_bin_same_name() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", @@ -789,7 +789,7 @@ fn lib_with_standard_name() { .with_stderr( "\ [COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/syntax-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE] [DOCTEST] syntax", @@ -835,7 +835,7 @@ fn lib_with_standard_name2() { .with_stderr( "\ [COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/syntax-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -876,7 +876,7 @@ fn lib_without_name() { .with_stderr( "\ [COMPILING] syntax v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/syntax-[..][EXE]", ) .with_stdout_contains("test test ... ok") @@ -1188,7 +1188,7 @@ fn test_dylib() { "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE]", ) @@ -1199,7 +1199,7 @@ fn test_dylib() { p.cargo("test") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE]", ) @@ -1228,7 +1228,7 @@ fn test_twice_with_build_cmd() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", ) @@ -1239,7 +1239,7 @@ fn test_twice_with_build_cmd() { p.cargo("test") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", ) @@ -1256,7 +1256,7 @@ fn test_then_build() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", ) @@ -1277,7 +1277,7 @@ fn test_no_run() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -1311,7 +1311,7 @@ fn test_run_specific_bin_target() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/bin2-[..][EXE]", ) .with_stdout_contains("test test2 ... ok") @@ -1352,7 +1352,7 @@ fn test_run_implicit_bin_target() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE]", ) .with_stdout_contains("test test_in_bin ... ok") @@ -1372,7 +1372,7 @@ fn test_run_specific_test_target() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/b-[..][EXE]", ) .with_stdout_contains("test test_b ... ok") @@ -1412,7 +1412,7 @@ fn test_run_implicit_test_target() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE] [RUNNING] target/debug/deps/mytest-[..][EXE]", ) @@ -1453,7 +1453,7 @@ fn test_run_implicit_bench_target() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE] [RUNNING] target/debug/deps/mybench-[..][EXE]", ) @@ -1559,7 +1559,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..] --test [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[CWD]/target/debug/deps/foo-[..] foo` ", ) @@ -1596,7 +1596,7 @@ fn test_no_harness() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/bar-[..][EXE] ", ) @@ -1668,7 +1668,7 @@ fn selective_testing() { .with_stderr( "\ [COMPILING] d1 v0.0.1 ([CWD]/d1) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d1-[..][EXE] [RUNNING] target/debug/deps/d1-[..][EXE]", ) @@ -1680,7 +1680,7 @@ fn selective_testing() { .with_stderr( "\ [COMPILING] d2 v0.0.1 ([CWD]/d2) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d2-[..][EXE] [RUNNING] target/debug/deps/d2-[..][EXE]", ) @@ -1692,7 +1692,7 @@ fn selective_testing() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", ) .with_stdout_contains("running 0 tests") @@ -1873,7 +1873,7 @@ fn selective_testing_with_docs() { .with_stderr( "\ [COMPILING] d1 v0.0.1 ([CWD]/d1) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d1[..][EXE] [DOCTEST] d1", ) @@ -1894,7 +1894,7 @@ fn example_bin_same_name() { [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -1970,7 +1970,7 @@ fn example_with_dev_dep() { [..] [..] [RUNNING] `rustc --crate-name ex [..] --extern a=[..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -2036,7 +2036,7 @@ fn doctest_feature() { .with_stderr( "\ [COMPILING] foo [..] -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE] [DOCTEST] foo", ) @@ -2113,7 +2113,7 @@ fn filter_no_doc_tests() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE]", ) .with_stdout_contains("running 0 tests") @@ -2152,7 +2152,7 @@ fn dylib_doctest() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [DOCTEST] foo", ) .with_stdout_contains("test [..] ... ok") @@ -2239,7 +2239,7 @@ fn cyclic_dev_dep_doc_test() { "\ [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE] [DOCTEST] foo", ) @@ -2335,7 +2335,7 @@ fn no_fail_fast() { .with_stderr_contains( "\ [COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test_add_one-[..][EXE]", ) @@ -2432,7 +2432,7 @@ fn bin_does_not_rebuild_tests() { [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..] src/main.rs [..]` [RUNNING] `rustc [..] src/main.rs [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -2490,7 +2490,7 @@ fn selective_test_optional_dep() { [COMPILING] a v0.0.1 ([..]) [RUNNING] `rustc [..] a/src/lib.rs [..]` [RUNNING] `rustc [..] a/src/lib.rs [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] ", ) .run(); @@ -2522,7 +2522,7 @@ fn only_test_docs() { .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [DOCTEST] foo", ) .with_stdout_contains("test [..] ... ok") @@ -2589,7 +2589,7 @@ fn cfg_test_even_with_no_harness() { "\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]` ", ) @@ -3498,7 +3498,7 @@ fn doctest_skip_staticlib() { .with_stderr( "\ [COMPILING] foo [..] -[FINISHED] dev [..] +[FINISHED] test [..] [RUNNING] target/debug/deps/foo-[..]", ) .run(); @@ -3526,7 +3526,7 @@ pub fn foo() -> u8 { 1 } .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..] [DOCTEST] foo ", @@ -3550,7 +3550,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out p.cargo("test --lib") .with_stderr( "\ -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..]\n", ) .with_stdout( @@ -3616,7 +3616,7 @@ fn test_all_targets_lib() { .with_stderr( "\ [COMPILING] foo [..] -[FINISHED] dev [..] +[FINISHED] test [..] [RUNNING] [..]foo[..] ", ) diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index a198176ab82..49ced238f36 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -156,7 +156,7 @@ fn custom_runner() { "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..]` -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `nonexistent-runner -r [..]/target/debug/deps/test-[..][EXE] --param` ", ) @@ -169,7 +169,7 @@ fn custom_runner() { [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` -[FINISHED] release [optimized] target(s) in [..] +[FINISHED] bench [optimized] target(s) in [..] [RUNNING] `nonexistent-runner -r [..]/target/release/deps/bench-[..][EXE] --param --bench` ", )