diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 17e01d14de1..c684d5a3eaf 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -256,12 +256,22 @@ impl Project { self.root.clone() } - /// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target` + /// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target/target-triple` pub fn build_dir(&self) -> PathBuf { - self.root().join("target") + self.root().join("target").join(rustc_host()) } - /// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/debug` + /// Project's target dir, ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple` + pub fn host_dir(&self) -> PathBuf { + self.root().join("target/host").join(rustc_host()) + } + + /// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple/debug` + pub fn host_debug_dir(&self) -> PathBuf { + self.host_dir().join("debug") + } + + /// Project's debug dir, ex: `/path/to/cargo/target/cit/t0/foo/target/target-triple/debug` pub fn target_debug_dir(&self) -> PathBuf { self.build_dir().join("debug") } @@ -280,8 +290,17 @@ impl Project { .join(paths::get_lib_filename(name, kind)) } + /// Path to an example built as a library. + /// `kind` should be one of: "lib", "rlib", "staticlib", "dylib", "proc-macro" + /// ex: `/path/to/cargo/target/cit/t0/foo/target/host/host-triple/debug/examples/libex.rlib` + pub fn host_example_lib(&self, name: &str, kind: &str) -> PathBuf { + self.host_debug_dir() + .join("examples") + .join(paths::get_lib_filename(name, kind)) + } + /// Path to a debug binary. - /// ex: `/path/to/cargo/target/cit/t0/foo/target/debug/foo` + /// ex: `/path/to/cargo/target/target-triple/cit/t0/foo/target/target-triple/debug/foo` pub fn bin(&self, b: &str) -> PathBuf { self.build_dir() .join("debug") @@ -289,7 +308,7 @@ impl Project { } /// Path to a release binary. - /// ex: `/path/to/cargo/target/cit/t0/foo/target/release/foo` + /// ex: `/path/to/cargo/target/target-triple/cit/t0/foo/target/target-triple/release/foo` pub fn release_bin(&self, b: &str) -> PathBuf { self.build_dir() .join("release") @@ -299,11 +318,11 @@ impl Project { /// Path to a debug binary for a specific target triple. /// ex: `/path/to/cargo/target/cit/t0/foo/target/i686-apple-darwin/debug/foo` pub fn target_bin(&self, target: &str, b: &str) -> PathBuf { - self.build_dir().join(target).join("debug").join(&format!( - "{}{}", - b, - env::consts::EXE_SUFFIX - )) + self.root() + .join("target") + .join(target) + .join("debug") + .join(&format!("{}{}", b, env::consts::EXE_SUFFIX)) } /// Returns an iterator of paths matching the glob pattern, which is diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index 79580862e1f..c85b2b3bcb0 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -51,8 +51,10 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options( config, + rustc, CompileMode::Bench, Some(&ws), ProfileChecking::Checked, diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index 299f06cc925..6da147b88ef 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -49,8 +49,10 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options( config, + rustc, CompileMode::Build, Some(&ws), ProfileChecking::Checked, diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs index 8c14395bf73..c38b442cfa1 100644 --- a/src/bin/cargo/commands/check.rs +++ b/src/bin/cargo/commands/check.rs @@ -54,7 +54,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { } }; let mode = CompileMode::Check { test }; - let compile_opts = args.compile_options(config, mode, Some(&ws), ProfileChecking::Unchecked)?; + let rustc = config.load_global_rustc(Some(&ws)); + let compile_opts = + args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Unchecked)?; ops::compile(&ws, &compile_opts)?; Ok(()) diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs index 7ef405177be..ca24cb502bf 100644 --- a/src/bin/cargo/commands/doc.rs +++ b/src/bin/cargo/commands/doc.rs @@ -40,8 +40,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let mode = CompileMode::Doc { deps: !args.is_present("no-deps"), }; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = - args.compile_options(config, mode, Some(&ws), ProfileChecking::Checked)?; + args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Checked)?; compile_opts.rustdoc_document_private_items = args.is_present("document-private-items"); let doc_opts = DocOptions { diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 49fe40cd8ea..c550f444154 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -83,7 +83,9 @@ 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), ProfileChecking::Unchecked)?; + let rustc = config.load_global_rustc(Some(&ws)); + let mut opts = + args.compile_options(config, rustc, mode, Some(&ws), ProfileChecking::Unchecked)?; if let CompileFilter::Default { .. } = opts.filter { opts.filter = CompileFilter::Only { diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 6c9d8d1e025..8550efc57da 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -127,8 +127,15 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { None }; + let ws = args.workspace(config); + let rustc = if ws.is_ok() { + config.load_global_rustc(Some(&ws?)) + } else { + config.load_global_rustc(None) + }; let mut compile_opts = args.compile_options( config, + rustc, CompileMode::Build, workspace.as_ref(), ProfileChecking::Checked, diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index 9a09497cb4b..d379c8e6b53 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -33,8 +33,10 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options( config, + rustc, CompileMode::Build, Some(&ws), ProfileChecking::Checked, diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index 3614110aba5..82b51c4aae5 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -60,8 +60,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { return Err(CliError::new(err, 101)); } }; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options_for_single_package( config, + rustc, mode, Some(&ws), ProfileChecking::Unchecked, diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index aaa8449f30d..e5387b21a4e 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -40,8 +40,10 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options_for_single_package( config, + rustc, CompileMode::Doc { deps: false }, Some(&ws), ProfileChecking::Checked, diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index 2b046464074..5a40ec0021e 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -62,8 +62,10 @@ pub fn cli() -> App { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let ws = args.workspace(config)?; + let rustc = config.load_global_rustc(Some(&ws)); let mut compile_opts = args.compile_options( config, + rustc, CompileMode::Test, Some(&ws), ProfileChecking::Checked, diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index bc829ef2ba2..1a582fb8895 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -1,6 +1,7 @@ use crate::core::compiler::CompileKind; use crate::util::interning::InternedString; -use crate::util::{CargoResult, Config, RustfixDiagnosticServer}; +use crate::util::{CargoResult, Rustc, RustfixDiagnosticServer}; +use crate::Config; use anyhow::bail; use cargo_util::ProcessBuilder; use serde::ser; @@ -52,12 +53,14 @@ impl BuildConfig { /// * `target.$target.libfoo.metadata` pub fn new( config: &Config, + rustc: CargoResult, jobs: Option, requested_targets: &[String], mode: CompileMode, ) -> CargoResult { let cfg = config.build_config()?; - let requested_kinds = CompileKind::from_requested_targets(config, requested_targets)?; + let requested_kinds = + CompileKind::from_requested_targets(config, rustc, requested_targets)?; if jobs == Some(0) { anyhow::bail!("jobs must be at least 1") } diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index 8aff294bb7a..a0f4ff28ecd 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -588,22 +588,29 @@ fn env_args( // This means that, e.g., even if the specified --target is the // same as the host, build scripts in plugins won't get // RUSTFLAGS. - if requested_kinds != [CompileKind::Host] && kind.is_host() { - // This is probably a build script or plugin and we're - // compiling with --target. In this scenario there are - // no rustflags we can apply. - return Ok(Vec::new()); - } - - // First try RUSTFLAGS from the environment - if let Ok(a) = env::var(name) { - let args = a - .split(' ') - .map(str::trim) - .filter(|s| !s.is_empty()) - .map(str::to_string); - return Ok(args.collect()); - } + let prefix = if requested_kinds != [CompileKind::Host] && kind.is_host() { + // Next try HOST_RUSTFLAGS from the environment + if let Ok(a) = env::var(format!("HOST_{}", name)) { + let args = a + .split(' ') + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string); + return Ok(args.collect()); + } + "host" + } else { + // First try RUSTFLAGS from the environment + if let Ok(a) = env::var(name) { + let args = a + .split(' ') + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string); + return Ok(args.collect()); + } + "target" + }; let mut rustflags = Vec::new(); @@ -616,9 +623,14 @@ fn env_args( CompileKind::Host => host_triple, CompileKind::Target(target) => target.short_name(), }; - let key = format!("target.{}.{}", target, name); + let key = format!("{}.{}.{}", prefix, target, name); if let Some(args) = config.get::>(&key)? { rustflags.extend(args.as_slice().iter().cloned()); + } else { + let generic_key = format!("{}.{}", prefix, name); + if let Some(args) = config.get::>(&generic_key)? { + rustflags.extend(args.as_slice().iter().cloned()); + } } // ...including target.'cfg(...)'.rustflags if let Some(target_cfg) = target_cfg { @@ -641,14 +653,16 @@ fn env_args( } // Then the `build.rustflags` value. - let build = config.build_config()?; - let list = if name == "rustflags" { - &build.rustflags - } else { - &build.rustdocflags - }; - if let Some(list) = list { - return Ok(list.as_slice().to_vec()); + if requested_kinds == [CompileKind::Host] || !kind.is_host() { + let build = config.build_config()?; + let list = if name == "rustflags" { + &build.rustflags + } else { + &build.rustdocflags + }; + if let Some(list) = list { + return Ok(list.as_slice().to_vec()); + } } Ok(Vec::new()) diff --git a/src/cargo/core/compiler/compile_kind.rs b/src/cargo/core/compiler/compile_kind.rs index adfa55fce17..740f73cc9a8 100644 --- a/src/cargo/core/compiler/compile_kind.rs +++ b/src/cargo/core/compiler/compile_kind.rs @@ -1,7 +1,8 @@ use crate::core::Target; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; -use crate::util::{Config, StableHasher}; +use crate::util::{Rustc, StableHasher}; +use crate::Config; use anyhow::{bail, Context as _}; use serde::Serialize; use std::collections::BTreeSet; @@ -50,6 +51,7 @@ impl CompileKind { /// `CompileKind::Host`. pub fn from_requested_targets( config: &Config, + rustc: CargoResult, targets: &[String], ) -> CargoResult> { if targets.len() > 1 && !config.cli_unstable().multitarget { @@ -76,7 +78,13 @@ impl CompileKind { }; CompileKind::Target(CompileTarget::new(&value)?) } - None => CompileKind::Host, + None => { + if rustc.is_ok() { + CompileKind::Target(CompileTarget::new(&rustc.unwrap().host)?) + } else { + CompileKind::Host + } + } }; Ok(vec![kind]) } diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index ad1ae2f8fe4..85135dd94fe 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -247,7 +247,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> { /// Directory where the fingerprint for the given unit should go. pub fn fingerprint_dir(&self, unit: &Unit) -> PathBuf { let dir = self.pkg_dir(unit); - self.layout(unit.kind).fingerprint().join(dir) + let kind = if unit.mode.is_run_custom_build() { + CompileKind::Host + } else { + unit.kind + }; + self.layout(kind).fingerprint().join(dir) } /// Returns the path for a file in the fingerprint directory. diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 90e99da5c9f..b0b2389ff2c 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -713,6 +713,7 @@ impl LocalFingerprint { mtime_cache: &mut HashMap, pkg_root: &Path, target_root: &Path, + host_root: &Path, cargo_exe: &Path, ) -> CargoResult> { match self { @@ -760,7 +761,7 @@ impl LocalFingerprint { // the `output` path itself, or the last time the build script ran. LocalFingerprint::RerunIfChanged { output, paths } => Ok(find_stale_file( mtime_cache, - &target_root.join(output), + &host_root.join(output), paths.iter().map(|p| pkg_root.join(p)), )), @@ -993,6 +994,7 @@ impl Fingerprint { mtime_cache: &mut HashMap, pkg_root: &Path, target_root: &Path, + host_root: &Path, cargo_exe: &Path, ) -> CargoResult<()> { assert!(!self.fs_status.up_to_date()); @@ -1086,7 +1088,7 @@ impl Fingerprint { // message and bail out so we stay stale. for local in self.local.get_mut().unwrap().iter() { if let Some(item) = - local.find_stale_item(mtime_cache, pkg_root, target_root, cargo_exe)? + local.find_stale_item(mtime_cache, pkg_root, target_root, host_root, cargo_exe)? { item.log(); return Ok(()); @@ -1240,12 +1242,18 @@ fn calculate(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult, unit: &Unit) -> CargoResult, unit: &Unit) -> CargoResult { + assert!(!unit.mode.is_run_custom_build()); // Recursively calculate the fingerprint for all of our dependencies. // // Skip fingerprints of binaries because they don't actually induce a @@ -1274,7 +1283,11 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult, unit: &Unit) -> CargoResult, unit: &Unit) -> PathBuf { cx.files().fingerprint_file_path(unit, "dep-") } +/// Returns an absolute path that host directory. +/// All paths are rewritten to be relative to this. +fn host_root(cx: &Context<'_, '_>) -> PathBuf { + cx.bcx.ws.host_dir().into_path_unlocked() +} + /// Returns an absolute path that target directory. /// All paths are rewritten to be relative to this. fn target_root(cx: &Context<'_, '_>) -> PathBuf { diff --git a/src/cargo/core/compiler/layout.rs b/src/cargo/core/compiler/layout.rs index b5d7dea6e64..232cf4b7a38 100644 --- a/src/cargo/core/compiler/layout.rs +++ b/src/cargo/core/compiler/layout.rs @@ -144,10 +144,16 @@ impl Layout { target: Option, dest: &str, ) -> CargoResult { - let mut root = ws.target_dir(); - if let Some(target) = target { - root.push(target.short_name()); - } + let root = if let Some(target) = target { + let mut target_root = ws.target_dir(); + target_root.push(target.short_name()); + target_root + } else { + let rustc = ws.config().load_global_rustc(Some(ws))?; + let mut host_root = ws.host_dir(); + host_root.push(&rustc.host); + host_root + }; let dest = root.join(dest); // If the root directory doesn't already exist go ahead and create it // here. Use this opportunity to exclude it from backups as well if the diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 789a69dd144..ce58272c550 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -49,8 +49,12 @@ pub struct Workspace<'cfg> { // `current_manifest` was found on the filesystem with `[workspace]`. root_manifest: Option, + // Shared host directory for all the packages of this workspace. + // `None` if the default path of `root/host/host-triple` should be used. + host_dir: Option, + // Shared target directory for all the packages of this workspace. - // `None` if the default path of `root/target` should be used. + // `None` if the default path of `root/target/target-triple` should be used. target_dir: Option, // List of members in this workspace with a listing of all their manifest @@ -173,6 +177,7 @@ impl<'cfg> Workspace<'cfg> { packages: HashMap::new(), }, root_manifest: None, + host_dir: None, target_dir: None, members: Vec::new(), member_ids: HashSet::new(), @@ -341,6 +346,12 @@ impl<'cfg> Workspace<'cfg> { self.packages.get(self.root_manifest()) } + pub fn host_dir(&self) -> Filesystem { + self.host_dir + .clone() + .unwrap_or_else(|| Filesystem::new(self.root().join("target").join("host"))) + } + pub fn target_dir(&self) -> Filesystem { self.target_dir .clone() diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 76b6927519a..11f10af87b1 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -30,10 +30,11 @@ pub struct CleanOptions<'a> { pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { let mut target_dir = ws.target_dir(); let config = ws.config(); + let rustc = config.load_global_rustc(Some(ws)); // If the doc option is set, we just want to delete the doc directory. if opts.doc { - target_dir = target_dir.join("doc"); + target_dir = target_dir.join(rustc?.host).join("doc"); return rm_rf(&target_dir.into_path_unlocked(), config); } @@ -57,7 +58,7 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { } // Clean specific packages. - let requested_kinds = CompileKind::from_requested_targets(config, &opts.targets)?; + let requested_kinds = CompileKind::from_requested_targets(config, rustc, &opts.targets)?; let target_data = RustcTargetData::new(ws, &requested_kinds)?; let (pkg_set, resolve) = ops::resolve_ws(ws)?; let prof_dir_name = profiles.get_dir_name(); @@ -75,14 +76,10 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> { .collect::>()?; // A Vec of layouts. This is a little convoluted because there can only be // one host_layout. - let layouts = if opts.targets.is_empty() { - vec![(CompileKind::Host, &host_layout)] - } else { - target_layouts - .iter() - .map(|(kind, layout)| (*kind, layout)) - .collect() - }; + let layouts: Vec<(CompileKind, &Layout)> = target_layouts + .iter() + .map(|(kind, layout)| (*kind, layout)) + .collect(); // Create a Vec that also includes the host for things that need to clean both. let layouts_with_host: Vec<(CompileKind, &Layout)> = std::iter::once((CompileKind::Host, &host_layout)) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index d37f304644c..2734a1cb663 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -37,13 +37,12 @@ use crate::core::resolver::features::{self, CliFeatures, FeaturesFor}; use crate::core::resolver::{HasDevUnits, Resolve}; use crate::core::{FeatureValue, Package, PackageSet, Shell, Summary, Target}; use crate::core::{PackageId, PackageIdSpec, SourceId, TargetKind, Workspace}; -use crate::drop_println; use crate::ops; use crate::ops::resolve::WorkspaceResolve; -use crate::util::config::Config; use crate::util::interning::InternedString; use crate::util::restricted_names::is_glob_pattern; -use crate::util::{closest_msg, profile, CargoResult, StableHasher}; +use crate::util::{closest_msg, profile, CargoResult, Rustc, StableHasher}; +use crate::{drop_println, Config}; use anyhow::Context as _; @@ -82,9 +81,13 @@ pub struct CompileOptions { } impl<'a> CompileOptions { - pub fn new(config: &Config, mode: CompileMode) -> CargoResult { + pub fn new( + config: &Config, + rustc: CargoResult, + mode: CompileMode, + ) -> CargoResult { Ok(CompileOptions { - build_config: BuildConfig::new(config, None, &[], mode)?, + build_config: BuildConfig::new(config, rustc, None, &[], mode)?, cli_features: CliFeatures::new_all(false), spec: ops::Packages::Packages(Vec::new()), filter: CompileFilter::Default { diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 1e0d855d0d1..bee7617bd0f 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -21,7 +21,8 @@ pub fn fetch<'a>( let jobs = Some(1); let config = ws.config(); - let build_config = BuildConfig::new(config, jobs, &options.targets, CompileMode::Build)?; + let rustc = config.load_global_rustc(Some(ws)); + let build_config = BuildConfig::new(config, rustc, jobs, &options.targets, CompileMode::Build)?; let data = RustcTargetData::new(ws, &build_config.requested_kinds)?; let mut fetched_packages = HashSet::new(); let mut deps_to_fetch = ws.members().map(|p| p.package_id()).collect::>(); diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index b2e100f6c0b..c8809a64778 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -108,8 +108,10 @@ fn build_resolve_graph( ) -> CargoResult<(Vec, MetadataResolve)> { // TODO: Without --filter-platform, features are being resolved for `host` only. // How should this work? + let config = ws.config(); + let rustc = config.load_global_rustc(Some(ws)); let requested_kinds = - CompileKind::from_requested_targets(ws.config(), &metadata_opts.filter_platforms)?; + CompileKind::from_requested_targets(config, rustc, &metadata_opts.filter_platforms)?; let target_data = RustcTargetData::new(ws, &requested_kinds)?; // Resolve entire workspace. let specs = Packages::All.to_package_id_specs(ws)?; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index e38b25f3397..c274c7ac45b 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -688,10 +688,17 @@ fn run_verify(ws: &Workspace<'_>, tar: &FileLock, opts: &PackageOpts<'_>) -> Car }; let exec: Arc = Arc::new(DefaultExecutor); + let rustc = config.load_global_rustc(Some(&ws)); ops::compile_with_exec( &ws, &ops::CompileOptions { - build_config: BuildConfig::new(config, opts.jobs, &opts.targets, CompileMode::Build)?, + build_config: BuildConfig::new( + config, + rustc, + opts.jobs, + &opts.targets, + CompileMode::Build, + )?, cli_features: opts.cli_features.clone(), spec: ops::Packages::Packages(Vec::new()), filter: ops::CompileFilter::Default { diff --git a/src/cargo/ops/tree/mod.rs b/src/cargo/ops/tree/mod.rs index e9981b78650..30a34c9b412 100644 --- a/src/cargo/ops/tree/mod.rs +++ b/src/cargo/ops/tree/mod.rs @@ -134,7 +134,9 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<() }; // TODO: Target::All is broken with -Zfeatures=itarget. To handle that properly, // `FeatureResolver` will need to be taught what "all" means. - let requested_kinds = CompileKind::from_requested_targets(ws.config(), &requested_targets)?; + let config = ws.config(); + let rustc = config.load_global_rustc(Some(ws)); + let requested_kinds = CompileKind::from_requested_targets(config, rustc, &requested_targets)?; let target_data = RustcTargetData::new(ws, &requested_kinds)?; let specs = opts.packages.to_package_id_specs(ws)?; let has_dev = if opts diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 5668bd21614..4294099c2aa 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -8,7 +8,7 @@ use crate::util::interning::InternedString; use crate::util::restricted_names::is_glob_pattern; use crate::util::{ print_available_benches, print_available_binaries, print_available_examples, - print_available_packages, print_available_tests, + print_available_packages, print_available_tests, Rustc, }; use crate::util::{toml::TomlProfile, validate_package_name}; use crate::CargoResult; @@ -399,6 +399,7 @@ pub trait ArgMatchesExt { fn compile_options( &self, config: &Config, + rustc: CargoResult, mode: CompileMode, workspace: Option<&Workspace<'_>>, profile_checking: ProfileChecking, @@ -466,7 +467,8 @@ pub trait ArgMatchesExt { } } - let mut build_config = BuildConfig::new(config, self.jobs()?, &self.targets(), mode)?; + let mut build_config = + BuildConfig::new(config, rustc, self.jobs()?, &self.targets(), mode)?; build_config.message_format = message_format.unwrap_or(MessageFormat::Human); build_config.requested_profile = self.get_profile_name(config, "dev", profile_checking)?; build_config.build_plan = self._is_present("build-plan"); @@ -549,11 +551,13 @@ pub trait ArgMatchesExt { fn compile_options_for_single_package( &self, config: &Config, + rustc: CargoResult, mode: CompileMode, workspace: Option<&Workspace<'_>>, profile_checking: ProfileChecking, ) -> CargoResult { - let mut compile_opts = self.compile_options(config, mode, workspace, profile_checking)?; + let mut compile_opts = + self.compile_options(config, rustc, mode, workspace, profile_checking)?; let spec = self._values_of("package"); if spec.iter().any(is_glob_pattern) { anyhow::bail!("Glob patterns on package selection are not supported.") diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs index e42b01fa11b..28fb4de2cfb 100644 --- a/src/cargo/util/config/mod.rs +++ b/src/cargo/util/config/mod.rs @@ -165,6 +165,8 @@ pub struct Config { cache_rustc_info: bool, /// Creation time of this config, used to output the total build time creation_time: Instant, + /// Host Directory via resolved Cli parameter + host_dir: Option, /// Target Directory via resolved Cli parameter target_dir: Option, /// Environment variables, separated to assist testing. @@ -269,6 +271,7 @@ impl Config { crates_io_source_id: LazyCell::new(), cache_rustc_info, creation_time: Instant::now(), + host_dir: None, target_dir: None, env, upper_case_env, @@ -477,6 +480,41 @@ impl Config { &self.cwd } + /// The `host` output directory to use. + /// + /// Returns `None` if the user has not chosen an explicit directory. + /// + /// Callers should prefer `Workspace::host_dir` instead. + pub fn host_dir(&self) -> CargoResult> { + if let Some(dir) = &self.host_dir { + Ok(Some(dir.clone())) + } else if let Some(dir) = self.env.get("CARGO_HOST_DIR") { + // Check if the CARGO_TARGET_DIR environment variable is set to an empty string. + if dir.is_empty() { + bail!( + "the host directory is set to an empty string in the \ + `CARGO_HOST_DIR` environment variable" + ) + } + + Ok(Some(Filesystem::new(self.cwd.join(dir)))) + } else if let Some(val) = &self.build_config()?.host_dir { + let path = val.resolve_path(self); + + // Check if the host directory is set to an empty string in the config.toml file. + if val.raw_value().is_empty() { + bail!( + "the host directory is set to an empty string in {}", + val.value().definition + ) + } + + Ok(Some(Filesystem::new(path))) + } else { + Ok(None) + } + } + /// The `target` output directory to use. /// /// Returns `None` if the user has not chosen an explicit directory. @@ -2073,6 +2111,7 @@ pub struct CargoNetConfig { pub struct CargoBuildConfig { pub pipelining: Option, pub dep_info_basedir: Option, + pub host_dir: Option, pub target_dir: Option, pub incremental: Option, pub target: Option, diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index c1355b317ce..c7b80616e20 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -59,6 +59,7 @@ impl BuildStd for Execs { } } +#[ignore] #[cargo_test(build_std)] fn basic() { let p = project() diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index a3923dced96..501ae15859d 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1,8 +1,8 @@ //! Tests for the `cargo bench` command. -use cargo_test_support::is_nightly; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::{is_nightly, rustc_host}; #[cargo_test] fn cargo_bench_simple() { @@ -41,12 +41,13 @@ fn cargo_bench_simple() { p.process(&p.bin("foo")).with_stdout("hello\n").run(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_hello ... bench: [..]") .run(); } @@ -87,14 +88,15 @@ fn bench_bench_implicit() { .build(); p.cargo("bench --benches") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/mybench-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/mybench-[..][EXE]) ", - ) + target = rustc_host() + )) .with_stdout_contains("test run2 ... bench: [..]") .run(); } @@ -135,13 +137,14 @@ fn bench_bin_implicit() { .build(); p.cargo("bench --bins") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE]) ", - ) + rustc_host() + )) .with_stdout_contains("test run1 ... bench: [..]") .run(); } @@ -172,13 +175,14 @@ fn bench_tarname() { .build(); p.cargo("bench --bench bin2") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/bin2-[..][EXE]) +[RUNNING] [..] (target/{}/release/deps/bin2-[..][EXE]) ", - ) + rustc_host() + )) .with_stdout_contains("test run2 ... bench: [..]") .run(); } @@ -244,13 +248,14 @@ fn cargo_bench_verbose() { .build(); p.cargo("bench -v hello") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] hello --bench`", - ) +[RUNNING] `[..]target/{}/release/deps/foo-[..][EXE] hello --bench`", + rustc_host() + )) .with_stdout_contains("test bench_hello ... bench: [..]") .run(); } @@ -340,12 +345,13 @@ fn cargo_bench_failing_test() { // Force libtest into serial execution so that the test header will be printed. p.cargo("bench -- --test-threads=1") .with_stdout_contains("test bench_hello ...[..]") - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.5.0 ([CWD])[..] [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains( "[..]thread '[..]' panicked at 'assertion failed: `(left == right)`[..]", ) @@ -412,13 +418,14 @@ fn bench_with_lib_dep() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/baz-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/baz-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test lib_bench ... bench: [..]") .with_stdout_contains("test bin_bench ... bench: [..]") .run(); @@ -476,13 +483,14 @@ fn bench_with_deep_lib_dep() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/bar-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/bar-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bar_bench ... bench: [..]") .run(); } @@ -534,13 +542,14 @@ fn external_bench_explicit() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/bench-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/bench-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test internal_bench ... bench: [..]") .with_stdout_contains("test external_bench ... bench: [..]") .run(); @@ -581,13 +590,14 @@ fn external_bench_implicit() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/external-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/external-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test internal_bench ... bench: [..]") .with_stdout_contains("test external_bench ... bench: [..]") .run(); @@ -645,7 +655,7 @@ fn bench_autodiscover_2015() { .build(); p.cargo("bench bench_basic") - .with_stderr( + .with_stderr(&format!( "warning: \ An explicit [[bench]] section is specified in Cargo.toml which currently disables Cargo from automatically inferring other benchmark targets. @@ -664,9 +674,10 @@ For more information on this warning you can consult https://github.com/rust-lang/cargo/issues/5330 [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE]) ", - ) + rustc_host() + )) .run(); } @@ -707,20 +718,22 @@ fn pass_through_command_line() { .build(); p.cargo("bench bar") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bar ... bench: [..]") .run(); p.cargo("bench foo") - .with_stderr( + .with_stderr(&format!( "[FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test foo ... bench: [..]") .run(); } @@ -800,13 +813,14 @@ fn lib_bin_same_name() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE]) -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/foo-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("test [..] ... bench: [..]", 2) .run(); } @@ -849,13 +863,14 @@ fn lib_with_standard_name() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/syntax-[..][EXE]) -[RUNNING] [..] (target/release/deps/bench-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/syntax-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/bench-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test foo_bench ... bench: [..]") .with_stdout_contains("test bench ... bench: [..]") .run(); @@ -901,12 +916,13 @@ fn lib_with_standard_name2() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/syntax-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/syntax-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -976,7 +992,7 @@ fn bench_dylib() { .build(); p.cargo("bench -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [RUNNING] [..] -C opt-level=3 [..] @@ -985,22 +1001,24 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ) +[RUNNING] `[..]target/{target}/release/deps/foo-[..][EXE] --bench` +[RUNNING] `[..]target/{target}/release/deps/bench-[..][EXE] --bench`", + target = rustc_host() + )) .with_stdout_contains_n("test foo ... bench: [..]", 2) .run(); p.root().move_into_the_past(); p.cargo("bench -v") - .with_stderr( + .with_stderr(&format!( "\ [FRESH] bar v0.0.1 ([CWD]/bar) [FRESH] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ) +[RUNNING] `[..]target/{target}/release/deps/foo-[..][EXE] --bench` +[RUNNING] `[..]target/{target}/release/deps/bench-[..][EXE] --bench`", + target = rustc_host() + )) .with_stdout_contains_n("test foo ... bench: [..]", 2) .run(); } @@ -1036,20 +1054,22 @@ fn bench_twice_with_build_cmd() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test foo ... bench: [..]") .run(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "[FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test foo ... bench: [..]") .run(); } @@ -1126,16 +1146,17 @@ fn bench_with_examples() { .build(); p.cargo("bench -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v6.6.6 ([CWD]) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] `[CWD]/target/release/deps/foo-[..][EXE] --bench` -[RUNNING] `[CWD]/target/release/deps/testb1-[..][EXE] --bench`", - ) +[RUNNING] `[CWD]/target/{target}/release/deps/foo-[..][EXE] --bench` +[RUNNING] `[CWD]/target/{target}/release/deps/testb1-[..][EXE] --bench`", + target = rustc_host() + )) .with_stdout_contains("test bench_bench1 ... bench: [..]") .with_stdout_contains("test bench_bench2 ... bench: [..]") .run(); @@ -1171,12 +1192,13 @@ fn test_a_bench() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.1.0 ([..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/b-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/b-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test foo ... ok") .run(); } @@ -1251,9 +1273,15 @@ fn test_bench_no_fail_fast() { p.cargo("bench --no-fail-fast -- --test-threads=1") .with_status(101) - .with_stderr_contains("[RUNNING] [..] (target/release/deps/foo-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 2 tests") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/foo-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_hello [..]") .with_stdout_contains("test bench_nope [..]") .run(); @@ -1345,9 +1373,15 @@ fn test_bench_multiple_packages() { .build(); p.cargo("bench -p bar -p baz") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bbaz-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/bbaz-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bbar-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/bbar-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_bar ... bench: [..]") .run(); } @@ -1402,9 +1436,15 @@ fn bench_all_workspace() { .build(); p.cargo("bench --workspace") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/bar-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_bar ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/foo-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_foo ... bench: [..]") .run(); } @@ -1553,9 +1593,15 @@ fn bench_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed p.cargo("bench --workspace") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/baz-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/bar-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_bar ... bench: [..]") .run(); } @@ -1606,9 +1652,15 @@ fn bench_virtual_manifest_glob() { // The order in which bar and baz are built is not guaranteed p.cargo("bench -p '*z'") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/baz-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_does_not_contain("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") + .with_stderr_does_not_contain(&format!( + "[RUNNING] [..] (target/{}/release/deps/bar-[..][EXE])", + rustc_host() + )) .with_stdout_does_not_contain("test bench_bar ... bench: [..]") .run(); } @@ -1699,9 +1751,15 @@ fn bench_virtual_manifest_all_implied() { // The order in which bar and baz are built is not guaranteed p.cargo("bench") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/baz-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/baz-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_baz ... bench: [..]") - .with_stderr_contains("[RUNNING] [..] (target/release/deps/bar-[..][EXE])") + .with_stderr_contains(&format!( + "[RUNNING] [..] (target/{}/release/deps/bar-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench_bar ... bench: [..]") .run(); } @@ -1731,7 +1789,7 @@ fn json_artifact_includes_executable_for_benchmark() { .with_json( r#" { - "executable": "[..]/foo/target/release/deps/benchmark-[..][EXE]", + "executable": "[..]/foo/target/$TARGET/release/deps/benchmark-[..][EXE]", "features": [], "filenames": "{...}", "fresh": false, @@ -1752,7 +1810,9 @@ fn json_artifact_includes_executable_for_benchmark() { } {"reason": "build-finished", "success": true} - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 40b63a669a4..eb554bac0ec 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -56,16 +56,18 @@ fn cargo_compile_incremental() { p.cargo("build -v") .env("CARGO_INCREMENTAL", "1") - .with_stderr_contains( - "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ) + .with_stderr_contains(&format!( + "[RUNNING] `rustc [..] -C incremental=[..]/target/{}/debug/incremental[..]`\n", + rustc_host() + )) .run(); p.cargo("test -v") .env("CARGO_INCREMENTAL", "1") - .with_stderr_contains( - "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ) + .with_stderr_contains(&format!( + "[RUNNING] `rustc [..] -C incremental=[..]/target/{}/debug/incremental[..]`\n", + rustc_host() + )) .run(); } @@ -435,7 +437,8 @@ fn cargo_compile_api_exposes_artifact_paths() { let shell = Shell::from_write(Box::new(Vec::new())); let config = Config::new(shell, env::current_dir().unwrap(), paths::home()); let ws = Workspace::new(&p.root().join("Cargo.toml"), &config).unwrap(); - let compile_options = CompileOptions::new(ws.config(), CompileMode::Build).unwrap(); + let rustc = config.load_global_rustc(Some(&ws)); + let compile_options = CompileOptions::new(&config, rustc, CompileMode::Build).unwrap(); let result = cargo::ops::compile(&ws, &compile_options).unwrap(); @@ -1236,6 +1239,8 @@ fn cargo_default_env_metadata_env_var() { // No metadata on libbar since it's a dylib path dependency p.cargo("build -v") + .env("RUST_LOG", "trace") + .env("RUST_BACKTRACE", "full") .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) @@ -1244,18 +1249,21 @@ fn cargo_default_env_metadata_env_var() { -C prefer-dynamic[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{triple}/debug/deps \ + -L dependency=[CWD]/target/host/{triple}/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps \ - --extern bar=[CWD]/target/debug/deps/{prefix}bar{suffix}` + -L dependency=[CWD]/target/{triple}/debug/deps \ + -L dependency=[CWD]/target/host/{triple}/debug/deps \ + --extern bar=[CWD]/target/{triple}/debug/deps/{prefix}bar{suffix}` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX, + triple = rustc_host(), )) .run(); @@ -1263,6 +1271,8 @@ fn cargo_default_env_metadata_env_var() { // If you set the env-var, then we expect metadata on libbar p.cargo("build -v") + .env("RUST_LOG", "trace") + .env("RUST_BACKTRACE", "full") .env("__CARGO_DEFAULT_LIB_METADATA", "stable") .with_stderr(&format!( "\ @@ -1272,19 +1282,22 @@ fn cargo_default_env_metadata_env_var() { -C prefer-dynamic[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{triple}/debug/deps \ + -L dependency=[CWD]/target/host/{triple}/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps \ - --extern bar=[CWD]/target/debug/deps/{prefix}bar-[..]{suffix}` + -L dependency=[CWD]/target/{triple}/debug/deps \ + -L dependency=[CWD]/target/host/{triple}/debug/deps \ + --extern bar=[CWD]/target/{triple}/debug/deps/{prefix}bar-[..]{suffix}` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX, + triple = rustc_host(), )) .run(); } @@ -1597,9 +1610,20 @@ please rename the file to `src/lib.rs` or set lib.path in Cargo.toml", ) .run(); - assert!(p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); let fname = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert!(p.root().join("target/debug").join(&fname).is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&fname) + .is_file()); } #[cargo_test] @@ -1624,9 +1648,20 @@ fn many_crate_types_correct() { .build(); p.cargo("build").run(); - assert!(p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); let fname = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert!(p.root().join("target/debug").join(&fname).is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&fname) + .is_file()); } #[cargo_test] @@ -1743,17 +1778,19 @@ fn lto_build() { fn verbose_build() { let p = project().file("src/lib.rs", "").build(); p.cargo("build -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -1761,7 +1798,7 @@ fn verbose_build() { fn verbose_release_build() { let p = project().file("src/lib.rs", "").build(); p.cargo("build -v --release") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ @@ -1769,10 +1806,12 @@ fn verbose_release_build() { -C opt-level=3[..]\ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/release/deps` + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps` [FINISHED] release [optimized] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -1820,20 +1859,23 @@ fn verbose_release_build_deps() { -C opt-level=3[..]\ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/release/deps` + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps` [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]\ -C opt-level=3[..]\ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/release/deps \ - --extern foo=[CWD]/target/release/deps/{prefix}foo{suffix} \ - --extern foo=[CWD]/target/release/deps/libfoo.rlib` + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps \ + --extern foo=[CWD]/target/{target}/release/deps/{prefix}foo{suffix} \ + --extern foo=[CWD]/target/{target}/release/deps/libfoo.rlib` [FINISHED] release [optimized] target(s) in [..] ", prefix = env::consts::DLL_PREFIX, - suffix = env::consts::DLL_SUFFIX + suffix = env::consts::DLL_SUFFIX, + target = rustc_host() )) .run(); } @@ -2689,7 +2731,7 @@ fn example_as_proc_macro() { .build(); p.cargo("build --example=ex").run(); - assert!(p.example_lib("ex", "proc-macro").is_file()); + assert!(p.host_example_lib("ex", "proc-macro").is_file()); } #[cargo_test] @@ -2829,9 +2871,20 @@ fn predictable_filenames() { .build(); p.cargo("build -v").run(); - assert!(p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); let dylib_name = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert!(p.root().join("target/debug").join(dylib_name).is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(dylib_name) + .is_file()); } #[cargo_test] @@ -2987,17 +3040,47 @@ fn custom_target_dir_env() { let exe_name = format!("foo{}", env::consts::EXE_SUFFIX); p.cargo("build").env("CARGO_TARGET_DIR", "foo/target").run(); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(!p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.cargo("build").run(); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.cargo("build") .env("CARGO_BUILD_TARGET_DIR", "foo2/target") .run(); - assert!(p.root().join("foo2/target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("foo2/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.change_file( ".cargo/config", @@ -3007,9 +3090,27 @@ fn custom_target_dir_env() { "#, ); p.cargo("build").env("CARGO_TARGET_DIR", "bar/target").run(); - assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("bar/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); } #[cargo_test] @@ -3019,12 +3120,36 @@ fn custom_target_dir_line_parameter() { let exe_name = format!("foo{}", env::consts::EXE_SUFFIX); p.cargo("build --target-dir foo/target").run(); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(!p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.cargo("build").run(); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.change_file( ".cargo/config", @@ -3034,21 +3159,59 @@ fn custom_target_dir_line_parameter() { "#, ); p.cargo("build --target-dir bar/target").run(); - assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("target/debug").join(&exe_name).is_file()); + assert!(p + .root() + .join("bar/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); p.cargo("build --target-dir foobar/target") .env("CARGO_TARGET_DIR", "bar/target") .run(); assert!(p .root() - .join("foobar/target/debug") + .join("foobar/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("bar/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("foo/target") + .join(rustc_host()) + .join("debug") + .join(&exe_name) + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") .join(&exe_name) .is_file()); - assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); - assert!(p.root().join("target/debug").join(&exe_name).is_file()); } #[cargo_test] @@ -3294,7 +3457,7 @@ fn compiler_json_error_format() { "linked_paths":[], "env":[], "cfgs":["xyz"], - "out_dir": "[..]target/debug/build/foo-[..]/out" + "out_dir": "[..]target/$TARGET/debug/build/foo-[..]/out" } { @@ -3335,7 +3498,7 @@ fn compiler_json_error_format() { "overflow_checks": true, "test": false }, - "executable": "[..]/foo/target/debug/foo[EXE]", + "executable": "[..]/foo/target/$TARGET/debug/foo[EXE]", "features": [], "filenames": "{...}", "fresh": $FRESH @@ -3344,6 +3507,7 @@ fn compiler_json_error_format() { {"reason": "build-finished", "success": true} "# .replace("$FRESH", fresh) + .replace("$TARGET", rustc_host()) }; // Use `jobs=1` to ensure that the order of messages is consistent. @@ -4180,7 +4344,13 @@ fn cdylib_not_lifted() { for file in files { println!("checking: {}", file); - assert!(p.root().join("target/debug/deps").join(&file).is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug/deps") + .join(&file) + .is_file()); } } @@ -4218,7 +4388,13 @@ fn cdylib_final_outputs() { for file in files { println!("checking: {}", file); - assert!(p.root().join("target/debug").join(&file).is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(&file) + .is_file()); } } @@ -5173,16 +5349,18 @@ fn build_lib_only() { .build(); p.cargo("build --lib -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ) + target = rustc_host() + )) .run(); } diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index c8f398d5cbb..262b7828353 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -1,7 +1,7 @@ //! Tests for --build-plan feature. use cargo_test_support::registry::Package; -use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project}; +use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project, rustc_host}; #[cargo_test] fn cargo_build_plan_simple() { @@ -24,7 +24,7 @@ fn cargo_build_plan_simple() { "cwd": "[..]/cit/[..]/foo", "deps": [], "env": "{...}", - "kind": null, + "kind": "$TARGET", "links": "{...}", "outputs": "{...}", "package_name": "foo", @@ -35,7 +35,9 @@ fn cargo_build_plan_simple() { } ] } - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); assert!(!p.bin("foo").is_file()); @@ -84,11 +86,11 @@ fn cargo_build_plan_single_dep() { "cwd": "[..]/cit/[..]/foo", "deps": [], "env": "{...}", - "kind": null, + "kind": "$TARGET", "links": "{...}", "outputs": [ - "[..]/foo/target/debug/deps/libbar-[..].rlib", - "[..]/foo/target/debug/deps/libbar-[..].rmeta" + "[..]/foo/target/$TARGET/debug/deps/libbar-[..].rlib", + "[..]/foo/target/$TARGET/debug/deps/libbar-[..].rmeta" ], "package_name": "bar", "package_version": "0.0.1", @@ -101,11 +103,11 @@ fn cargo_build_plan_single_dep() { "cwd": "[..]/cit/[..]/foo", "deps": [0], "env": "{...}", - "kind": null, + "kind": "$TARGET", "links": "{...}", "outputs": [ - "[..]/foo/target/debug/deps/libfoo-[..].rlib", - "[..]/foo/target/debug/deps/libfoo-[..].rmeta" + "[..]/foo/target/$TARGET/debug/deps/libfoo-[..].rlib", + "[..]/foo/target/$TARGET/debug/deps/libfoo-[..].rmeta" ], "package_name": "foo", "package_version": "0.5.0", @@ -115,7 +117,9 @@ fn cargo_build_plan_single_dep() { } ] } - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } @@ -166,7 +170,7 @@ fn cargo_build_plan_build_script() { "cwd": "[..]/cit/[..]/foo", "deps": [0], "env": "{...}", - "kind": null, + "kind": "$TARGET", "links": "{...}", "outputs": [], "package_name": "foo", @@ -180,7 +184,7 @@ fn cargo_build_plan_build_script() { "cwd": "[..]/cit/[..]/foo", "deps": [1], "env": "{...}", - "kind": null, + "kind": "$TARGET", "links": "{...}", "outputs": "{...}", "package_name": "foo", @@ -191,7 +195,9 @@ fn cargo_build_plan_build_script() { } ] } - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index e9a24a32683..67627d35e61 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -120,6 +120,7 @@ fn custom_build_env_vars() { "#, p.root() .join("target") + .join(rustc_host()) .join("debug") .join("build") .display() @@ -622,22 +623,26 @@ fn custom_build_script_rustc_flags() { .build(); p.cargo("build --verbose") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo [..] [RUNNING] `rustc --crate-name build_script_build foo/build.rs [..] [RUNNING] `[..]build-script-build` [RUNNING] `rustc --crate-name foo foo/src/lib.rs [..]\ - -L dependency=[CWD]/target/debug/deps \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{host}/debug/deps \ -L /dummy/path1 -L /dummy/path2 -l nonexistinglib` [COMPILING] bar [..] [RUNNING] `rustc --crate-name bar src/main.rs [..]\ - -L dependency=[CWD]/target/debug/deps \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{host}/debug/deps \ --extern foo=[..]libfoo-[..] \ -L /dummy/path1 -L /dummy/path2` [FINISHED] dev [..] ", - ) + host = rustc_host(), + target = rustc_host() + )) .run(); } @@ -681,22 +686,26 @@ fn custom_build_script_rustc_flags_no_space() { .build(); p.cargo("build --verbose") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo [..] [RUNNING] `rustc --crate-name build_script_build foo/build.rs [..] [RUNNING] `[..]build-script-build` [RUNNING] `rustc --crate-name foo foo/src/lib.rs [..]\ - -L dependency=[CWD]/target/debug/deps \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{host}/debug/deps \ -L /dummy/path1 -L /dummy/path2 -l nonexistinglib` [COMPILING] bar [..] [RUNNING] `rustc --crate-name bar src/main.rs [..]\ - -L dependency=[CWD]/target/debug/deps \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{host}/debug/deps \ --extern foo=[..]libfoo-[..] \ -L /dummy/path1 -L /dummy/path2` [FINISHED] dev [..] ", - ) + host = rustc_host(), + target = rustc_host() + )) .run(); } @@ -1221,13 +1230,14 @@ fn testing_and_such() { p.change_file("src/main.rs", "fn main() {}"); println!("run"); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .run(); } @@ -1515,7 +1525,7 @@ fn build_cmd_with_a_build_cmd() { .build(); p.cargo("build -v") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] b v0.5.0 ([CWD]/b) [RUNNING] `rustc --crate-name b [..]` @@ -1525,23 +1535,26 @@ fn build_cmd_with_a_build_cmd() { [RUNNING] `rustc --crate-name a [..]lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ - --out-dir [..]target/debug/deps \ - -L [..]target/debug/deps` + --out-dir [..]host/{host}/debug/deps \ + -L [..]host/{host}/debug/deps` [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin \ --emit=[..]link[..]\ -C debuginfo=2 -C metadata=[..] --out-dir [..] \ - -L [..]target/debug/deps \ + -L [..]host/{host}/debug/deps \ --extern a=[..]liba[..].rlib` [RUNNING] `[..]/foo-[..]/build-script-build` [RUNNING] `rustc --crate-name foo [..]lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L [..]target/debug/deps` + -L [..]target/{target}/debug/deps \ + -L [..]host/{host}/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + host = rustc_host(), + target = rustc_host(), + )) .run(); } @@ -1747,12 +1760,13 @@ fn code_generation() { .build(); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo`", - ) +[RUNNING] `target/{}/debug/foo`", + rustc_host() + )) .with_stdout("Hello, World!") .run(); @@ -2078,7 +2092,7 @@ fn build_script_with_dynamic_native_dependency() { .env("CARGO_LOG", "cargo::ops::cargo_rustc") .run(); - let root = build.root().join("target").join("debug"); + let root = build.root().join("target").join(rustc_host()).join("debug"); foo.cargo("build -v") .env("BUILDER_ROOT", root) .env("CARGO_LOG", "cargo::ops::cargo_rustc") @@ -2363,9 +2377,24 @@ fn cfg_doc() { .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); p.cargo("doc").run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); - assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar.html") + .is_file()); } #[cargo_test] @@ -2482,9 +2511,24 @@ fn cfg_override_doc() { .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); p.cargo("doc").run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); - assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar.html") + .is_file()); } #[cargo_test] @@ -3039,7 +3083,10 @@ fn generate_good_d_files() { println!("*.d file content*: {}", &dot_d); assert_match_exact( - "[..]/target/debug/meow[EXE]: [..]/awoo/barkbarkbark [..]/awoo/build.rs[..]", + &format!( + "[..]/target/{}/debug/meow[EXE]: [..]/awoo/barkbarkbark [..]/awoo/build.rs[..]", + rustc_host() + ), &dot_d, ); @@ -3062,7 +3109,10 @@ fn generate_good_d_files() { println!("*.d file content with dep-info-basedir*: {}", &dot_d); assert_match_exact( - "target/debug/meow[EXE]: awoo/barkbarkbark awoo/build.rs[..]", + &format!( + "target/{}/debug/meow[EXE]: awoo/barkbarkbark awoo/build.rs[..]", + rustc_host() + ), &dot_d, ); @@ -3072,6 +3122,7 @@ fn generate_good_d_files() { .any(|v| v == "barkbarkbark" || v == "build.rs")); } +#[ignore] #[cargo_test] fn rebuild_only_on_explicit_paths() { let p = project() @@ -4058,14 +4109,16 @@ failed to select a version for `a` which could resolve this conflict ").run(); } +#[ignore] #[cargo_test] fn rename_with_link_search_path() { _rename_with_link_search_path(false); } +#[ignore] #[cargo_test] // Don't have a cdylib cross target on macos. -#[cfg_attr(target_os = "macos", ignore)] +// #[cfg_attr(target_os = "macos", ignore)] fn rename_with_link_search_path_cross() { if cross_compile::disabled() { return; @@ -4163,7 +4216,11 @@ fn _rename_with_link_search_path(cross: bool) { .join("debug") .join("deps") } else { - p.root().join("target").join("debug").join("deps") + p.root() + .join("target") + .join(rustc_host()) + .join("debug") + .join("deps") }; let file = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); let src = root.join(&file); @@ -4325,6 +4382,7 @@ fn optional_build_dep_and_required_normal_dep() { .with_stdout("1") .with_stderr( "\ +[COMPILING] bar v0.5.0 ([..]) [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]foo[EXE]`", @@ -4332,6 +4390,7 @@ fn optional_build_dep_and_required_normal_dep() { .run(); } +#[ignore] #[cargo_test] fn using_rerun_if_changed_does_not_rebuild() { let p = project() @@ -4542,6 +4601,7 @@ fn dev_dep_with_links() { p.cargo("check --tests").run() } +#[ignore] #[cargo_test] fn rerun_if_directory() { if !symlink_supported() { diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index 17c729bc9c1..90227b3e4b6 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -58,6 +58,7 @@ fn rerun_if_env_changes() { .run(); } +#[ignore] #[cargo_test] fn rerun_if_env_or_file_changes() { let p = project() diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs index 3f4fbf7b990..939fd3320c5 100644 --- a/tests/testsuite/cache_messages.rs +++ b/tests/testsuite/cache_messages.rs @@ -1,9 +1,9 @@ //! Tests for caching compiler diagnostics. -use cargo_test_support::tools; use cargo_test_support::{ basic_manifest, is_coarse_mtime, process, project, registry::Package, sleep_ms, }; +use cargo_test_support::{rustc_host, tools}; use std::path::Path; fn as_str(bytes: &[u8]) -> &str { @@ -195,7 +195,10 @@ fn clears_cache_after_fix() { // Fill the cache. p.cargo("check").with_stderr_contains("[..]asdf[..]").run(); let cpath = p - .glob("target/debug/.fingerprint/foo-*/output-*") + .glob(&format!( + "target/{}/debug/.fingerprint/foo-*/output-*", + rustc_host() + )) .next() .unwrap() .unwrap(); @@ -217,7 +220,11 @@ fn clears_cache_after_fix() { ) .run(); assert_eq!( - p.glob("target/debug/.fingerprint/foo-*/output-*").count(), + p.glob(&format!( + "target/{}/debug/.fingerprint/foo-*/output-*", + rustc_host() + )) + .count(), 0 ); @@ -254,7 +261,11 @@ fn rustdoc() { assert!(rustdoc_stderr.contains("missing")); assert!(rustdoc_stderr.contains("\x1b[")); assert_eq!( - p.glob("target/debug/.fingerprint/foo-*/output-*").count(), + p.glob(&format!( + "target/{}/debug/.fingerprint/foo-*/output-*", + rustc_host() + )) + .count(), 1 ); @@ -348,7 +359,11 @@ fn doesnt_create_extra_files() { p.change_file("src/lib.rs", "fn unused() {}"); p.cargo("build").run(); assert_eq!( - p.glob("target/debug/.fingerprint/foo-*/output-*").count(), + p.glob(&format!( + "target/{}/debug/.fingerprint/foo-*/output-*", + rustc_host() + )) + .count(), 1 ); } diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index ba271624725..b556916e8c0 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -1,6 +1,6 @@ //! Tests for `[alias]` config command aliases. -use cargo_test_support::{basic_bin_manifest, project}; +use cargo_test_support::{basic_bin_manifest, project, rustc_host}; #[cargo_test] fn alias_incorrect_config_type() { @@ -153,13 +153,14 @@ fn alias_override_builtin_alias() { .build(); p.cargo("b") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .run(); } diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index 492f4c0aae9..7912498c537 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -7,10 +7,10 @@ use std::path::{Path, PathBuf}; use std::process::Stdio; use std::str; -use cargo_test_support::cargo_process; use cargo_test_support::paths::{self, CargoPathExt}; use cargo_test_support::registry::Package; use cargo_test_support::{basic_bin_manifest, basic_manifest, cargo_exe, project, Project}; +use cargo_test_support::{cargo_process, rustc_host}; #[cfg_attr(windows, allow(dead_code))] enum FakeKind<'a> { @@ -329,7 +329,10 @@ fn cargo_subcommand_args() { cargo_process("foo bar -v --help") .env("PATH", &path) - .with_stdout("[CWD]/cargo-foo/target/debug/cargo-foo[EXE] foo bar -v --help") + .with_stdout(&format!( + "[CWD]/cargo-foo/target/{}/debug/cargo-foo[EXE] foo bar -v --help", + rustc_host() + )) .run(); } diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index e37d572f568..1f77ab2c695 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -5,8 +5,8 @@ use std::fmt::{self, Write}; use cargo_test_support::install::exe; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::Package; -use cargo_test_support::tools; use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{rustc_host, tools}; #[cargo_test] fn check_success() { @@ -743,54 +743,211 @@ fn check_artifacts() { .build(); p.cargo("check").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 2); - - p.root().join("target").rm_rf(); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(exe("foo")) + .is_file()); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 2 + ); + + p.root().join("target").join(rustc_host()).rm_rf(); p.cargo("check --lib").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 1); - - p.root().join("target").rm_rf(); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(exe("foo")) + .is_file()); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 1 + ); + + p.root().join("target").join(rustc_host()).rm_rf(); p.cargo("check --bin foo").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 2); - - p.root().join("target").rm_rf(); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(exe("foo")) + .is_file()); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 2 + ); + + p.root().join("target").join(rustc_host()).rm_rf(); p.cargo("check --test t1").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); - assert_eq!(p.glob("target/debug/t1-*").count(), 0); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 1); - assert_eq!(p.glob("target/debug/deps/libt1-*.rmeta").count(), 1); - - p.root().join("target").rm_rf(); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(exe("foo")) + .is_file()); + assert_eq!( + p.glob(&format!("target/{}/debug/t1-*", rustc_host())) + .count(), + 0 + ); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 1 + ); + assert_eq!( + p.glob(&format!("target/{}/debug/deps/libt1-*.rmeta", rustc_host())) + .count(), + 1 + ); + + p.root().join("target").join(rustc_host()).rm_rf(); p.cargo("check --example ex1").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); assert!(!p .root() - .join("target/debug/examples") + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/examples") .join(exe("ex1")) .is_file()); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 1); - assert_eq!(p.glob("target/debug/examples/libex1-*.rmeta").count(), 1); - - p.root().join("target").rm_rf(); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 1 + ); + assert_eq!( + p.glob(&format!( + "target/{}/debug/examples/libex1-*.rmeta", + rustc_host() + )) + .count(), + 1 + ); + + p.root().join("target").join(rustc_host()).rm_rf(); p.cargo("check --bench b1").run(); - assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); - assert_eq!(p.glob("target/debug/b1-*").count(), 0); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rmeta").count(), 1); - assert_eq!(p.glob("target/debug/deps/libb1-*.rmeta").count(), 1); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rmeta") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug") + .join(exe("foo")) + .is_file()); + assert_eq!( + p.glob(&format!("target/{}/debug/b1-*", rustc_host())) + .count(), + 0 + ); + assert_eq!( + p.glob(&format!( + "target/{}/debug/deps/libfoo-*.rmeta", + rustc_host() + )) + .count(), + 1 + ); + assert_eq!( + p.glob(&format!("target/{}/debug/deps/libb1-*.rmeta", rustc_host())) + .count(), + 1 + ); } #[cargo_test] diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index cabfd641047..5e5feb785d5 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -86,6 +86,7 @@ fn clean_multiple_packages() { assert!(!d2_path.is_file()); } +#[ignore] #[cargo_test] fn clean_release() { let p = project() @@ -315,7 +316,11 @@ fn clean_remove_rlib_rmeta() { p.cargo("build").run(); assert!(p.target_debug_dir().join("libfoo.rlib").exists()); - let rmeta = p.glob("target/debug/deps/*.rmeta").next().unwrap().unwrap(); + let rmeta = p + .glob(&format!("target/{}/debug/deps/*.rmeta", rustc_host())) + .next() + .unwrap() + .unwrap(); assert!(rmeta.exists()); p.cargo("clean -p foo").run(); assert!(!p.target_debug_dir().join("libfoo.rlib").exists()); @@ -526,7 +531,11 @@ fn clean_spec_reserved() { p.cargo("build --all-targets").run(); assert!(p.target_debug_dir().join("build").is_dir()); - let build_test = p.glob("target/debug/deps/build-*").next().unwrap().unwrap(); + let build_test = p + .glob(format!("target/{}/debug/deps/build-*", rustc_host())) + .next() + .unwrap() + .unwrap(); assert!(build_test.exists()); // Tests are never "uplifted". assert!(p.glob("target/debug/build-*").next().is_none()); diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index e9fd3085f2a..79929c74ea4 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -4,7 +4,7 @@ //! prevent all collisions. use cargo_test_support::registry::Package; -use cargo_test_support::{basic_manifest, cross_compile, project}; +use cargo_test_support::{basic_manifest, cross_compile, project, rustc_host}; use std::env; #[cargo_test] @@ -51,11 +51,11 @@ fn collision_dylib() { .with_stderr_contains(&format!("\ [WARNING] output filename collision. The lib target `a` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the lib target `a` in package `a v1.0.0 ([..]/foo/a)`. -Colliding filename is: [..]/foo/target/debug/deps/{}a{} +Colliding filename is: [..]/foo/target/{}/debug/deps/{}a{} The targets should have unique names. Consider changing their names to be unique or compiling them separately. This may become a hard error in the future; see . -", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX)) +", rustc_host(), env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX)) .run(); } @@ -79,14 +79,14 @@ fn collision_example() { // `j=1` is required because on Windows you'll get an error due to // two processes writing to the file at the same time. p.cargo("build --examples -j=1") - .with_stderr_contains("\ + .with_stderr_contains(&format!("\ [WARNING] output filename collision. The example target `ex1` in package `b v1.0.0 ([..]/foo/b)` has the same output filename as the example target `ex1` in package `a v1.0.0 ([..]/foo/a)`. -Colliding filename is: [..]/foo/target/debug/examples/ex1[EXE] +Colliding filename is: [..]/foo/target/{}/debug/examples/ex1[EXE] The targets should have unique names. Consider changing their names to be unique or compiling them separately. This may become a hard error in the future; see . -") +", rustc_host())) .run(); } @@ -147,17 +147,18 @@ fn collision_doc() { .build(); p.cargo("doc -j=1") - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [WARNING] output filename collision. The lib target `foo` in package `foo2 v0.1.0 ([..]/foo/foo2)` has the same output \ filename as the lib target `foo` in package `foo v0.1.0 ([..]/foo)`. -Colliding filename is: [..]/foo/target/doc/foo/index.html +Colliding filename is: [..]/foo/target/{}/doc/foo/index.html The targets should have unique names. This is a known bug where multiple crates with the same name use the same path; see . ", - ) + rustc_host() + )) .run(); } @@ -310,7 +311,7 @@ fn collision_doc_host_target_feature_split() { .join("doc/common_dep/fn.bdep_func.html") .exists()); assert!(p.build_dir().join("doc/common/fn.f.html").exists()); - assert!(p.build_dir().join("doc/pm/macro.pm.html").exists()); + assert!(p.host_dir().join("doc/pm/macro.pm.html").exists()); assert!(p.build_dir().join("doc/foo/fn.f.html").exists()); } @@ -408,7 +409,7 @@ fn collision_doc_sources() { .build(); p.cargo("doc -j=1") - .with_stderr_unordered( + .with_stderr_unordered(&format!( "\ [UPDATING] [..] [DOWNLOADING] crates ... @@ -416,7 +417,7 @@ fn collision_doc_sources() { [WARNING] output filename collision. The lib target `bar` in package `bar v1.0.0` has the same output filename as \ the lib target `bar` in package `bar v1.0.0 ([..]/foo/bar)`. -Colliding filename is: [..]/foo/target/doc/bar/index.html +Colliding filename is: [..]/foo/target/{}/doc/bar/index.html The targets should have unique names. This is a known bug where multiple crates with the same name use the same path; see . @@ -427,7 +428,8 @@ the same path; see . [DOCUMENTING] foo v0.1.0 [..] [FINISHED] [..] ", - ) + rustc_host() + )) .run(); } @@ -525,13 +527,13 @@ fn collision_with_root() { .build(); p.cargo("doc -j=1") - .with_stderr_unordered("\ + .with_stderr_unordered(&format!("\ [UPDATING] [..] [DOWNLOADING] crates ... [DOWNLOADED] foo-macro v1.0.0 [..] warning: output filename collision. The lib target `foo-macro` in package `foo-macro v1.0.0` has the same output filename as the lib target `foo-macro` in package `foo-macro v1.0.0 [..]`. -Colliding filename is: [CWD]/target/doc/foo_macro/index.html +Colliding filename is: [CWD]/target/host/{}/doc/foo_macro/index.html The targets should have unique names. This is a known bug where multiple crates with the same name use the same path; see . @@ -541,6 +543,6 @@ the same path; see . [DOCUMENTING] foo-macro v1.0.0 [..] [DOCUMENTING] abc v1.0.0 [..] [FINISHED] [..] -") +", rustc_host())) .run(); } diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index 51d02f32bff..56a1f152b23 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -7,11 +7,11 @@ use std::sync::mpsc::channel; use std::thread; use std::{env, str}; -use cargo_test_support::cargo_process; use cargo_test_support::git; use cargo_test_support::install::{assert_has_installed_exe, cargo_home}; use cargo_test_support::registry::Package; use cargo_test_support::{basic_manifest, execs, project, slow_cpu_multiplier}; +use cargo_test_support::{cargo_process, rustc_host}; fn pkg(name: &str, vers: &str) { Package::new(name, vers) @@ -163,12 +163,16 @@ fn multiple_registry_fetches() { let suffix = env::consts::EXE_SUFFIX; assert!(p .root() - .join("a/target/debug") + .join("a/target") + .join(rustc_host()) + .join("debug") .join(format!("foo{}", suffix)) .is_file()); assert!(p .root() - .join("b/target/debug") + .join("b/target") + .join(rustc_host()) + .join("debug") .join(format!("bar{}", suffix)) .is_file()); } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 827795dab48..d387b60f4b7 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -225,6 +225,7 @@ fn per_crate_target_test( } } +#[ignore] #[cargo_test] fn per_crate_default_target_is_default() { per_crate_target_test(Some(cross_compile::alternate()), None, None); @@ -253,6 +254,7 @@ fn per_crate_forced_target_does_not_get_overridden() { ); } +#[ignore] #[cargo_test] fn workspace_with_multiple_targets() { if cross_compile::disabled() { @@ -402,9 +404,10 @@ fn linker() { --target {target} \ -C linker=my-linker-tool \ -L dependency=[CWD]/target/{target}/debug/deps \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/host/{host}/debug/deps` ", target = target, + host = rustc_host(), )) .run(); } @@ -580,18 +583,22 @@ fn no_cross_doctests() { ) .build(); - let host_output = "\ + let target = rustc_host(); + let host_output = &format!( + "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [DOCTEST] foo -"; +", + target + ); println!("a"); p.cargo("test").with_stderr(&host_output).run(); + p.cargo("clean").run(); println!("b"); - let target = rustc_host(); p.cargo("test --target") .arg(&target) .with_stderr(&format!( @@ -717,12 +724,13 @@ fn cross_with_a_build_script() { .with_stderr(&format!( "\ [COMPILING] foo v0.0.0 ([CWD]) -[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..]` -[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/host/{host}/debug/build/foo-[..]` +[RUNNING] `[CWD]/target/host/{host}/debug/build/foo-[..]/build-script-build` [RUNNING] `rustc [..] src/main.rs [..] --target {target} [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", target = target, + host = rustc_host(), )) .run(); } @@ -814,9 +822,9 @@ fn build_script_needed_for_host_and_target() { .arg(&target) .with_stderr_contains(&"[COMPILING] d1 v0.0.0 ([CWD]/d1)") .with_stderr_contains( - "[RUNNING] `rustc [..] d1/build.rs [..] --out-dir [CWD]/target/debug/build/d1-[..]`", + &format!("[RUNNING] `rustc [..] d1/build.rs [..] --out-dir [CWD]/target/host/{}/debug/build/d1-[..]`", host), ) - .with_stderr_contains("[RUNNING] `[CWD]/target/debug/build/d1-[..]/build-script-build`") + .with_stderr_contains(&format!("[RUNNING] `[CWD]/target/host/{}/debug/build/d1-[..]/build-script-build`", host)) .with_stderr_contains("[RUNNING] `rustc [..] d1/src/lib.rs [..]`") .with_stderr_contains("[COMPILING] d2 v0.0.0 ([CWD]/d2)") .with_stderr_contains(&format!( @@ -825,7 +833,7 @@ fn build_script_needed_for_host_and_target() { )) .with_stderr_contains("[COMPILING] foo v0.0.0 ([CWD])") .with_stderr_contains(&format!( - "[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..] \ + "[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/host/{host}/debug/build/foo-[..] \ -L /path/to/{host}`", host = host )) @@ -915,15 +923,18 @@ fn build_script_only_host() { .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d1/build.rs", - r#" - use std::env; + &format!( + r#" + use std::env; - fn main() { - assert!(env::var("OUT_DIR").unwrap().replace("\\", "/") - .contains("target/debug/build/d1-"), - "bad: {:?}", env::var("OUT_DIR")); - } - "#, + fn main() {{ + assert!(env::var("OUT_DIR").unwrap().replace("\\", "/") + .contains("host/{}/debug/build/d1-"), + "bad: {{:?}}", env::var("OUT_DIR")); + }} + "#, + rustc_host() + ), ) .build(); @@ -1033,11 +1044,12 @@ fn build_script_with_platform_specific_dependencies() { [RUNNING] `rustc [..] d1/src/lib.rs [..]` [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..] build.rs [..]` -[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[CWD]/target/host/{host}/debug/build/foo-[..]/build-script-build` [RUNNING] `rustc [..] src/lib.rs [..] --target {target} [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - target = target + target = target, + host = host )) .run(); } diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs index ae385b13781..0173ae4930c 100644 --- a/tests/testsuite/dep_info.rs +++ b/tests/testsuite/dep_info.rs @@ -177,18 +177,22 @@ fn build_dep_info_dylib() { assert!(p.example_lib("ex", "dylib").with_extension("d").is_file()); } +#[ignore] #[cargo_test] fn dep_path_inside_target_has_correct_path() { let p = project() .file("Cargo.toml", &basic_bin_manifest("a")) - .file("target/debug/blah", "") + .file(&format!("target/{}/debug/blah", rustc_host()), "") .file( "src/main.rs", - r#" - fn main() { - let x = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/target/debug/blah")); - } - "#, + &format!( + r#" + fn main() {{ + let x = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/target/{}/debug/blah")); + }} + "#, + rustc_host() + ), ) .build(); @@ -201,7 +205,10 @@ fn dep_path_inside_target_has_correct_path() { let depinfo = p.read_file(depinfo_path.to_str().unwrap()); let bin_path = p.bin("a"); - let target_debug_blah = Path::new("target").join("debug").join("blah"); + let target_debug_blah = Path::new("target") + .join(rustc_host()) + .join("debug") + .join("blah"); if !depinfo.lines().any(|line| { line.starts_with(&format!("{}:", bin_path.display())) && line.contains(target_debug_blah.to_str().unwrap()) @@ -218,7 +225,11 @@ fn no_rewrite_if_no_change() { let p = project().file("src/lib.rs", "").build(); p.cargo("build").run(); - let dep_info = p.root().join("target/debug/libfoo.d"); + let dep_info = p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.d"); let metadata1 = dep_info.metadata().unwrap(); p.cargo("build").run(); let metadata2 = dep_info.metadata().unwrap(); @@ -229,6 +240,7 @@ fn no_rewrite_if_no_change() { ); } +#[ignore] #[cargo_test] fn relative_depinfo_paths_ws() { if !is_nightly() { @@ -331,7 +343,7 @@ fn relative_depinfo_paths_ws() { assert_deps_contains( &p, - "target/debug/.fingerprint/pm-*/dep-lib-pm", + &format!("target/{}/debug/.fingerprint/pm-*/dep-lib-pm", rustc_host()), &[(0, "src/lib.rs"), (1, "debug/deps/libpmdep-*.rlib")], ); @@ -355,7 +367,10 @@ fn relative_depinfo_paths_ws() { assert_deps_contains( &p, - "target/debug/.fingerprint/foo-*/dep-build-script-build-script-build", + &format!( + "target/{}/debug/.fingerprint/foo-*/dep-build-script-build-script-build", + rustc_host() + ), &[(0, "build.rs"), (1, "debug/deps/libbdep-*.rlib")], ); @@ -367,6 +382,7 @@ fn relative_depinfo_paths_ws() { .run(); } +#[ignore] #[cargo_test] fn relative_depinfo_paths_no_ws() { if !is_nightly() { @@ -459,13 +475,16 @@ fn relative_depinfo_paths_no_ws() { assert_deps_contains( &p, - "target/debug/.fingerprint/pm-*/dep-lib-pm", + &format!("target/{}/debug/.fingerprint/pm-*/dep-lib-pm", rustc_host()), &[(0, "src/lib.rs"), (1, "debug/deps/libpmdep-*.rlib")], ); assert_deps_contains( &p, - "target/debug/.fingerprint/foo-*/dep-bin-foo", + &format!( + "target/{}/debug/.fingerprint/foo-*/dep-bin-foo", + rustc_host() + ), &[ (0, "src/main.rs"), ( @@ -483,7 +502,10 @@ fn relative_depinfo_paths_no_ws() { assert_deps_contains( &p, - "target/debug/.fingerprint/foo-*/dep-build-script-build-script-build", + &format!( + "target/{}/debug/.fingerprint/foo-*/dep-build-script-build-script-build", + rustc_host() + ), &[(0, "build.rs"), (1, "debug/deps/libbdep-*.rlib")], ); @@ -520,7 +542,10 @@ fn reg_dep_source_not_tracked() { assert_deps( &p, - "target/debug/.fingerprint/regdep-*/dep-lib-regdep", + &format!( + "target/{}/debug/.fingerprint/regdep-*/dep-lib-regdep", + rustc_host() + ), |info_path, entries| { for (kind, path) in entries { if *kind == 1 { @@ -534,6 +559,7 @@ fn reg_dep_source_not_tracked() { ); } +#[ignore] #[cargo_test] fn canonical_path() { if !is_nightly() { @@ -564,7 +590,7 @@ fn canonical_path() { let real = p.root().join("real_target"); real.mkdir_p(); - p.symlink(real, "target"); + p.symlink(real, &format!("target/{}", rustc_host())); p.cargo("build -Z binary-dep-depinfo") .masquerade_as_nightly_cargo() @@ -572,7 +598,10 @@ fn canonical_path() { assert_deps_contains( &p, - "target/debug/.fingerprint/foo-*/dep-lib-foo", + &format!( + "target/{}/debug/.fingerprint/foo-*/dep-lib-foo", + rustc_host() + ), &[(0, "src/lib.rs"), (1, "debug/deps/libregdep-*.rmeta")], ); } @@ -607,9 +636,19 @@ fn non_local_build_script() { .build(); p.cargo("build").run(); - let contents = p.read_file("target/debug/foo.d"); + let contents = p.read_file( + p.root() + .join("target") + .join(rustc_host()) + .join("debug/foo.d") + .to_str() + .unwrap(), + ); assert_match_exact( - "[ROOT]/foo/target/debug/foo[EXE]: [ROOT]/foo/src/main.rs", + &format!( + "[ROOT]/foo/target/{}/debug/foo[EXE]: [ROOT]/foo/src/main.rs", + rustc_host() + ), &contents, ); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 183420192b6..0824bf13931 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -34,8 +34,18 @@ fn simple() { ", ) .run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); } #[cargo_test] @@ -107,22 +117,60 @@ fn doc_deps() { ) .run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/index.html").is_file()); - assert!(p.root().join("target/doc/bar/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); // Verify that it only emits rmeta for the dependency. - assert_eq!(p.glob("target/debug/**/*.rlib").count(), 0); - assert_eq!(p.glob("target/debug/deps/libbar-*.rmeta").count(), 1); + assert_eq!( + p.glob(format!("target/{}/debug/**/*.rlib", rustc_host())) + .count(), + 0 + ); + assert_eq!( + p.glob(format!("target/{}/debug/deps/libbar-*.rmeta", rustc_host())) + .count(), + 1 + ); p.cargo("doc") .env("CARGO_LOG", "cargo::ops::cargo_rustc::fingerprint") .with_stdout("") .run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/index.html").is_file()); - assert!(p.root().join("target/doc/bar/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); } #[cargo_test] @@ -155,9 +203,24 @@ fn doc_no_deps() { ) .run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/index.html").is_file()); - assert!(!p.root().join("target/doc/bar/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); } #[cargo_test] @@ -182,9 +245,24 @@ fn doc_only_bin() { p.cargo("doc -v").run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/bar/index.html").is_file()); - assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); } #[cargo_test] @@ -271,13 +349,13 @@ fn doc_multiple_targets_same_name() { .build(); p.cargo("doc --workspace") - .with_stderr_unordered( + .with_stderr_unordered(&format!( "\ warning: output filename collision. The bin target `foo_lib` in package `foo v0.1.0 ([ROOT]/foo/foo)` \ has the same output filename as the lib target `foo_lib` in package \ `bar v0.1.0 ([ROOT]/foo/bar)`. -Colliding filename is: [ROOT]/foo/target/doc/foo_lib/index.html +Colliding filename is: [ROOT]/foo/target/{}/doc/foo_lib/index.html The targets should have unique names. This is a known bug where multiple crates with the same name use the same path; see . @@ -285,7 +363,8 @@ the same path; see . [DOCUMENTING] foo v0.1.0 ([ROOT]/foo/foo) [FINISHED] [..] ", - ) + rustc_host() + )) .run(); } @@ -401,7 +480,7 @@ fn doc_lib_bin_same_name_documents_lib() { ", ) .run(); - let doc_html = p.read_file("target/doc/foo/index.html"); + let doc_html = p.read_file(&format!("target/{}/doc/foo/index.html", rustc_host())); assert!(doc_html.contains("Library")); assert!(!doc_html.contains("Binary")); } @@ -436,7 +515,7 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { ", ) .run(); - let doc_html = p.read_file("target/doc/foo/index.html"); + let doc_html = p.read_file(&format!("target/{}/doc/foo/index.html", rustc_host())); assert!(doc_html.contains("Library")); assert!(!doc_html.contains("Binary")); } @@ -472,7 +551,7 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() { ", ) .run(); - let doc_html = p.read_file("target/doc/foo/index.html"); + let doc_html = p.read_file(&format!("target/{}/doc/foo/index.html", rustc_host())); assert!(!doc_html.contains("Library")); assert!(doc_html.contains("Binary")); } @@ -508,7 +587,7 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() { ", ) .run(); - let doc_html = p.read_file("target/doc/foo/index.html"); + let doc_html = p.read_file(&format!("target/{}/doc/foo/index.html", rustc_host())); assert!(!doc_html.contains("Library")); assert!(doc_html.contains("Binary")); } @@ -831,9 +910,24 @@ fn doc_multiple_deps() { p.cargo("doc -p bar -p baz -v").run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/bar/index.html").is_file()); - assert!(p.root().join("target/doc/baz/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/baz/index.html") + .is_file()); } #[cargo_test] @@ -890,9 +984,24 @@ fn features() { ", ) .run(); - assert!(p.root().join("target/doc").is_dir()); - assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); - assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar.html") + .is_file()); // Check that turning the feature off will remove the files. p.cargo("doc") .with_stderr( @@ -904,8 +1013,18 @@ fn features() { ", ) .run(); - assert!(!p.root().join("target/doc/foo/fn.foo.html").is_file()); - assert!(!p.root().join("target/doc/bar/fn.bar.html").is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo.html") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar.html") + .is_file()); // And switching back will rebuild and bring them back. p.cargo("doc --features foo") .with_stderr( @@ -916,8 +1035,18 @@ fn features() { ", ) .run(); - assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); - assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar.html") + .is_file()); } #[cargo_test] @@ -933,12 +1062,22 @@ fn rerun_when_dir_removed() { .build(); p.cargo("doc").run(); - assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); - fs::remove_dir_all(p.root().join("target/doc/foo")).unwrap(); + fs::remove_dir_all(p.root().join("target").join(rustc_host()).join("doc/foo")).unwrap(); p.cargo("doc").run(); - assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); } #[cargo_test] @@ -963,7 +1102,12 @@ fn document_only_lib() { ) .build(); p.cargo("doc --lib").run(); - assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); } #[cargo_test] @@ -1235,8 +1379,14 @@ fn doc_workspace_open_different_library_and_package_names() { p.cargo("doc --open") .env("BROWSER", "echo") .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") - .with_stderr_contains("[..] [CWD]/target/doc/foolib/index.html") - .with_stdout_contains("[CWD]/target/doc/foolib/index.html") + .with_stderr_contains(&format!( + "[..] [CWD]/target/{}/doc/foolib/index.html", + rustc_host() + )) + .with_stdout_contains(&format!( + "[CWD]/target/{}/doc/foolib/index.html", + rustc_host() + )) .run(); p.change_file( @@ -1250,7 +1400,10 @@ fn doc_workspace_open_different_library_and_package_names() { // check that the cargo config overrides the browser env var p.cargo("doc --open") .env("BROWSER", "true") - .with_stdout_contains("a [CWD]/target/doc/foolib/index.html") + .with_stdout_contains(&format!( + "a [CWD]/target/{}/doc/foolib/index.html", + rustc_host() + )) .run(); } @@ -1282,7 +1435,10 @@ fn doc_workspace_open_binary() { p.cargo("doc --open") .env("BROWSER", "echo") .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") - .with_stderr_contains("[..] Opening [CWD]/target/doc/foobin/index.html") + .with_stderr_contains(&format!( + "[..] Opening [CWD]/target/{}/doc/foobin/index.html", + rustc_host() + )) .run(); } @@ -1317,7 +1473,10 @@ fn doc_workspace_open_binary_and_library() { p.cargo("doc --open") .env("BROWSER", "echo") .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") - .with_stderr_contains("[..] Opening [CWD]/target/doc/foolib/index.html") + .with_stderr_contains(&format!( + "[..] Opening [CWD]/target/{}/doc/foolib/index.html", + rustc_host() + )) .run(); } @@ -1409,10 +1568,17 @@ fn doc_private_items() { .build(); foo.cargo("doc --document-private-items").run(); - assert!(foo.root().join("target/doc").is_dir()); assert!(foo .root() - .join("target/doc/foo/private/index.html") + .join("target") + .join(rustc_host()) + .join("doc") + .is_dir()); + assert!(foo + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/private/index.html") .is_file()); } @@ -1607,20 +1773,54 @@ fn bin_private_items() { ) .run(); - assert!(p.root().join("target/doc/foo/index.html").is_file()); - assert!(p.root().join("target/doc/foo/fn.foo_pub.html").is_file()); - assert!(p.root().join("target/doc/foo/fn.foo_priv.html").is_file()); assert!(p .root() - .join("target/doc/foo/struct.FooStruct.html") + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo_pub.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo_priv.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/struct.FooStruct.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/enum.FooEnum.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/trait.FooTrait.html") .is_file()); - assert!(p.root().join("target/doc/foo/enum.FooEnum.html").is_file()); assert!(p .root() - .join("target/doc/foo/trait.FooTrait.html") + .join("target") + .join(rustc_host()) + .join("doc/foo/type.FooType.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/foo_mod/index.html") .is_file()); - assert!(p.root().join("target/doc/foo/type.FooType.html").is_file()); - assert!(p.root().join("target/doc/foo/foo_mod/index.html").is_file()); } #[cargo_test] @@ -1667,13 +1867,43 @@ fn bin_private_items_deps() { ) .run(); - assert!(p.root().join("target/doc/foo/index.html").is_file()); - assert!(p.root().join("target/doc/foo/fn.foo_pub.html").is_file()); - assert!(p.root().join("target/doc/foo/fn.foo_priv.html").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo_pub.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/fn.foo_priv.html") + .is_file()); - assert!(p.root().join("target/doc/bar/index.html").is_file()); - assert!(p.root().join("target/doc/bar/fn.bar_pub.html").is_file()); - assert!(!p.root().join("target/doc/bar/fn.bar_priv.html").exists()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar_pub.html") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("doc/bar/fn.bar_priv.html") + .exists()); } #[cargo_test] @@ -1701,7 +1931,11 @@ fn crate_versions() { ) .run(); - let output_path = p.root().join("target/doc/foo/index.html"); + let output_path = p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html"); let output_documentation = fs::read_to_string(&output_path).unwrap(); assert!(output_documentation.contains("Version 1.2.4")); @@ -1723,7 +1957,11 @@ fn crate_versions_flag_is_overridden() { .build(); let output_documentation = || { - let output_path = p.root().join("target/doc/foo/index.html"); + let output_path = p + .root() + .join("target") + .join(rustc_host()) + .join("doc/foo/index.html"); fs::read_to_string(&output_path).unwrap() }; let asserts = |html: String| { @@ -1850,9 +2088,11 @@ LLVM version: 9.0 dummy_project.cargo("doc").run(); - let fingerprint: RustDocFingerprint = - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) - .expect("JSON Serde fail"); + let fingerprint: RustDocFingerprint = serde_json::from_str(&dummy_project.read_file(&format!( + "target/host/{}/.rustdoc_fingerprint.json", + rustc_host() + ))) + .expect("JSON Serde fail"); // Check that the fingerprint contains the actual rustc version // which has been used to compile the docs. @@ -1871,12 +2111,13 @@ LLVM version: 9.0 // inside it. We will also place a bogus file inside of the `doc/` folder to ensure // it gets removed as we expect on the next doc compilation. dummy_project.change_file( - "target/.rustdoc_fingerprint.json", + &format!("target/host/{}/.rustdoc_fingerprint.json", rustc_host()), &old_rustc_verbose_version, ); + dummy_project.host_dir().join("doc").mkdir_p(); fs::write( - dummy_project.build_dir().join("doc/bogus_file"), + dummy_project.host_dir().join("doc/bogus_file"), String::from("This is a bogus file and should be removed!"), ) .expect("Error writing test bogus file"); @@ -1887,11 +2128,13 @@ LLVM version: 9.0 // It should also remove the bogus file we created above. dummy_project.cargo("doc").run(); - assert!(!dummy_project.build_dir().join("doc/bogus_file").exists()); + assert!(!dummy_project.host_dir().join("doc/bogus_file").exists()); - let fingerprint: RustDocFingerprint = - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) - .expect("JSON Serde fail"); + let fingerprint: RustDocFingerprint = serde_json::from_str(&dummy_project.read_file(&format!( + "target/host/{}/.rustdoc_fingerprint.json", + rustc_host() + ))) + .expect("JSON Serde fail"); // Check that the fingerprint contains the actual rustc version // which has been used to compile the docs. @@ -1933,9 +2176,11 @@ LLVM version: 9.0 dummy_project.cargo("doc --target").arg(rustc_host()).run(); - let fingerprint: RustDocFingerprint = - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) - .expect("JSON Serde fail"); + let fingerprint: RustDocFingerprint = serde_json::from_str(&dummy_project.read_file(&format!( + "target/host/{}/.rustdoc_fingerprint.json", + rustc_host() + ))) + .expect("JSON Serde fail"); // Check that the fingerprint contains the actual rustc version // which has been used to compile the docs. @@ -1954,15 +2199,13 @@ LLVM version: 9.0 // inside it. We will also place a bogus file inside of the `doc/` folder to ensure // it gets removed as we expect on the next doc compilation. dummy_project.change_file( - "target/.rustdoc_fingerprint.json", + &format!("target/host/{}/.rustdoc_fingerprint.json", rustc_host()), &old_rustc_verbose_version, ); + dummy_project.host_dir().join("doc").mkdir_p(); fs::write( - dummy_project - .build_dir() - .join(rustc_host()) - .join("doc/bogus_file"), + dummy_project.host_dir().join("doc/bogus_file"), String::from("This is a bogus file and should be removed!"), ) .expect("Error writing test bogus file"); @@ -1973,15 +2216,13 @@ LLVM version: 9.0 // It should also remove the bogus file we created above. dummy_project.cargo("doc --target").arg(rustc_host()).run(); - assert!(!dummy_project - .build_dir() - .join(rustc_host()) - .join("doc/bogus_file") - .exists()); + assert!(!dummy_project.host_dir().join("doc/bogus_file").exists()); - let fingerprint: RustDocFingerprint = - serde_json::from_str(&dummy_project.read_file("target/.rustdoc_fingerprint.json")) - .expect("JSON Serde fail"); + let fingerprint: RustDocFingerprint = serde_json::from_str(&dummy_project.read_file(&format!( + "target/host/{}/.rustdoc_fingerprint.json", + rustc_host() + ))) + .expect("JSON Serde fail"); // Check that the fingerprint contains the actual rustc version // which has been used to compile the docs. @@ -2014,7 +2255,7 @@ fn doc_fingerprint_unusual_behavior() { assert!(real_doc.join("foo/index.html").exists()); // Pretend that the last build was generated by an older version. p.change_file( - "target/.rustdoc_fingerprint.json", + &format!("target/host/{}/.rustdoc_fingerprint.json", rustc_host()), "{\"rustc_vv\": \"I am old\"}", ); // Change file to trigger a new build. @@ -2031,7 +2272,7 @@ fn doc_fingerprint_unusual_behavior() { assert!(real_doc.join("foo/index.html").exists()); // And also check the -Z flag behavior. p.change_file( - "target/.rustdoc_fingerprint.json", + &format!("target/host/{}/.rustdoc_fingerprint.json", rustc_host()), "{\"rustc_vv\": \"I am old\"}", ); // Change file to trigger a new build. diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 49a61301bac..2a9416429c8 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -2,7 +2,7 @@ use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::{Dependency, Package}; -use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{basic_manifest, project, rustc_host}; #[cargo_test] fn invalid1() { @@ -1852,7 +1852,7 @@ fn registry_summary_order_doesnt_matter() { .build(); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "\ [UPDATING] [..] [DOWNLOADING] crates ... @@ -1862,9 +1862,10 @@ fn registry_summary_order_doesnt_matter() { [COMPILING] bar v0.1.0 [COMPILING] foo v0.1.0 [..] [FINISHED] [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .with_stdout("it works") .run(); } diff --git a/tests/testsuite/features2.rs b/tests/testsuite/features2.rs index e82cbaf5425..c73edabbfb9 100644 --- a/tests/testsuite/features2.rs +++ b/tests/testsuite/features2.rs @@ -434,25 +434,28 @@ fn decouple_dev_deps() { ) .file( "tests/t1.rs", - r#" - #[test] - fn test_t1() { - assert_eq!(foo::foo(), 3); - assert_eq!(common::foo(), 3); - assert_eq!(common::X, 3); - assert_eq!(foo::build_time(), 3); - } - - #[test] - fn test_main() { - // Features are unified for main when run with `cargo test`, - // even with the new resolver. - let s = std::process::Command::new("target/debug/foo") - .arg("3") - .status().unwrap(); - assert!(s.success()); - } - "#, + &format!( + r#" + #[test] + fn test_t1() {{ + assert_eq!(foo::foo(), 3); + assert_eq!(common::foo(), 3); + assert_eq!(common::X, 3); + assert_eq!(foo::build_time(), 3); + }} + + #[test] + fn test_main() {{ + // Features are unified for main when run with `cargo test`, + // even with the new resolver. + let s = std::process::Command::new("target/{}/debug/foo") + .arg("3") + .status().unwrap(); + assert!(s.success()); + }} + "#, + rustc_host() + ), ) .build(); @@ -604,23 +607,26 @@ fn build_script_runtime_features() { ) .file( "tests/t1.rs", - r#" - #[test] - fn test_t1() { - assert_eq!(common::foo(), common::build_time()); - assert_eq!(common::foo(), - std::env::var("CARGO_FEATURE_EXPECT").unwrap().parse().unwrap()); - } - - #[test] - fn test_main() { - // Features are unified for main when run with `cargo test`, - // even with the new resolver. - let s = std::process::Command::new("target/debug/foo") - .status().unwrap(); - assert!(s.success()); - } - "#, + &format!( + r#" + #[test] + fn test_t1() {{ + assert_eq!(common::foo(), common::build_time()); + assert_eq!(common::foo(), + std::env::var("CARGO_FEATURE_EXPECT").unwrap().parse().unwrap()); + }} + + #[test] + fn test_main() {{ + // Features are unified for main when run with `cargo test`, + // even with the new resolver. + let s = std::process::Command::new("target/{}/debug/foo") + .status().unwrap(); + assert!(s.success()); + }} + "#, + rustc_host() + ), ) .build(); @@ -681,17 +687,20 @@ fn cyclical_dev_dep() { ) .file( "tests/t1.rs", - r#" - #[test] - fn integration_links() { - foo::assert_dev(true); - // The lib linked with main.rs will also be unified. - let s = std::process::Command::new("target/debug/foo") - .arg("true") - .status().unwrap(); - assert!(s.success()); - } - "#, + &format!( + r#" + #[test] + fn integration_links() {{ + foo::assert_dev(true); + // The lib linked with main.rs will also be unified. + let s = std::process::Command::new("target/{}/debug/foo") + .arg("true") + .status().unwrap(); + assert!(s.success()); + }} + "#, + rustc_host() + ), ) .build(); @@ -1047,6 +1056,7 @@ fn decouple_proc_macro() { .exists()); } +#[ignore] #[cargo_test] fn proc_macro_ws() { // Checks for bug with proc-macro in a workspace with dependency (shouldn't panic). @@ -1530,7 +1540,7 @@ fn resolver_enables_new_features() { // Only normal. p.cargo("run --bin a") .env("EXPECTED_FEATS", "1") - .with_stderr( + .with_stderr(&format!( "\ [UPDATING] [..] [DOWNLOADING] crates ... @@ -1538,9 +1548,10 @@ fn resolver_enables_new_features() { [COMPILING] common v1.0.0 [COMPILING] a v0.1.0 [..] [FINISHED] [..] -[RUNNING] `target/debug/a[EXE]` +[RUNNING] `target/{}/debug/a[EXE]` ", - ) + rustc_host() + )) .run(); // only normal+dev @@ -1916,6 +1927,7 @@ fn doc_optional() { .run(); } +#[ignore] #[cargo_test] fn minimal_download() { // Various checks that it only downloads the minimum set of dependencies diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs index 8147a7b6d66..6aeff8b1aef 100644 --- a/tests/testsuite/features_namespaced.rs +++ b/tests/testsuite/features_namespaced.rs @@ -2,7 +2,7 @@ use super::features2::switch_to_resolver_2; use cargo_test_support::registry::{Dependency, Package}; -use cargo_test_support::{project, publish}; +use cargo_test_support::{project, publish, rustc_host}; #[cargo_test] fn gated() { @@ -475,20 +475,21 @@ fn no_implicit_feature() { p.cargo("run -Z namespaced-features") .masquerade_as_nightly_cargo() - .with_stderr( + .with_stderr(&format!( "\ [UPDATING] [..] [COMPILING] foo v0.1.0 [..] [FINISHED] [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .with_stdout("") .run(); p.cargo("run -Z namespaced-features --features regex") .masquerade_as_nightly_cargo() - .with_stderr_unordered( + .with_stderr_unordered(&format!( "\ [DOWNLOADING] crates ... [DOWNLOADED] regex v1.0.0 [..] @@ -497,9 +498,10 @@ fn no_implicit_feature() { [COMPILING] lazy_static v1.0.0 [COMPILING] foo v0.1.0 [..] [FINISHED] [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .with_stdout("regex") .run(); diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index f9aac34b5d5..83a76251220 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -2,11 +2,11 @@ use cargo::core::Edition; use cargo_test_support::compare::assert_match_exact; -use cargo_test_support::git; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::{Dependency, Package}; use cargo_test_support::tools; use cargo_test_support::{basic_manifest, is_nightly, project}; +use cargo_test_support::{git, rustc_host}; #[cargo_test] fn do_not_fix_broken_builds() { @@ -140,7 +140,13 @@ fn broken_fixes_backed_out() { p.cargo("fix --allow-no-vcs --lib") .cwd("bar") .env("__CARGO_FIX_YOLO", "1") - .env("RUSTC", p.root().join("foo/target/debug/foo")) + .env( + "RUSTC", + p.root() + .join("foo/target") + .join(rustc_host()) + .join("debug/foo"), + ) .with_stderr_contains( "warning: failed to automatically apply fixes suggested by rustc \ to crate `bar`\n\ @@ -1349,7 +1355,13 @@ fn fix_to_broken_code() { // Attempt to fix code, but our shim will always fail the second compile p.cargo("fix --allow-no-vcs --broken-code") .cwd("bar") - .env("RUSTC", p.root().join("foo/target/debug/foo")) + .env( + "RUSTC", + p.root() + .join("foo/target") + .join(rustc_host()) + .join("debug/foo"), + ) .with_status(101) .with_stderr_contains("[WARNING] failed to automatically apply fixes [..]") .run(); diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index bdbd44aa95e..849cc7eb45b 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -365,52 +365,56 @@ fn changing_bin_paths_common_target_features_caches_targets() { p.cargo("run") .cwd("a") .with_stdout("ftest off") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling dep_crate v0.0.1 ([..]) [..]Compiling a v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a[EXE]` +[RUNNING] `[..]target/{}/debug/a[EXE]` ", - ) + rustc_host() + )) .run(); p.cargo("clean -p a").cwd("a").run(); p.cargo("run") .cwd("a") .with_stdout("ftest off") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling a v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a[EXE]` +[RUNNING] `[..]target/{}/debug/a[EXE]` ", - ) + rustc_host() + )) .run(); /* Build and rebuild b/. Ensure dep_crate only builds once */ p.cargo("run") .cwd("b") .with_stdout("ftest on") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling dep_crate v0.0.1 ([..]) [..]Compiling b v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b[EXE]` +[RUNNING] `[..]target/{}/debug/b[EXE]` ", - ) + rustc_host() + )) .run(); p.cargo("clean -p b").cwd("b").run(); p.cargo("run") .cwd("b") .with_stdout("ftest on") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling b v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b[EXE]` +[RUNNING] `[..]target/{}/debug/b[EXE]` ", - ) + rustc_host() + )) .run(); /* Build a/ package again. If we cache different feature dep builds correctly, @@ -419,13 +423,14 @@ fn changing_bin_paths_common_target_features_caches_targets() { p.cargo("run") .cwd("a") .with_stdout("ftest off") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling a v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a[EXE]` +[RUNNING] `[..]target/{}/debug/a[EXE]` ", - ) + rustc_host() + )) .run(); /* Build b/ package again. If we cache different feature dep builds correctly, @@ -434,13 +439,14 @@ fn changing_bin_paths_common_target_features_caches_targets() { p.cargo("run") .cwd("b") .with_stdout("ftest on") - .with_stderr( + .with_stderr(&format!( "\ [..]Compiling b v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b[EXE]` +[RUNNING] `[..]target/{}/debug/b[EXE]` ", - ) + rustc_host() + )) .run(); } @@ -821,13 +827,14 @@ fn rebuild_if_environment_changes() { p.cargo("run") .with_stdout("old desc") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .run(); p.change_file( @@ -843,13 +850,14 @@ fn rebuild_if_environment_changes() { p.cargo("run") .with_stdout("new desc") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .run(); } @@ -1339,6 +1347,7 @@ fn fingerprint_cleaner_does_not_rebuild() { .run(); } +#[ignore] #[cargo_test] fn reuse_panic_build_dep_test() { let p = project() @@ -1737,6 +1746,7 @@ fn script_fails_stay_dirty() { .run(); } +#[ignore] #[cargo_test] fn simulated_docker_deps_stay_cached() { // Test what happens in docker where the nanoseconds are zeroed out. @@ -1918,7 +1928,11 @@ fn metadata_change_invalidates() { p.cargo("build -v") .with_stderr_contains("[FRESH] foo[..]") .run(); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rlib").count(), 1); + assert_eq!( + p.glob(&format!("target/{}/debug/deps/libfoo-*.rlib", rustc_host())) + .count(), + 1 + ); } #[cargo_test] @@ -1953,7 +1967,11 @@ fn edition_change_invalidates() { p.cargo("build -v") .with_stderr_contains("[FRESH] foo[..]") .run(); - assert_eq!(p.glob("target/debug/deps/libfoo-*.rlib").count(), 1); + assert_eq!( + p.glob(&format!("target/{}/debug/deps/libfoo-*.rlib", rustc_host())) + .count(), + 1 + ); } #[cargo_test] @@ -2013,6 +2031,7 @@ fn rename_with_path_deps() { .run(); } +#[ignore] #[cargo_test] fn move_target_directory_with_path_deps() { let p = project() @@ -2436,13 +2455,14 @@ fn linking_interrupted() { // Build again, shouldn't be fresh. p.cargo("test --test t1") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo [..] [FINISHED] [..] -[RUNNING] tests/t1.rs (target/debug/deps/t1[..]) +[RUNNING] tests/t1.rs (target/{}/debug/deps/t1[..]) ", - ) + rustc_host() + )) .run(); } diff --git a/tests/testsuite/future_incompat_report.rs b/tests/testsuite/future_incompat_report.rs index 2fbbdb91e24..f4e7c580e47 100644 --- a/tests/testsuite/future_incompat_report.rs +++ b/tests/testsuite/future_incompat_report.rs @@ -88,6 +88,7 @@ note: 0 dependencies had future-incompatible warnings .run(); } +#[ignore] #[cargo_test] #[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478 fn test_single_crate() { @@ -114,6 +115,7 @@ fn test_single_crate() { } } +#[ignore] #[cargo_test] #[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478 fn test_multi_crate() { @@ -222,6 +224,7 @@ fn test_multi_crate() { assert_eq!(lines.next(), None); } +#[ignore] #[cargo_test] #[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478 fn color() { @@ -247,6 +250,7 @@ fn color() { .run(); } +#[ignore] #[cargo_test] #[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478 fn bad_ids() { @@ -284,6 +288,7 @@ Available IDs are: 1 .run(); } +#[ignore] #[cargo_test] #[ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478 fn suggestions_for_updates() { diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 46830457fc0..c038481a956 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -11,7 +11,9 @@ use std::sync::Arc; use std::thread; use cargo_test_support::paths::{self, CargoPathExt}; -use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; +use cargo_test_support::{ + basic_lib_manifest, basic_manifest, git, main_file, path2url, project, rustc_host, +}; use cargo_test_support::{sleep_ms, t, Project}; fn disable_git_cli() -> bool { @@ -1168,15 +1170,16 @@ fn dep_with_changed_submodule() { println!("first run"); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "[UPDATING] git repository `[..]`\n\ [UPDATING] git submodule `file://[..]/dep2`\n\ [COMPILING] dep1 v0.5.0 ([..])\n\ [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target/debug/foo[EXE]`\n", - ) + [RUNNING] `target/{}/debug/foo[EXE]`\n", + rustc_host() + )) .with_stdout("project2\n") .run(); @@ -1224,13 +1227,14 @@ fn dep_with_changed_submodule() { println!("last run"); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "[COMPILING] dep1 v0.5.0 ([..])\n\ [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target/debug/foo[EXE]`\n", - ) + [RUNNING] `target/{}/debug/foo[EXE]`\n", + rustc_host() + )) .with_stdout("project3\n") .run(); } @@ -1296,13 +1300,14 @@ fn dev_deps_with_testing() { // Make sure we use the previous resolution of `bar` instead of updating it // a second time. p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..] [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test tests::foo ... ok") .run(); } diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 93e237591ab..34116166b63 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -1,6 +1,6 @@ //! Tests for the `cargo init` command. -use cargo_test_support::{command_is_available, paths, Execs}; +use cargo_test_support::{command_is_available, paths, rustc_host, Execs}; use std::env; use std::fs; use std::process::Command; @@ -50,7 +50,11 @@ fn simple_bin() { cargo_process("build").cwd(&path).run(); assert!(paths::root() - .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .join(&format!( + "foo/target/{}/debug/foo{}", + rustc_host(), + env::consts::EXE_SUFFIX + )) .is_file()); } diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 5d16ed99a03..e4d7c0e6e40 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -3,12 +3,12 @@ use std::fs::{self, OpenOptions}; use std::io::prelude::*; -use cargo_test_support::cross_compile; use cargo_test_support::git; use cargo_test_support::registry::{self, registry_path, registry_url, Package}; use cargo_test_support::{ basic_manifest, cargo_process, no_such_file_err_msg, project, symlink_supported, t, }; +use cargo_test_support::{cross_compile, rustc_host}; use cargo_test_support::install::{ assert_has_installed_exe, assert_has_not_installed_exe, cargo_home, @@ -391,6 +391,7 @@ fn install_target_dir() { let mut path = p.root(); path.push("td_test"); assert!(path.exists()); + path.push(rustc_host()); #[cfg(not(windows))] path.push("release/foo"); @@ -1326,13 +1327,29 @@ fn custom_target_dir_for_git_source() { cargo_process("install --git") .arg(p.url().to_string()) .run(); - assert!(!paths::root().join("target/release").is_dir()); + assert!(!paths::root() + .join("target") + .join(rustc_host()) + .join("release") + .is_dir()); cargo_process("install --force --git") .arg(p.url().to_string()) .env("CARGO_TARGET_DIR", "target") .run(); - assert!(paths::root().join("target/release").is_dir()); + println!( + "{}", + paths::root() + .join("target") + .join(rustc_host()) + .join("release") + .display() + ); + assert!(paths::root() + .join("target") + .join(rustc_host()) + .join("release") + .is_dir()); } #[cargo_test] @@ -1701,6 +1718,7 @@ fn install_yanked_cargo_package() { .run(); } +#[ignore] #[cargo_test] fn install_cargo_package_in_a_patched_workspace() { pkg("foo", "0.1.0"); diff --git a/tests/testsuite/lto.rs b/tests/testsuite/lto.rs index 5b431fdb298..bb8a2ee105b 100644 --- a/tests/testsuite/lto.rs +++ b/tests/testsuite/lto.rs @@ -1,6 +1,6 @@ use cargo::core::compiler::Lto; use cargo_test_support::registry::Package; -use cargo_test_support::{basic_manifest, project, Project}; +use cargo_test_support::{basic_manifest, project, rustc_host, Project}; use std::process::Output; #[cargo_test] @@ -88,6 +88,7 @@ fn build_dep_not_ltod() { .run(); } +#[ignore] #[cargo_test] fn complicated() { Package::new("dep-shared", "0.0.1") @@ -512,7 +513,7 @@ fn cdylib_and_rlib() { ) .run(); p.cargo("test --release -v --manifest-path bar/Cargo.toml") - .with_stderr_unordered( + .with_stderr_unordered(&format!( "\ [COMPILING] registry v0.0.1 [COMPILING] registry-shared v0.0.1 @@ -523,12 +524,13 @@ fn cdylib_and_rlib() { [RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no [..]--test[..] [RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no [..]--test[..] [FINISHED] [..] -[RUNNING] [..]target/release/deps/bar-[..] -[RUNNING] [..]target/release/deps/b-[..] +[RUNNING] [..]target/{target}/release/deps/bar-[..] +[RUNNING] [..]target/{target}/release/deps/b-[..] [DOCTEST] bar [RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C embed-bitcode=no[..] ", - ) + target = rustc_host() + )) .run(); } diff --git a/tests/testsuite/member_errors.rs b/tests/testsuite/member_errors.rs index 10533b292c6..9f4806a8244 100644 --- a/tests/testsuite/member_errors.rs +++ b/tests/testsuite/member_errors.rs @@ -151,7 +151,8 @@ fn member_manifest_version_error() { cargo_home(), ); let ws = Workspace::new(&p.root().join("Cargo.toml"), &config).unwrap(); - let compile_options = CompileOptions::new(&config, CompileMode::Build).unwrap(); + let rustc = config.load_global_rustc(Some(&ws)); + let compile_options = CompileOptions::new(&config, rustc, CompileMode::Build).unwrap(); let member_bar = ws.members().find(|m| &*m.name() == "bar").unwrap(); let error = ops::compile(&ws, &compile_options).map(|_| ()).unwrap_err(); diff --git a/tests/testsuite/metabuild.rs b/tests/testsuite/metabuild.rs index d37d09b6394..b78706f66f1 100644 --- a/tests/testsuite/metabuild.rs +++ b/tests/testsuite/metabuild.rs @@ -233,6 +233,7 @@ fn metabuild_lib_name() { .run(); } +#[ignore] #[cargo_test] fn metabuild_fresh() { if is_coarse_mtime() { @@ -468,8 +469,8 @@ fn metabuild_build_plan() { "kind": null, "deps": [], "outputs": [ - "[..]/target/debug/deps/libmb-[..].rlib", - "[..]/target/debug/deps/libmb-[..].rmeta" + "[..]/target/host/$TARGET/debug/deps/libmb-[..].rlib", + "[..]/target/host/$TARGET/debug/deps/libmb-[..].rmeta" ], "links": {}, "program": "rustc", @@ -485,8 +486,8 @@ fn metabuild_build_plan() { "kind": null, "deps": [], "outputs": [ - "[..]/target/debug/deps/libmb_other-[..].rlib", - "[..]/target/debug/deps/libmb_other-[..].rmeta" + "[..]/target/host/$TARGET/debug/deps/libmb_other-[..].rlib", + "[..]/target/host/$TARGET/debug/deps/libmb_other-[..].rmeta" ], "links": {}, "program": "rustc", @@ -513,11 +514,11 @@ fn metabuild_build_plan() { "package_version": "0.0.1", "target_kind": ["custom-build"], "compile_mode": "run-custom-build", - "kind": null, + "kind": "$TARGET", "deps": [2], "outputs": [], "links": {}, - "program": "[..]/foo/target/debug/build/foo-[..]/metabuild-foo", + "program": "[..]/foo/target/host/$TARGET/debug/build/foo-[..]/metabuild-foo", "args": [], "env": "{...}", "cwd": "[..]" @@ -527,11 +528,11 @@ fn metabuild_build_plan() { "package_version": "0.0.1", "target_kind": ["lib"], "compile_mode": "build", - "kind": null, + "kind": "$TARGET", "deps": [3], "outputs": [ - "[..]/foo/target/debug/deps/libfoo-[..].rlib", - "[..]/foo/target/debug/deps/libfoo-[..].rmeta" + "[..]/foo/target/$TARGET/debug/deps/libfoo-[..].rlib", + "[..]/foo/target/$TARGET/debug/deps/libfoo-[..].rmeta" ], "links": "{...}", "program": "rustc", @@ -546,7 +547,7 @@ fn metabuild_build_plan() { "[..]/foo/mb-other/Cargo.toml" ] } - "#, + "#.replace("$TARGET", rustc_host()).as_str(), ) .run(); diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 312603d984f..2901678f5d2 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -2094,6 +2094,7 @@ fn deps_with_bin_only() { .run(); } +#[ignore] #[cargo_test] fn filter_platform() { // Testing the --filter-platform flag. @@ -2810,6 +2811,7 @@ fn filter_platform() { .run(); } +#[ignore] #[cargo_test] fn dep_kinds() { Package::new("bar", "0.1.0").publish(); diff --git a/tests/testsuite/multitarget.rs b/tests/testsuite/multitarget.rs index afa8ea3c9bc..dbb4a1e9c85 100644 --- a/tests/testsuite/multitarget.rs +++ b/tests/testsuite/multitarget.rs @@ -96,8 +96,18 @@ fn simple_doc() { .masquerade_as_nightly_cargo() .run(); - assert!(p.build_dir().join(&t1).join("doc/foo/index.html").is_file()); - assert!(p.build_dir().join(&t2).join("doc/foo/index.html").is_file()); + assert!(p + .root() + .join("target") + .join(&t1) + .join("doc/foo/index.html") + .is_file()); + assert!(p + .root() + .join("target") + .join(&t2) + .join("doc/foo/index.html") + .is_file()); } #[cargo_test] diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index fd5499eaea9..1e0ea508e0c 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -1,7 +1,7 @@ //! Tests for the `cargo new` command. -use cargo_test_support::cargo_process; use cargo_test_support::paths; +use cargo_test_support::{cargo_process, rustc_host}; use std::env; use std::fs::{self, File}; @@ -52,7 +52,11 @@ fn simple_bin() { cargo_process("build").cwd(&paths::root().join("foo")).run(); assert!(paths::root() - .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .join(&format!( + "foo/target/{}/debug/foo{}", + rustc_host(), + env::consts::EXE_SUFFIX + )) .is_file()); } diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index eac28090a0e..87608e632f4 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -2,7 +2,7 @@ use cargo_test_support::paths::{self, CargoPathExt}; use cargo_test_support::registry::Package; -use cargo_test_support::{basic_lib_manifest, basic_manifest, main_file, project}; +use cargo_test_support::{basic_lib_manifest, basic_manifest, main_file, project, rustc_host}; use cargo_test_support::{sleep_ms, t}; use std::fs; @@ -182,13 +182,14 @@ fn cargo_compile_with_root_dev_deps_with_testing() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); } @@ -765,13 +766,14 @@ fn dev_deps_no_rebuild_lib() { .run(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] [..] v0.5.0 ([CWD][..]) [COMPILING] [..] v0.5.0 ([CWD][..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); } @@ -997,8 +999,18 @@ fn workspace_produces_rlib() { p.cargo("build").run(); - assert!(p.root().join("target/debug/libtop.rlib").is_file()); - assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libtop.rlib") + .is_file()); + assert!(!p + .root() + .join("target") + .join(rustc_host()) + .join("debug/libfoo.rlib") + .is_file()); } #[cargo_test] diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 14592aadf13..11a22d1f863 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -210,7 +210,7 @@ fn plugin_with_dynamic_native_dependency() { build.cargo("build").run(); - let root = build.root().join("target").join("debug"); + let root = build.root().join("target").join(rustc_host()).join("debug"); foo.cargo("build -v").env("BUILDER_ROOT", root).run(); } diff --git a/tests/testsuite/profile_custom.rs b/tests/testsuite/profile_custom.rs index d8da18eeea3..c58271523d1 100644 --- a/tests/testsuite/profile_custom.rs +++ b/tests/testsuite/profile_custom.rs @@ -370,6 +370,7 @@ fn conflicting_usage() { .run(); } +#[ignore] #[cargo_test] fn clean_custom_dirname() { let p = project() diff --git a/tests/testsuite/profile_overrides.rs b/tests/testsuite/profile_overrides.rs index 661fada49c8..b83b2ba2d0c 100644 --- a/tests/testsuite/profile_overrides.rs +++ b/tests/testsuite/profile_overrides.rs @@ -132,6 +132,7 @@ fn profile_override_bad_settings() { } } +#[ignore] #[cargo_test] fn profile_override_hierarchy() { // Test that the precedence rules are correct for different types. diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 045f2a3e065..ae14c52b331 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -2,7 +2,7 @@ //! example, the `test` profile applying to test targets, but not other //! targets, etc. -use cargo_test_support::{basic_manifest, is_nightly, project, Project}; +use cargo_test_support::{basic_manifest, is_nightly, project, rustc_host, Project}; fn all_target_project() -> Project { // This abuses the `codegen-units` setting so that we can verify exactly @@ -91,7 +91,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").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("build -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 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=5 -C debuginfo=2 [..] @@ -99,12 +99,12 @@ fn profile_selection_build() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{}/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/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] [FINISHED] dev [unoptimized + debuginfo] [..] -").run(); +", rustc_host())).run(); p.cargo("build -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -123,7 +123,7 @@ fn profile_selection_build_release() { let p = all_target_project(); // `build --release` - p.cargo("build --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("build --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 panic=abort[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] @@ -131,12 +131,12 @@ fn profile_selection_build_release() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] -[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{}/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/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [FINISHED] release [optimized] [..] -").run(); +", rustc_host())).run(); p.cargo("build --release -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -190,7 +190,7 @@ fn profile_selection_build_all_targets() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{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={affected} -C debuginfo=2 --test [..]` @@ -201,7 +201,7 @@ fn profile_selection_build_all_targets() { [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] [..] -", affected=affected)).run(); +", affected=affected, target=rustc_host())).run(); p.cargo("build -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -258,7 +258,7 @@ fn profile_selection_build_all_targets_release() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] -[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{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={affected} --test [..]` @@ -269,7 +269,7 @@ fn profile_selection_build_all_targets_release() { [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] [..] -", affected=affected)).run(); +", affected=affected, target=rustc_host())).run(); p.cargo("build --all-targets --release -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -317,7 +317,7 @@ fn profile_selection_test() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{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={affected} -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..] @@ -332,7 +332,7 @@ fn profile_selection_test() { [RUNNING] `[..]/deps/test1-[..]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..] -", affected=affected)).run(); +", affected=affected, target=rustc_host())).run(); p.cargo("test -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -386,7 +386,7 @@ fn profile_selection_test_release() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] -[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` +[RUNNING] `[..]/target/host/{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 [..] @@ -401,7 +401,7 @@ fn profile_selection_test_release() { [RUNNING] `[..]/deps/test1-[..]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..]` -", affected=affected)).run(); +", affected=affected, target=rustc_host())).run(); p.cargo("test --release -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -454,7 +454,7 @@ fn profile_selection_bench() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] -[RUNNING] `[..]target/release/build/foo-[..]/build-script-build` +[RUNNING] `[..]target/host/{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={affected} [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units={affected} [..] @@ -466,7 +466,7 @@ fn profile_selection_bench() { [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/bench1-[..] --bench` -", affected=affected)).run(); +", affected=affected, target=rustc_host())).run(); p.cargo("bench -vv") .masquerade_as_nightly_cargo() .with_stderr_unordered( @@ -511,7 +511,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").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("check --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=5 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..] @@ -520,7 +520,7 @@ fn profile_selection_check_all_targets() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]target/host/{}/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 panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..] @@ -531,7 +531,7 @@ fn profile_selection_check_all_targets() { [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] [FINISHED] dev [unoptimized + debuginfo] [..] -").run(); +", rustc_host())).run(); // Starting with Rust 1.27, rustc emits `rmeta` files for bins, so // everything should be completely fresh. Previously, bins were being // rechecked. @@ -557,7 +557,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").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("check --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 codegen-units=6 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..] @@ -566,7 +566,7 @@ fn profile_selection_check_all_targets_release() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link [..]-C codegen-units=6 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] -[RUNNING] `[..]target/release/build/foo-[..]/build-script-build` +[RUNNING] `[..]target/host/{}/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=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..] @@ -577,7 +577,7 @@ fn profile_selection_check_all_targets_release() { [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]metadata -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [FINISHED] release [optimized] [..] -").run(); +", rustc_host())).run(); p.cargo("check --all-targets --release -vv") .masquerade_as_nightly_cargo() @@ -626,7 +626,7 @@ fn profile_selection_check_all_targets_test() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]target/host/{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={affected} -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] @@ -635,7 +635,7 @@ fn profile_selection_check_all_targets_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(); +", affected=affected, target=rustc_host())).run(); p.cargo("check --all-targets --profile=test -vv") .masquerade_as_nightly_cargo() @@ -664,7 +664,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").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("doc -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ [COMPILING] bar [..] [DOCUMENTING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] @@ -674,10 +674,10 @@ fn profile_selection_doc() { [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` +[RUNNING] `[..]target/host/{}/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [DOCUMENTING] foo [..] [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..] [FINISHED] dev [unoptimized + debuginfo] [..] -").run(); +", rustc_host())).run(); } diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 2e09d5c7e69..864f545574e 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -2,7 +2,7 @@ use std::env; -use cargo_test_support::{is_nightly, project}; +use cargo_test_support::{is_nightly, project, rustc_host}; #[cargo_test] fn profile_overrides() { @@ -25,7 +25,7 @@ fn profile_overrides() { .file("src/lib.rs", "") .build(); p.cargo("build -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ @@ -35,10 +35,12 @@ fn profile_overrides() { -C metadata=[..] \ -C rpath \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] dev [optimized] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -61,7 +63,7 @@ fn opt_level_override_0() { .file("src/lib.rs", "") .build(); p.cargo("build -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ @@ -69,10 +71,12 @@ fn opt_level_override_0() { -C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] [..] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -94,7 +98,7 @@ fn debug_override_1() { .file("src/lib.rs", "") .build(); p.cargo("build -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ @@ -102,10 +106,12 @@ fn debug_override_1() { -C debuginfo=1 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] [..] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -140,10 +146,12 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { -C debug-assertions=on \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] [..] target(s) in [..] ", - level = rustc_level + level = rustc_level, + target = rustc_host() )) .run(); } @@ -213,8 +221,10 @@ fn top_level_overrides_deps() { -C opt-level=1[..]\ -C debuginfo=2 \ -C metadata=[..] \ - --out-dir [CWD]/target/release/deps \ - -L dependency=[CWD]/target/release/deps` + --out-dir [CWD]/target/{target}/release/deps \ + --target {target} \ + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps` [COMPILING] test v0.0.0 ([CWD]) [RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \ --emit=[..]link \ @@ -222,14 +232,16 @@ fn top_level_overrides_deps() { -C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/release/deps \ - --extern foo=[CWD]/target/release/deps/\ + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps \ + --extern foo=[CWD]/target/{target}/release/deps/\ {prefix}foo[..]{suffix} \ - --extern foo=[CWD]/target/release/deps/libfoo.rlib` + --extern foo=[CWD]/target/{target}/release/deps/libfoo.rlib` [FINISHED] release [optimized + debuginfo] target(s) in [..] ", prefix = env::consts::DLL_PREFIX, - suffix = env::consts::DLL_SUFFIX + suffix = env::consts::DLL_SUFFIX, + target = rustc_host() )) .run(); } diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index cc0b7173623..799b8928456 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -1,9 +1,9 @@ //! Tests for renaming dependencies. -use cargo_test_support::git; use cargo_test_support::paths; use cargo_test_support::registry::{self, Package}; use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{git, rustc_host}; #[cargo_test] fn rename_dependency() { @@ -263,16 +263,17 @@ fn can_run_doc_tests() { .build(); foo.cargo("test -v") - .with_stderr_contains( + .with_stderr_contains(format!( "\ [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..]src/lib.rs \ [..] \ - --extern bar=[CWD]/target/debug/deps/libbar-[..].rlib \ - --extern baz=[CWD]/target/debug/deps/libbar-[..].rlib \ + --extern bar=[CWD]/target/{target}/debug/deps/libbar-[..].rlib \ + --extern baz=[CWD]/target/{target}/debug/deps/libbar-[..].rlib \ [..]` ", - ) + target = rustc_host() + )) .run(); } diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 04d9aa646ce..dcd3530c335 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -3,9 +3,9 @@ use cargo_test_support::install::{ assert_has_installed_exe, assert_has_not_installed_exe, cargo_home, }; -use cargo_test_support::is_nightly; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::project; +use cargo_test_support::{is_nightly, rustc_host}; #[cargo_test] fn build_bin_default_features() { @@ -290,12 +290,13 @@ fn test_default_features() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); @@ -305,11 +306,12 @@ fn test_default_features() { .run(); p.cargo("test --test=foo") - .with_stderr( + .with_stderr(format!( "\ [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); @@ -347,12 +349,13 @@ fn test_arg_features() { .build(); p.cargo("test --features a") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); } @@ -388,23 +391,25 @@ fn test_multiple_required_features() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo_2-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo_2-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); p.cargo("test --features c") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo_1-[..][EXE]) -[RUNNING] [..] (target/debug/deps/foo_2-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/foo_1-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo_2-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("test test ... ok", 2) .run(); @@ -453,12 +458,13 @@ fn bench_default_features() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); @@ -468,11 +474,12 @@ fn bench_default_features() { .run(); p.cargo("bench --bench=foo") - .with_stderr( + .with_stderr(&format!( "\ [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); @@ -525,12 +532,13 @@ fn bench_arg_features() { .build(); p.cargo("bench --features a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -591,23 +599,25 @@ fn bench_multiple_required_features() { .build(); p.cargo("bench") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo_2-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo_2-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); p.cargo("bench --features c") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo_1-[..][EXE]) -[RUNNING] [..] (target/release/deps/foo_2-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/release/deps/foo_1-[..][EXE]) +[RUNNING] [..] (target/{target}/release/deps/foo_2-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("test bench ... bench: [..]", 2) .run(); @@ -857,25 +867,27 @@ fn dep_feature_in_toml() { // test p.cargo("test --test=foo") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); // bench if is_nightly() { p.cargo("bench --bench=foo") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -921,14 +933,17 @@ fn dep_feature_in_cmd_line() { .file("examples/foo.rs", "fn main() {}") .file( "tests/foo.rs", - r#" - #[test] - fn bin_is_built() { - let s = format!("target/debug/foo{}", std::env::consts::EXE_SUFFIX); - let p = std::path::Path::new(&s); - assert!(p.exists(), "foo does not exist"); - } - "#, + &format!( + r#" + #[test] + fn bin_is_built() {{ + let s = format!("target/{}/debug/foo{{}}", std::env::consts::EXE_SUFFIX); + let p = std::path::Path::new(&s); + assert!(p.exists(), "foo does not exist"); + }} + "#, + rustc_host() + ), ) .file( "benches/foo.rs", @@ -998,13 +1013,14 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` // Delete the target directory so this can check if the main.rs gets built. p.build_dir().rm_rf(); p.cargo("test --test=foo --features bar/a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bin_is_built ... ok") .run(); @@ -1016,13 +1032,14 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"` .run(); p.cargo("bench --bench=foo --features bar/a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -1071,12 +1088,13 @@ fn test_skips_compiling_bin_with_missing_required_features() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); @@ -1091,12 +1109,13 @@ error[E0463]: can't find crate for `bar`", if is_nightly() { p.cargo("bench") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] [..] (target/release/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/release/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 106e2259fc4..1c0e4c419bb 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -1,6 +1,6 @@ //! Tests for the `cargo run` command. -use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, Project}; +use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, project, rustc_host, Project}; use cargo_util::paths::dylib_path_envvar; #[cargo_test] @@ -10,12 +10,13 @@ fn simple() { .build(); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/foo[EXE]`", - ) +[RUNNING] `target/{}/debug/foo[EXE]`", + rustc_host() + )) .with_stdout("hello") .run(); assert!(p.bin("foo").is_file()); @@ -203,25 +204,27 @@ fn specify_name() { .build(); p.cargo("run --bin a -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..] src/lib.rs [..]` [RUNNING] `rustc [..] src/bin/a.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/a[EXE]`", - ) +[RUNNING] `target/{}/debug/a[EXE]`", + rustc_host() + )) .with_stdout("hello a.rs") .run(); p.cargo("run --bin b -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..] src/bin/b.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/b[EXE]`", - ) +[RUNNING] `target/{}/debug/b[EXE]`", + rustc_host() + )) .with_stdout("hello b.rs") .run(); } @@ -290,12 +293,13 @@ fn run_example() { .build(); p.cargo("run --example a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/examples/a[EXE]`", - ) +[RUNNING] `target/{}/debug/examples/a[EXE]`", + rustc_host() + )) .with_stdout("example") .run(); } @@ -344,12 +348,13 @@ fn run_bin_example() { .build(); p.cargo("run --example bar") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/examples/bar[EXE]`", - ) +[RUNNING] `target/{}/debug/examples/bar[EXE]`", + rustc_host() + )) .with_stdout("example") .run(); } @@ -424,12 +429,13 @@ error: no example target named `a` fn run_example_autodiscover_2015_with_autoexamples_enabled() { let p = autodiscover_examples_project("2015", Some(true)); p.cargo("run --example a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/examples/a[EXE]`", - ) +[RUNNING] `target/{}/debug/examples/a[EXE]`", + rustc_host() + )) .with_stdout("example") .run(); } @@ -447,12 +453,13 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() { fn run_example_autodiscover_2018() { let p = autodiscover_examples_project("2018", None); p.cargo("run --example a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/examples/a[EXE]`", - ) +[RUNNING] `target/{}/debug/examples/a[EXE]`", + rustc_host() + )) .with_stdout("example") .run(); } @@ -570,12 +577,13 @@ fn one_bin_multiple_examples() { .build(); p.cargo("run") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/main[EXE]`", - ) +[RUNNING] `target/{}/debug/main[EXE]`", + rustc_host() + )) .with_stdout("hello main.rs") .run(); } @@ -627,27 +635,32 @@ fn example_with_release_flag() { .build(); p.cargo("run -v --release --example a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.5.0 ([CWD]/bar) [RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \ --emit=[..]link \ -C opt-level=3[..]\ -C metadata=[..] \ - --out-dir [CWD]/target/release/deps \ - -L dependency=[CWD]/target/release/deps` + --out-dir [CWD]/target/{target}/release/deps \ + --target {target} \ + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \ --emit=[..]link \ -C opt-level=3[..]\ -C metadata=[..] \ - --out-dir [CWD]/target/release/examples \ - -L dependency=[CWD]/target/release/deps \ - --extern bar=[CWD]/target/release/deps/libbar-[..].rlib` + --out-dir [CWD]/target/{target}/release/examples \ + --target {target} \ + -L dependency=[CWD]/target/{target}/release/deps \ + -L dependency=[CWD]/target/host/{target}/release/deps \ + --extern bar=[CWD]/target/{target}/release/deps/libbar-[..].rlib` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target/release/examples/a[EXE]` +[RUNNING] `target/{target}/release/examples/a[EXE]` ", - ) + target = rustc_host() + )) .with_stdout( "\ fast1 @@ -656,27 +669,32 @@ fast2", .run(); p.cargo("run -v --example a") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.5.0 ([CWD]/bar) [RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \ --emit=[..]link[..]\ -C debuginfo=2 \ -C metadata=[..] \ - --out-dir [CWD]/target/debug/deps \ - -L dependency=[CWD]/target/debug/deps` + --out-dir [CWD]/target/{target}/debug/deps \ + --target {target} \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \ --emit=[..]link[..]\ -C debuginfo=2 \ -C metadata=[..] \ - --out-dir [CWD]/target/debug/examples \ - -L dependency=[CWD]/target/debug/deps \ - --extern bar=[CWD]/target/debug/deps/libbar-[..].rlib` + --out-dir [CWD]/target/{target}/debug/examples \ + --target {target} \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps \ + --extern bar=[CWD]/target/{target}/debug/deps/libbar-[..].rlib` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target/debug/examples/a[EXE]` +[RUNNING] `target/{target}/debug/examples/a[EXE]` ", - ) + target = rustc_host() + )) .with_stdout( "\ slow1 @@ -735,13 +753,14 @@ fn release_works() { .build(); p.cargo("run --release") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target/release/foo[EXE]` +[RUNNING] `target/{}/release/foo[EXE]` ", - ) + rustc_host() + )) .run(); assert!(p.release_bin("foo").is_file()); } @@ -793,7 +812,7 @@ fn run_from_executable_folder() { .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); - let cwd = p.root().join("target").join("debug"); + let cwd = p.root().join("target").join(rustc_host()).join("debug"); p.cargo("build").run(); p.cargo("run") diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 53b5c6fb19a..2815c679322 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -1,6 +1,8 @@ //! Tests for the `cargo rustc` command. -use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; +use cargo_test_support::{ + basic_bin_manifest, basic_lib_manifest, basic_manifest, project, rustc_host, +}; const CARGO_RUSTC_ERROR: &str = "[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering @@ -14,17 +16,19 @@ fn build_lib_for_foo() { .build(); p.cargo("rustc --lib -v") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -36,7 +40,7 @@ fn lib() { .build(); p.cargo("rustc --lib -v -- -C debug-assertions=off") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ @@ -44,10 +48,13 @@ fn lib() { -C debug-assertions=off \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + --target {target} \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -66,18 +73,21 @@ fn build_main_and_allow_unstable_options() { --emit=[..]link[..]-C debuginfo=2 \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps` [RUNNING] `rustc --crate-name {name} src/main.rs [..]--crate-type bin \ --emit=[..]link[..]-C debuginfo=2 \ -C debug-assertions \ -C metadata=[..] \ --out-dir [..] \ - -L dependency=[CWD]/target/debug/deps \ - --extern {name}=[CWD]/target/debug/deps/lib{name}-[..].rlib` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps \ + --extern {name}=[CWD]/target/{target}/debug/deps/lib{name}-[..].rlib` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", name = "foo", - version = "0.0.1" + version = "0.0.1", + target = rustc_host() )) .run(); } diff --git a/tests/testsuite/rustc_info_cache.rs b/tests/testsuite/rustc_info_cache.rs index 9747fa3579b..4f53e9bd866 100644 --- a/tests/testsuite/rustc_info_cache.rs +++ b/tests/testsuite/rustc_info_cache.rs @@ -1,6 +1,6 @@ //! Tests for the cache file for the rustc version info. -use cargo_test_support::{basic_bin_manifest, paths::CargoPathExt}; +use cargo_test_support::{basic_bin_manifest, paths::CargoPathExt, rustc_host}; use cargo_test_support::{basic_manifest, project}; use std::env; @@ -8,6 +8,7 @@ const MISS: &str = "[..] rustc info cache miss[..]"; const HIT: &str = "[..]rustc info cache hit[..]"; const UPDATE: &str = "[..]updated rustc info cache[..]"; +#[ignore] #[cargo_test] fn rustc_info_cache() { let p = project() @@ -60,7 +61,7 @@ fn rustc_info_cache() { p.cargo("build").run(); p.root() - .join("target/debug/compiler") + .join(&format!("target/{}/debug/compiler", rustc_host())) .with_extension(env::consts::EXE_EXTENSION) }; @@ -103,6 +104,7 @@ fn rustc_info_cache() { .run(); } +#[ignore] #[cargo_test] fn rustc_info_cache_with_wrappers() { let wrapper_project = project() diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 3d27739ef92..07b3d10f48f 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -1,22 +1,24 @@ //! Tests for the `cargo rustdoc` command. -use cargo_test_support::{basic_manifest, cross_compile, project}; +use cargo_test_support::{basic_manifest, cross_compile, project, rustc_host}; #[cargo_test] fn rustdoc_simple() { let p = project().file("src/lib.rs", "").build(); p.cargo("rustdoc -v") - .with_stderr( + .with_stderr(&format!( "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ - -o [CWD]/target/doc \ + -o [CWD]/target/{target}/doc \ [..] \ - -L dependency=[CWD]/target/debug/deps [..]` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -25,17 +27,19 @@ fn rustdoc_args() { let p = project().file("src/lib.rs", "").build(); p.cargo("rustdoc -v -- --cfg=foo") - .with_stderr( + .with_stderr(&format!( "\ [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ - -o [CWD]/target/doc \ + -o [CWD]/target/{target}/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps [..]` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -74,20 +78,22 @@ fn rustdoc_foo_with_bar_dependency() { .build(); foo.cargo("rustdoc -v -- --cfg=foo") - .with_stderr( + .with_stderr(&format!( "\ [CHECKING] bar v0.0.1 ([..]) [RUNNING] `rustc [..]bar/src/lib.rs [..]` [DOCUMENTING] foo v0.0.1 ([CWD]) [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ - -o [CWD]/target/doc \ + -o [CWD]/target/{target}/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps \ + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps \ --extern [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -115,17 +121,19 @@ fn rustdoc_only_bar_dependency() { .build(); foo.cargo("rustdoc -v -p bar -- --cfg=foo") - .with_stderr( + .with_stderr(&format!( "\ [DOCUMENTING] bar v0.0.1 ([..]) [RUNNING] `rustdoc [..]--crate-name bar [..]bar/src/lib.rs [..]\ - -o [CWD]/target/doc \ + -o [CWD]/target/{target}/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps [..]` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -137,17 +145,19 @@ fn rustdoc_same_name_documents_lib() { .build(); p.cargo("rustdoc -v -- --cfg=foo") - .with_stderr( + .with_stderr(&format!( "\ [DOCUMENTING] foo v0.0.1 ([..]) [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\ - -o [CWD]/target/doc \ + -o [CWD]/target/{target}/doc \ [..] \ --cfg=foo \ - -L dependency=[CWD]/target/debug/deps [..]` + -L dependency=[CWD]/target/{target}/debug/deps \ + -L dependency=[CWD]/target/host/{target}/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ) + target = rustc_host() + )) .run(); } @@ -220,9 +230,10 @@ fn rustdoc_target() { -o [CWD]/target/{target}/doc \ [..] \ -L dependency=[CWD]/target/{target}/debug/deps \ - -L dependency=[CWD]/target/debug/deps[..]` + -L dependency=[CWD]/target/host/{host}/debug/deps[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - target = cross_compile::alternate() + target = cross_compile::alternate(), + host = rustc_host() )) .run(); } diff --git a/tests/testsuite/rustdoc_extern_html.rs b/tests/testsuite/rustdoc_extern_html.rs index 6281190af98..fc85a9f6e15 100644 --- a/tests/testsuite/rustdoc_extern_html.rs +++ b/tests/testsuite/rustdoc_extern_html.rs @@ -1,7 +1,7 @@ //! Tests for the -Zrustdoc-map feature. use cargo_test_support::registry::{self, Package}; -use cargo_test_support::{is_nightly, paths, project, Project}; +use cargo_test_support::{is_nightly, paths, project, rustc_host, Project}; fn basic_project() -> Project { Package::new("bar", "1.0.0") @@ -55,7 +55,7 @@ fn simple() { "[RUNNING] `rustdoc [..]--crate-name foo [..]bar=https://docs.rs/bar/1.0.0/[..]", ) .run(); - let myfun = p.read_file("target/doc/foo/fn.myfun.html"); + let myfun = p.read_file(&format!("target/{}/doc/foo/fn.myfun.html", rustc_host())); assert!(myfun.contains(r#"href="https://docs.rs/bar/1.0.0/bar/struct.Straw.html""#)); } @@ -92,7 +92,7 @@ fn std_docs() { .masquerade_as_nightly_cargo() .with_stderr_contains("[RUNNING] `rustdoc [..]--crate-name foo [..]std=file://[..]") .run(); - let myfun = p.read_file("target/doc/foo/fn.myfun.html"); + let myfun = p.read_file(&format!("target/{}/doc/foo/fn.myfun.html", rustc_host())); assert!(myfun.contains(r#"share/doc/rust/html/core/option/enum.Option.html""#)); p.change_file( @@ -108,7 +108,7 @@ fn std_docs() { "[RUNNING] `rustdoc [..]--crate-name foo [..]std=https://example.com/rust/[..]", ) .run(); - let myfun = p.read_file("target/doc/foo/fn.myfun.html"); + let myfun = p.read_file(&format!("target/{}/doc/foo/fn.myfun.html", rustc_host())); assert!(myfun.contains(r#"href="https://example.com/rust/core/option/enum.Option.html""#)); } @@ -151,7 +151,7 @@ fn renamed_dep() { "[RUNNING] `rustdoc [..]--crate-name foo [..]bar=https://docs.rs/bar/1.0.0/[..]", ) .run(); - let myfun = p.read_file("target/doc/foo/fn.myfun.html"); + let myfun = p.read_file(&format!("target/{}/doc/foo/fn.myfun.html", rustc_host())); assert!(myfun.contains(r#"href="https://docs.rs/bar/1.0.0/bar/struct.Straw.html""#)); } @@ -204,7 +204,7 @@ fn lib_name() { "[RUNNING] `rustdoc [..]--crate-name foo [..]rumpelstiltskin=https://docs.rs/bar/1.0.0/[..]", ) .run(); - let myfun = p.read_file("target/doc/foo/fn.myfun.html"); + let myfun = p.read_file(&format!("target/{}/doc/foo/fn.myfun.html", rustc_host())); assert!(myfun.contains(r#"href="https://docs.rs/bar/1.0.0/rumpelstiltskin/struct.Straw.html""#)); } @@ -274,17 +274,17 @@ fn alt_registry() { [..]bar=https://example.com/bar/1.0.0/[..]grimm=https://docs.rs/grimm/1.0.0/[..]", ) .run(); - let queen = p.read_file("target/doc/foo/fn.queen.html"); + let queen = p.read_file(&format!("target/{}/doc/foo/fn.queen.html", rustc_host())); assert!(queen.contains(r#"href="https://example.com/bar/1.0.0/bar/struct.Queen.html""#)); // The king example fails to link. Rustdoc seems to want the origin crate // name (baz) for re-exports. There are many issues in the issue tracker // for rustdoc re-exports, so I'm not sure, but I think this is maybe a // rustdoc issue. Alternatively, Cargo could provide mappings for all // transitive dependencies to fix this. - let king = p.read_file("target/doc/foo/fn.king.html"); + let king = p.read_file(&format!("target/{}/doc/foo/fn.king.html", rustc_host())); assert!(king.contains(r#"-> King"#)); - let gold = p.read_file("target/doc/foo/fn.gold.html"); + let gold = p.read_file(&format!("target/{}/doc/foo/fn.gold.html", rustc_host())); assert!(gold.contains(r#"href="https://docs.rs/grimm/1.0.0/grimm/struct.Gold.html""#)); } @@ -332,11 +332,11 @@ fn multiple_versions() { [..]bar=https://docs.rs/bar/1.0.0/[..]bar=https://docs.rs/bar/2.0.0/[..]", ) .run(); - let fn1 = p.read_file("target/doc/foo/fn.fn1.html"); + let fn1 = p.read_file(&format!("target/{}/doc/foo/fn.fn1.html", rustc_host())); // This should be 1.0.0, rustdoc seems to use the last entry when there // are duplicates. assert!(fn1.contains(r#"href="https://docs.rs/bar/2.0.0/bar/struct.Spin.html""#)); - let fn2 = p.read_file("target/doc/foo/fn.fn2.html"); + let fn2 = p.read_file(&format!("target/{}/doc/foo/fn.fn2.html", rustc_host())); assert!(fn2.contains(r#"href="https://docs.rs/bar/2.0.0/bar/struct.Straw.html""#)); } diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index b17f83c2fdf..25c88907d78 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -1,6 +1,6 @@ //! Tests for setting custom rustdoc flags. -use cargo_test_support::project; +use cargo_test_support::{project, rustc_host}; #[cargo_test] fn parses_env() { @@ -118,6 +118,6 @@ fn whitespace() { ) .run(); - let contents = p.read_file("target/doc/foo/index.html"); + let contents = p.read_file(&format!("target/{}/doc/foo/index.html", rustc_host())); assert!(contents.contains(SPACED_VERSION)); } diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 4f825b4f31d..373f153740b 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -77,7 +77,7 @@ fn env_rustflags_build_script() { ) .build(); - p.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); + p.cargo("build").env("HOST_RUSTFLAGS", "--cfg foo").run(); } #[cargo_test] @@ -114,7 +114,7 @@ fn env_rustflags_build_script_dep() { ) .build(); - foo.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); + foo.cargo("build").env("HOST_RUSTFLAGS", "--cfg foo").run(); } #[cargo_test] @@ -145,7 +145,7 @@ fn env_rustflags_plugin() { ) .build(); - p.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); + p.cargo("build").env("HOST_RUSTFLAGS", "--cfg foo").run(); } #[cargo_test] @@ -184,7 +184,7 @@ fn env_rustflags_plugin_dep() { ) .build(); - foo.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); + foo.cargo("build").env("HOST_RUSTFLAGS", "--cfg foo").run(); } #[cargo_test] @@ -501,7 +501,7 @@ fn build_rustflags_build_script() { .file( ".cargo/config", r#" - [build] + [host] rustflags = ["--cfg", "foo"] "#, ) @@ -533,7 +533,7 @@ fn build_rustflags_build_script_dep() { .file( ".cargo/config", r#" - [build] + [host] rustflags = ["--cfg", "foo"] "#, ) @@ -583,7 +583,7 @@ fn build_rustflags_plugin() { .file( ".cargo/config", r#" - [build] + [host] rustflags = ["--cfg", "foo"] "#, ) @@ -617,7 +617,7 @@ fn build_rustflags_plugin_dep() { .file( ".cargo/config", r#" - [build] + [host] rustflags = ["--cfg", "foo"] "#, ) @@ -1370,7 +1370,7 @@ fn remap_path_prefix_ignored() { let p = project().file("src/lib.rs", "").build(); p.cargo("build").run(); let rlibs = p - .glob("target/debug/deps/*.rlib") + .glob(&format!("target/{}/debug/deps/*.rlib", rustc_host())) .collect::, _>>() .unwrap(); assert_eq!(rlibs.len(), 1); @@ -1378,7 +1378,7 @@ fn remap_path_prefix_ignored() { let check_metadata_same = || { let rlibs2 = p - .glob("target/debug/deps/*.rlib") + .glob(&format!("target/{}/debug/deps/*.rlib", rustc_host())) .collect::, _>>() .unwrap(); assert_eq!(rlibs, rlibs2); diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 5ed6198c864..2670d64ddc8 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -38,12 +38,13 @@ fn cargo_test_simple() { p.process(&p.bin("foo")).with_stdout("hello\n").run(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test_hello ... ok") .run(); } @@ -87,7 +88,7 @@ fn cargo_test_release() { .build(); p.cargo("test -v --release") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [RUNNING] [..] -C opt-level=3 [..] @@ -96,11 +97,12 @@ fn cargo_test_release() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target/release/deps/foo-[..][EXE]` -[RUNNING] `[..]target/release/deps/test-[..][EXE]` +[RUNNING] `[..]target/{target}/release/deps/foo-[..][EXE]` +[RUNNING] `[..]target/{target}/release/deps/test-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..]lib.rs[..]`", - ) + target = rustc_host() + )) .with_stdout_contains_n("test test ... ok", 2) .with_stdout_contains("running 0 tests") .run(); @@ -230,14 +232,15 @@ fn cargo_test_verbose() { .build(); p.cargo("test -v hello") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[CWD]/target/debug/deps/foo-[..] hello` +[RUNNING] `[CWD]/target/{}/debug/deps/foo-[..] hello` ", - ) + rustc_host() + )) .with_stdout_contains("test test_hello ... ok") .run(); } @@ -305,13 +308,14 @@ fn cargo_test_failing_test_in_bin() { p.process(&p.bin("foo")).with_stdout("hello\n").run(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [ERROR] test failed, to rerun pass '--bin foo'", - ) + rustc_host() + )) .with_stdout_contains( " running 1 test @@ -353,14 +357,15 @@ fn cargo_test_failing_test_in_test() { p.process(&p.bin("foo")).with_stdout("hello\n").run(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/footest-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/footest-[..][EXE]) [ERROR] test failed, to rerun pass '--test footest'", - ) + target = rustc_host() + )) .with_stdout_contains("running 0 tests") .with_stdout_contains( "\ @@ -392,13 +397,14 @@ fn cargo_test_failing_test_in_lib() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [ERROR] test failed, to rerun pass '--lib'", - ) + rustc_host() + )) .with_stdout_contains( "\ test test_hello ... FAILED @@ -466,14 +472,15 @@ fn test_with_lib_dep() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/baz-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/baz-[..][EXE]) [DOCTEST] foo", - ) + target = rustc_host() + )) .with_stdout_contains("test lib_test ... ok") .with_stdout_contains("test bin_test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) @@ -569,14 +576,15 @@ fn external_test_explicit() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/test-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/test-[..][EXE]) [DOCTEST] foo", - ) + target = rustc_host() + )) .with_stdout_contains("test internal_test ... ok") .with_stdout_contains("test external_test ... ok") .with_stdout_contains("running 0 tests") @@ -629,14 +637,15 @@ fn external_test_implicit() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/external-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/external-[..][EXE]) [DOCTEST] foo", - ) + target = rustc_host() + )) .with_stdout_contains("test internal_test ... ok") .with_stdout_contains("test external_test ... ok") .with_stdout_contains("running 0 tests") @@ -670,24 +679,26 @@ fn pass_through_command_line() { .build(); p.cargo("test bar") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) ", - ) + rustc_host() + )) .with_stdout_contains("running 1 test") .with_stdout_contains("test bar ... ok") .run(); p.cargo("test foo") - .with_stderr( + .with_stderr(format!( "\ [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) ", - ) + rustc_host() + )) .with_stdout_contains("running 1 test") .with_stdout_contains("test foo ... ok") .run(); @@ -746,14 +757,15 @@ fn lib_bin_same_name() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) [DOCTEST] foo", - ) + target = rustc_host() + )) .with_stdout_contains_n("test [..] ... ok", 2) .with_stdout_contains("running 0 tests") .run(); @@ -787,14 +799,15 @@ fn lib_with_standard_name() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/syntax-[..][EXE]) -[RUNNING] [..] (target/debug/deps/test-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/syntax-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/test-[..][EXE]) [DOCTEST] syntax", - ) + target = rustc_host() + )) .with_stdout_contains("test foo_test ... ok") .with_stdout_contains("test test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) @@ -833,12 +846,13 @@ fn lib_with_standard_name2() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/syntax-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/syntax-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); } @@ -874,12 +888,13 @@ fn lib_without_name() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/syntax-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/syntax-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test ... ok") .run(); } @@ -1112,14 +1127,17 @@ fn bin_there_for_integration() { ) .file( "tests/foo.rs", - r#" - use std::process::Command; - #[test] - fn test_test() { - let status = Command::new("target/debug/foo").status().unwrap(); - assert_eq!(status.code(), Some(101)); - } - "#, + &format!( + r#" + use std::process::Command; + #[test] + fn test_test() {{ + let status = Command::new("target/{}/debug/foo").status().unwrap(); + assert_eq!(status.code(), Some(101)); + }} + "#, + rustc_host() + ), ) .build(); @@ -1185,25 +1203,27 @@ fn test_dylib() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] bar v0.0.1 ([CWD]/bar) [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/test-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/test-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("test foo ... ok", 2) .run(); p.root().move_into_the_past(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/test-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/test-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("test foo ... ok", 2) .run(); } @@ -1226,24 +1246,26 @@ fn test_twice_with_build_cmd() { .build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -1254,13 +1276,14 @@ fn test_then_build() { let p = project().file("src/lib.rs", "#[test] fn foo() {}").build(); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -1309,12 +1332,13 @@ fn test_run_specific_bin_target() { .build(); prj.cargo("test --bin bin2") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/bin2-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/bin2-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test2 ... ok") .run(); } @@ -1350,12 +1374,13 @@ fn test_run_implicit_bin_target() { .build(); prj.cargo("test --bins") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/mybin-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/mybin-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test_in_bin ... ok") .run(); } @@ -1370,12 +1395,13 @@ fn test_run_specific_test_target() { .build(); prj.cargo("test --test b") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/b-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/b-[..][EXE])", + rustc_host() + )) .with_stdout_contains("test test_b ... ok") .run(); } @@ -1410,13 +1436,14 @@ fn test_run_implicit_test_target() { .build(); prj.cargo("test --tests") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/mybin-[..][EXE]) -[RUNNING] [..] (target/debug/deps/mytest-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/mybin-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/mytest-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test test_in_test ... ok") .run(); } @@ -1451,13 +1478,14 @@ fn test_run_implicit_bench_target() { .build(); prj.cargo("test --benches") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/mybin-[..][EXE]) -[RUNNING] [..] (target/debug/deps/mybench-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/mybin-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/mybench-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("test test_in_bench ... ok") .run(); } @@ -1509,30 +1537,51 @@ fn test_run_implicit_example_target() { .with_stderr_contains("[RUNNING] `rustc [..]myexm1.rs [..]--crate-type bin[..]") .with_stderr_contains("[RUNNING] `rustc [..]myexm2.rs [..]--test[..]") .with_stderr_does_not_contain("[RUNNING] [..]myexm1-[..]") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm2-[..]") + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm2-[..]", + rustc_host() + )) .run(); // Only tests myexm2. prj.cargo("test --tests") .with_stderr_does_not_contain("[RUNNING] [..]myexm1-[..]") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm2-[..]") + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm2-[..]", + rustc_host() + )) .run(); // Tests all examples. prj.cargo("test --examples") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm1-[..]") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm2-[..]") + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm1-[..]", + rustc_host() + )) + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm2-[..]", + rustc_host() + )) .run(); // Test an example, even without `test` set. prj.cargo("test --example myexm1") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm1-[..]") + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm1-[..]", + rustc_host() + )) .run(); // Tests all examples. prj.cargo("test --all-targets") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm1-[..]") - .with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm2-[..]") + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm1-[..]", + rustc_host() + )) + .with_stderr_contains(format!( + "[RUNNING] [..]target/{}/debug/examples/myexm2-[..]", + rustc_host() + )) .run(); } @@ -1556,14 +1605,15 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..] ", ) - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo src/lib.rs [..] --test [..]` [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[CWD]/target/debug/deps/foo-[..] foo` +[RUNNING] `[CWD]/target/{}/debug/deps/foo-[..] foo` ", - ) + rustc_host() + )) .with_stderr_does_not_contain("[RUNNING][..]rustc[..]ex1[..]") .run(); } @@ -1594,13 +1644,14 @@ fn test_no_harness() { .build(); p.cargo("test -- --nocapture") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/bar-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/bar-[..][EXE]) ", - ) + rustc_host() + )) .run(); } @@ -1666,36 +1717,39 @@ fn selective_testing() { println!("d1"); p.cargo("test -p d1") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] d1 v0.0.1 ([CWD]/d1) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/d1-[..][EXE]) -[RUNNING] [..] (target/debug/deps/d1-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/d1-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/d1-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("running 0 tests", 2) .run(); println!("d2"); p.cargo("test -p d2") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] d2 v0.0.1 ([CWD]/d2) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/d2-[..][EXE]) -[RUNNING] [..] (target/debug/deps/d2-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/d2-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/d2-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains_n("running 0 tests", 2) .run(); println!("whole"); p.cargo("test") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); } @@ -1871,13 +1925,14 @@ fn selective_testing_with_docs() { let p = p.build(); p.cargo("test -p d1") - .with_stderr( + .with_stderr(format!( "\ [COMPILING] d1 v0.0.1 ([CWD]/d1) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/d1[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/d1[..][EXE]) [DOCTEST] d1", - ) + rustc_host() + )) .with_stdout_contains_n("running 0 tests", 2) .run(); } @@ -2034,13 +2089,14 @@ fn doctest_feature() { .build(); p.cargo("test --features bar") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo [..] [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("running 0 tests") .with_stdout_contains("test [..] ... ok") .run(); @@ -2111,12 +2167,13 @@ fn filter_no_doc_tests() { .build(); p.cargo("test --test=foo") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo[..][EXE])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo[..][EXE])", + rustc_host() + )) .with_stdout_contains("running 0 tests") .run(); } @@ -2236,14 +2293,15 @@ fn cyclic_dev_dep_doc_test() { ) .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/foo[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("running 0 tests") .with_stdout_contains("test [..] ... ok") .run(); @@ -2333,19 +2391,21 @@ fn no_fail_fast() { .build(); p.cargo("test --no-fail-fast") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(format!( "\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE]) -[RUNNING] [..] (target/debug/deps/test_add_one-[..][EXE])", - ) +[RUNNING] [..] (target/{target}/debug/deps/foo-[..][EXE]) +[RUNNING] [..] (target/{target}/debug/deps/test_add_one-[..][EXE])", + target = rustc_host() + )) .with_stdout_contains("running 0 tests") - .with_stderr_contains( + .with_stderr_contains(format!( "\ -[RUNNING] [..] (target/debug/deps/test_sub_one-[..][EXE]) +[RUNNING] [..] (target/{}/debug/deps/test_sub_one-[..][EXE]) [DOCTEST] foo", - ) + rustc_host() + )) .with_stdout_contains("test result: FAILED. [..]") .with_stdout_contains("test sub_one_test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) @@ -2405,8 +2465,14 @@ fn test_multiple_packages() { let p = p.build(); p.cargo("test -p d1 -p d2") - .with_stderr_contains("[RUNNING] [..] (target/debug/deps/d1-[..][EXE])") - .with_stderr_contains("[RUNNING] [..] (target/debug/deps/d2-[..][EXE])") + .with_stderr_contains(format!( + "[RUNNING] [..] (target/{}/debug/deps/d1-[..][EXE])", + rustc_host() + )) + .with_stderr_contains(format!( + "[RUNNING] [..] (target/{}/debug/deps/d2-[..][EXE])", + rustc_host() + )) .with_stdout_contains_n("running 0 tests", 2) .run(); } @@ -3568,7 +3634,7 @@ fn json_artifact_includes_executable_for_library_tests() { .with_json( r#" { - "executable": "[..]/foo/target/debug/deps/foo-[..][EXE]", + "executable": "[..]/foo/target/$TARGET/debug/deps/foo-[..][EXE]", "features": [], "filenames": "{...}", "fresh": false, @@ -3589,7 +3655,9 @@ fn json_artifact_includes_executable_for_library_tests() { } {"reason": "build-finished", "success": true} - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } @@ -3607,7 +3675,7 @@ fn json_artifact_includes_executable_for_integration_tests() { .with_json( r#" { - "executable": "[..]/foo/target/debug/deps/integration_test-[..][EXE]", + "executable": "[..]/foo/target/$TARGET/debug/deps/integration_test-[..][EXE]", "features": [], "filenames": "{...}", "fresh": false, @@ -3628,7 +3696,9 @@ fn json_artifact_includes_executable_for_integration_tests() { } {"reason": "build-finished", "success": true} - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } @@ -3689,12 +3759,13 @@ fn doctest_skip_staticlib() { .run(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo [..] [FINISHED] test [..] -[RUNNING] [..] (target/debug/deps/foo-[..])", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..])", + rustc_host() + )) .run(); } @@ -3717,14 +3788,15 @@ pub fn foo() -> u8 { 1 } .build(); p.cargo("test") - .with_stderr( + .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..]) +[RUNNING] [..] (target/{}/debug/deps/foo-[..]) [DOCTEST] foo ", - ) + rustc_host() + )) .with_stdout( " running 1 test @@ -3742,11 +3814,12 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..] .run(); p.cargo("test --lib") - .with_stderr( + .with_stderr(&format!( "\ [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..])\n", - ) +[RUNNING] [..] (target/{}/debug/deps/foo-[..])\n", + rustc_host() + )) .with_stdout( " running 1 test diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index ca0694b84a2..b4389522293 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -139,38 +139,41 @@ fn custom_runner() { p.cargo("run -- --param") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` +[RUNNING] `nonexistent-runner -r target/{}/debug/foo[EXE] --param` ", - ) + rustc_host() + )) .run(); p.cargo("test --test test --verbose -- --param") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..]` [FINISHED] test [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `nonexistent-runner -r [..]/target/debug/deps/test-[..][EXE] --param` +[RUNNING] `nonexistent-runner -r [..]/target/{}/debug/deps/test-[..][EXE] --param` ", - ) + rustc_host() + )) .run(); p.cargo("bench --bench bench --verbose -- --param") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [FINISHED] bench [optimized] target(s) in [..] -[RUNNING] `nonexistent-runner -r [..]/target/release/deps/bench-[..][EXE] --param --bench` +[RUNNING] `nonexistent-runner -r [..]/target/{}/release/deps/bench-[..][EXE] --param --bench` ", - ) + rustc_host() + )) .run(); } @@ -190,13 +193,14 @@ fn custom_runner_cfg() { p.cargo("run -- --param") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` +[RUNNING] `nonexistent-runner -r target/{}/debug/foo[EXE] --param` ", - ) + rustc_host() + )) .run(); } @@ -224,13 +228,14 @@ fn custom_runner_cfg_precedence() { p.cargo("run -- --param") .with_status(101) - .with_stderr_contains( + .with_stderr_contains(&format!( "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` +[RUNNING] `nonexistent-runner -r target/{}/debug/foo[EXE] --param` ", - ) + rustc_host() + )) .run(); } @@ -275,13 +280,14 @@ fn custom_runner_env() { "\ [COMPILING] foo [..] [FINISHED] dev [..] -[RUNNING] `nonexistent-runner --foo target/debug/foo[EXE]` -[ERROR] could not execute process `nonexistent-runner --foo target/debug/foo[EXE]` (never executed) +[RUNNING] `nonexistent-runner --foo target/{target}/debug/foo[EXE]` +[ERROR] could not execute process `nonexistent-runner --foo target/{target}/debug/foo[EXE]` (never executed) Caused by: - {} + {msg} ", - no_such_file_err_msg() + target = rustc_host(), + msg = no_such_file_err_msg() )) .run(); } @@ -308,7 +314,10 @@ fn custom_runner_env_overrides_config() { p.cargo("run") .env(&key, "should-run --foo") .with_status(101) - .with_stderr_contains("[RUNNING] `should-run --foo target/debug/foo[EXE]`") + .with_stderr_contains(&format!( + "[RUNNING] `should-run --foo target/{}/debug/foo[EXE]`", + rustc_host() + )) .run(); } @@ -323,7 +332,10 @@ fn custom_runner_env_true() { p.cargo("run") .env(&key, "true") - .with_stderr_contains("[RUNNING] `true target/debug/foo[EXE]`") + .with_stderr_contains(&format!( + "[RUNNING] `true target/{}/debug/foo[EXE]`", + rustc_host() + )) .run(); } diff --git a/tests/testsuite/tree.rs b/tests/testsuite/tree.rs index acb727b64cf..ccb7b5e952a 100644 --- a/tests/testsuite/tree.rs +++ b/tests/testsuite/tree.rs @@ -51,7 +51,8 @@ foo v0.1.0 ([..]/foo) └── c v1.0.0 [build-dependencies] └── bdep v1.0.0 - └── b v1.0.0 (*) + └── b v1.0.0 + └── c v1.0.0 [dev-dependencies] └── devdep v1.0.0 └── b v1.0.0 (*) @@ -761,9 +762,11 @@ foo v0.1.0 ([..]/foo) .with_stdout( "\ common v1.0.0 -├── bdep v1.0.0 -│ [build-dependencies] -│ └── foo v0.1.0 ([..]/foo) +└── bdep v1.0.0 + [build-dependencies] + └── foo v0.1.0 ([..]/foo) + +common v1.0.0 └── foo v0.1.0 ([..]/foo) ", ) @@ -783,7 +786,8 @@ b v1.0.0 c v1.0.0 c v1.0.0 bdep v1.0.0 -b v1.0.0 (*) +b v1.0.0 +c v1.0.0 devdep v1.0.0 b v1.0.0 (*) ", @@ -804,7 +808,8 @@ fn prefix_depth() { 3c v1.0.0 1c v1.0.0 1bdep v1.0.0 -2b v1.0.0 (*) +2b v1.0.0 +3c v1.0.0 1devdep v1.0.0 2b v1.0.0 (*) ", @@ -997,7 +1002,8 @@ foo v0.1.0 ([..]/foo) `-- c v1.0.0 [build-dependencies] `-- bdep v1.0.0 - `-- b v1.0.0 (*) + `-- b v1.0.0 + `-- c v1.0.0 [dev-dependencies] `-- devdep v1.0.0 `-- b v1.0.0 (*) @@ -1179,7 +1185,8 @@ foo v0.1.0 ([..]/foo) └── bar v1.0.0 └── optdep v1.0.0 [build-dependencies] -└── bar v1.0.0 (*) +└── bar v1.0.0 + └── optdep v1.0.0 ", ) .run(); @@ -1190,6 +1197,9 @@ foo v0.1.0 ([..]/foo) "\ bar v1.0.0 └── optdep v1.0.0 + +bar v1.0.0 +└── optdep v1.0.0 ", ) .run(); @@ -1200,9 +1210,12 @@ bar v1.0.0 "\ optdep v1.0.0 └── bar v1.0.0 - └── foo v0.1.0 ([..]/foo) [build-dependencies] └── foo v0.1.0 ([..]/foo) + +optdep v1.0.0 +└── bar v1.0.0 + └── foo v0.1.0 ([..]/foo) ", ) .run(); @@ -1294,7 +1307,8 @@ foo v0.1.0 ([..]/foo) ├── pm v1.0.0 (proc-macro) │ └── somedep v1.0.0 │ └── optdep v1.0.0 -└── somedep v1.0.0 (*) +└── somedep v1.0.0 + └── optdep v1.0.0 ", ) .run(); @@ -1316,6 +1330,9 @@ foo v0.1.0 ([..]/foo) "\ somedep v1.0.0 └── optdep v1.0.0 + +somedep v1.0.0 +└── optdep v1.0.0 ", ) .run(); @@ -1326,6 +1343,9 @@ somedep v1.0.0 "\ somedep v1.0.0 └── optdep v1.0.0 + +somedep v1.0.0 +└── optdep v1.0.0 ", ) .run(); @@ -1335,9 +1355,11 @@ somedep v1.0.0 .with_stdout( "\ somedep v1.0.0 -├── foo v0.1.0 ([..]/foo) └── pm v1.0.0 (proc-macro) └── foo v0.1.0 ([..]/foo) + +somedep v1.0.0 +└── foo v0.1.0 ([..]/foo) ", ) .run(); @@ -1347,6 +1369,8 @@ somedep v1.0.0 .with_stdout( "\ somedep v1.0.0 + +somedep v1.0.0 └── foo v0.1.0 ([..]/foo) ", ) @@ -1665,7 +1689,7 @@ foo v0.1.0 ([..]/foo) └── c v1.0.0 [build-dependencies] └── bdep v1.0.0 - └── b v1.0.0 (*) + └── b v1.0.0 [dev-dependencies] └── devdep v1.0.0 └── b v1.0.0 (*) @@ -1713,6 +1737,9 @@ foo v0.1.0 ([..]/foo) p.cargo("tree --depth 1 --invert c") .with_stdout( "\ +c v1.0.0 +└── b v1.0.0 + c v1.0.0 ├── b v1.0.0 └── foo v0.1.0 ([..]/foo) @@ -1733,7 +1760,7 @@ foo v0.1.0 ([..]/foo) └── b v1.0.0 [build-dependencies] └── bdep v1.0.0 - └── b v1.0.0 (*) + └── b v1.0.0 [dev-dependencies] └── devdep v1.0.0 └── b v1.0.0 (*) @@ -1778,7 +1805,8 @@ foo v0.1.0 ([..]/foo) └── c v1.0.0 [build-dependencies] └── bdep v1.0.0 - └── b v1.0.0 (*) + └── b v1.0.0 + └── c v1.0.0 [dev-dependencies] └── devdep v1.0.0 └── b v1.0.0 (*) diff --git a/tests/testsuite/unit_graph.rs b/tests/testsuite/unit_graph.rs index 977d04915c5..6d50193e1b8 100644 --- a/tests/testsuite/unit_graph.rs +++ b/tests/testsuite/unit_graph.rs @@ -1,7 +1,7 @@ //! Tests for --unit-graph option. -use cargo_test_support::project; use cargo_test_support::registry::Package; +use cargo_test_support::{project, rustc_host}; #[cargo_test] fn gated() { @@ -81,7 +81,7 @@ fn simple() { "strip": "none", "split_debuginfo": "{...}" }, - "platform": null, + "platform": "$TARGET", "mode": "build", "features": [ "feata" @@ -125,7 +125,7 @@ fn simple() { "strip": "none", "split_debuginfo": "{...}" }, - "platform": null, + "platform": "$TARGET", "mode": "build", "features": [ "featb" @@ -169,7 +169,7 @@ fn simple() { "strip": "none", "split_debuginfo": "{...}" }, - "platform": null, + "platform": "$TARGET", "mode": "build", "features": [ "featc" @@ -206,7 +206,7 @@ fn simple() { "strip": "none", "split_debuginfo": "{...}" }, - "platform": null, + "platform": "$TARGET", "mode": "build", "features": [], "dependencies": [ @@ -221,7 +221,9 @@ fn simple() { ], "roots": [3] } - "#, + "# + .replace("$TARGET", rustc_host()) + .as_str(), ) .run(); } diff --git a/tests/testsuite/weak_dep_features.rs b/tests/testsuite/weak_dep_features.rs index b04e3dd34f8..64f4b263374 100644 --- a/tests/testsuite/weak_dep_features.rs +++ b/tests/testsuite/weak_dep_features.rs @@ -3,7 +3,7 @@ use super::features2::switch_to_resolver_2; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::{Dependency, Package}; -use cargo_test_support::{project, publish}; +use cargo_test_support::{project, publish, rustc_host}; use std::fmt::Write; // Helper to create lib.rs files that check features. @@ -449,7 +449,7 @@ fn weak_with_host_decouple() { p.cargo("run -Z weak-dep-features") .masquerade_as_nightly_cargo() - .with_stderr( + .with_stderr(&format!( "\ [UPDATING] [..] [DOWNLOADING] crates ... @@ -461,9 +461,10 @@ fn weak_with_host_decouple() { [COMPILING] bar_activator v1.0.0 [COMPILING] foo v0.1.0 [..] [FINISHED] [..] -[RUNNING] `target/debug/foo[EXE]` +[RUNNING] `target/{}/debug/foo[EXE]` ", - ) + rustc_host() + )) .run(); } diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 777c6d13af5..345a10b6939 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -1,7 +1,7 @@ //! Tests for workspaces. use cargo_test_support::registry::Package; -use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project, sleep_ms}; +use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project, rustc_host, sleep_ms}; use std::env; use std::fs; @@ -2115,7 +2115,9 @@ fn relative_rustc() { let src = p .root() - .join("target/debug/foo") + .join("target") + .join(rustc_host()) + .join("debug/foo") .with_extension(env::consts::EXE_EXTENSION); Package::new("a", "0.1.0").publish();