diff --git a/Cargo.lock b/Cargo.lock index 7525b35e3b..1061955f45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -347,7 +347,10 @@ version = "0.1.12" dependencies = [ "error-chain 0.1.12", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.28 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.69 (registry+https://github.com/rust-lang/crates.io-index)", "rustup-mock 0.1.12", @@ -357,7 +360,10 @@ dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/src/rustup-cli/main.rs b/src/rustup-cli/main.rs index 49661db37d..4ef562fb03 100644 --- a/src/rustup-cli/main.rs +++ b/src/rustup-cli/main.rs @@ -48,6 +48,7 @@ mod help; use std::env; use std::path::PathBuf; use errors::*; +use rustup_dist::dist::TargetTriple; fn main() { if let Err(ref e) = run_multirust() { @@ -102,6 +103,7 @@ fn run_multirust() -> Result<()> { // `self install` as the arguments. FIXME: Verify this // works. let opts = self_update::InstallOpts { + default_host_triple: TargetTriple::from_host_or_build().to_string(), default_toolchain: "stable".to_string(), no_modify_path: false, }; diff --git a/src/rustup-cli/rustup_mode.rs b/src/rustup-cli/rustup_mode.rs index 63e2dca35e..1069b60867 100644 --- a/src/rustup-cli/rustup_mode.rs +++ b/src/rustup-cli/rustup_mode.rs @@ -82,6 +82,12 @@ pub fn main() -> Result<()> { (_, _) => unreachable!(), } } + ("set", Some(c)) => { + match c.subcommand() { + ("default-host", Some(m)) => try!(set_default_host_triple(&cfg, m)), + (_, _) => unreachable!(), + } + } (_, _) => unreachable!(), } @@ -263,6 +269,13 @@ pub fn cli() -> App<'static, 'static> { .about("Disable rustup telemetry")) .subcommand(SubCommand::with_name("analyze") .about("Analyze stored telemetry"))) + .subcommand(SubCommand::with_name("set") + .about("Alter rustup settings") + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand(SubCommand::with_name("default-host") + .about("Set host triple.") + .arg(Arg::with_name("host_triple") + .required(true)))) } fn maybe_upgrade_data(cfg: &Cfg, m: &ArgMatches) -> Result { @@ -348,6 +361,16 @@ fn which(cfg: &Cfg, m: &ArgMatches) -> Result<()> { } fn show(cfg: &Cfg) -> Result<()> { + // Print host triple + { + let mut t = term2::stdout(); + let _ = t.attr(term2::Attr::Bold); + let _ = write!(t, "Default host: "); + let _ = t.reset(); + println!("{}", try!(cfg.get_default_host_triple())); + println!(""); + } + let ref cwd = try!(utils::current_dir()); let installed_toolchains = try!(cfg.list_toolchains()); let active_toolchain = try!(cfg.find_override_toolchain_or_default(cwd)); @@ -549,3 +572,8 @@ fn analyze_telemetry(cfg: &Cfg) -> Result<()> { let analysis = try!(cfg.analyze_telemetry()); common::show_telemetry(analysis) } + +fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches) -> Result<()> { + try!(cfg.set_default_host_triple(m.value_of("host_triple").expect(""))); + Ok(()) +} diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs index 2a1780d5d3..2842086042 100644 --- a/src/rustup-cli/self_update.rs +++ b/src/rustup-cli/self_update.rs @@ -46,6 +46,7 @@ use tempdir::TempDir; use term2; pub struct InstallOpts { + pub default_host_triple: String, pub default_toolchain: String, pub no_modify_path: bool, } @@ -219,7 +220,7 @@ pub fn install(no_prompt: bool, verbose: bool, if !opts.no_modify_path { try!(do_add_to_path(&get_add_path_methods())); } - try!(maybe_install_rust(&opts.default_toolchain, verbose)); + try!(maybe_install_rust(&opts.default_toolchain, &opts.default_host_triple, verbose)); if cfg!(unix) { let ref env_file = try!(utils::cargo_home()).join("env"); @@ -392,9 +393,11 @@ fn current_install_opts(opts: &InstallOpts) -> String { format!( r"Current installation options: +- ` `default host triple: `{}` - ` `default toolchain: `{}` - modify PATH variable: `{}` ", + opts.default_host_triple, opts.default_toolchain, if !opts.no_modify_path { "yes" } else { "no" } ) @@ -409,6 +412,10 @@ fn customize_install(mut opts: InstallOpts) -> Result { println!(""); + opts.default_host_triple = try!(common::question_str( + "Default host triple?", + &opts.default_host_triple)); + opts.default_toolchain = try!(common::question_str( "Default toolchain? (stable/beta/nightly)", &opts.default_toolchain)); @@ -475,7 +482,7 @@ fn install_bins() -> Result<()> { Ok(()) } -fn maybe_install_rust(toolchain_str: &str, verbose: bool) -> Result<()> { +fn maybe_install_rust(toolchain_str: &str, default_host_triple: &str, verbose: bool) -> Result<()> { let ref cfg = try!(common::set_globals(verbose)); // If there is already an install, then `toolchain_str` may not be @@ -483,6 +490,8 @@ fn maybe_install_rust(toolchain_str: &str, verbose: bool) -> Result<()> { // This logic should be part of InstallOpts so that it isn't // possible to select a toolchain then have it not be installed. if try!(cfg.find_default()).is_none() { + // Set host triple first as it will affect resolution of toolchain_str + try!(cfg.set_default_host_triple(default_host_triple)); let toolchain = try!(cfg.get_toolchain(toolchain_str, false)); let status = try!(toolchain.install_from_dist()); try!(cfg.set_default(toolchain_str)); @@ -1069,8 +1078,8 @@ pub fn prepare_update() -> Result> { try!(utils::remove_file("setup", setup_path)); } - // Get host triple - let triple = dist::TargetTriple::from_host(); + // Get build triple + let triple = dist::TargetTriple::from_build(); let update_root = env::var("RUSTUP_UPDATE_ROOT") .unwrap_or(String::from(UPDATE_ROOT)); diff --git a/src/rustup-cli/setup_mode.rs b/src/rustup-cli/setup_mode.rs index 3eb603a499..20661716d4 100644 --- a/src/rustup-cli/setup_mode.rs +++ b/src/rustup-cli/setup_mode.rs @@ -2,6 +2,7 @@ use std::env; use self_update::{self, InstallOpts}; use errors::*; use clap::{App, Arg, AppSettings}; +use rustup_dist::dist::TargetTriple; use common; pub fn main() -> Result<()> { @@ -13,9 +14,9 @@ pub fn main() -> Result<()> { return self_update::self_replace(); } - let cli = App::new("multirust-setup") + let cli = App::new("rustup-init") .version(common::version()) - .about("The installer for multirust") + .about("The installer for rustup") .setting(AppSettings::DeriveDisplayOrder) .arg(Arg::with_name("verbose") .short("v") @@ -24,6 +25,10 @@ pub fn main() -> Result<()> { .arg(Arg::with_name("no-prompt") .short("y") .help("Disable confirmation prompt.")) + .arg(Arg::with_name("default-host") + .long("default-host") + .takes_value(true) + .help("Choose a default host triple")) .arg(Arg::with_name("default-toolchain") .long("default-toolchain") .takes_value(true) @@ -36,10 +41,14 @@ pub fn main() -> Result<()> { let matches = cli.get_matches(); let no_prompt = matches.is_present("no-prompt"); let verbose = matches.is_present("verbose"); + let default_host = matches.value_of("default-host").map(|s| s.to_owned()).unwrap_or_else(|| { + TargetTriple::from_host_or_build().to_string() + }); let default_toolchain = matches.value_of("default-toolchain").unwrap_or("stable"); let no_modify_path = matches.is_present("no-modify-path"); let opts = InstallOpts { + default_host_triple: default_host, default_toolchain: default_toolchain.to_owned(), no_modify_path: no_modify_path, }; diff --git a/src/rustup-dist/Cargo.toml b/src/rustup-dist/Cargo.toml index 1e050a2850..34b6c889ab 100644 --- a/src/rustup-dist/Cargo.toml +++ b/src/rustup-dist/Cargo.toml @@ -27,5 +27,15 @@ rustup-utils = { path = "../rustup-utils", version = "0.1.12" } error-chain = { path = "../error-chain", version = "0.1.12" } rustup-mock = { path = "../rustup-mock", version = "0.1.12" } +[target."cfg(windows)".dependencies] +winapi = "0.2.4" +winreg = "0.3.2" +user32-sys = "0.1.2" +kernel32-sys = "0.2.1" +gcc = "0.3.28" + +[target."cfg(not(windows))".dependencies] +libc = "0.2.0" + [lib] name = "rustup_dist" diff --git a/src/rustup-dist/src/dist.rs b/src/rustup-dist/src/dist.rs index 6913afea9f..76604c1d87 100644 --- a/src/rustup-dist/src/dist.rs +++ b/src/rustup-dist/src/dist.rs @@ -10,6 +10,7 @@ use manifestation::{Manifestation, UpdateStatus, Changes}; use std::path::Path; use std::fmt; +use std::env; use regex::Regex; use sha2::{Sha256, Digest}; @@ -71,13 +72,100 @@ impl TargetTriple { TargetTriple(name.to_string()) } - pub fn from_host() -> Self { - if let Some(triple) = option_env!("RUSTUP_OVERRIDE_HOST_TRIPLE") { + pub fn from_build() -> Self { + if let Some(triple) = option_env!("RUSTUP_OVERRIDE_BUILD_TRIPLE") { TargetTriple::from_str(triple) } else { TargetTriple::from_str(include_str!(concat!(env!("OUT_DIR"), "/target.txt"))) } } + + pub fn from_host() -> Option { + #[cfg(windows)] + fn inner() -> Option { + use gcc::windows_registry; + use kernel32::GetNativeSystemInfo; + use std::mem; + + // First detect architecture + const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9; + const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0; + + let mut sys_info; + unsafe { + sys_info = mem::zeroed(); + GetNativeSystemInfo(&mut sys_info); + } + + let arch = match sys_info.wProcessorArchitecture { + PROCESSOR_ARCHITECTURE_AMD64 => "x86_64", + PROCESSOR_ARCHITECTURE_INTEL => "i686", + _ => return None + }; + + // Now try to find an installation of msvc, using the gcc crate to do the hard work + let msvc_triple = format!("{}-pc-windows-msvc", arch); + let gnu_triple = format!("{}-pc-windows-gnu", arch); + if let Some(_) = windows_registry::find_tool(&msvc_triple, "cl.exe") { + // Found msvc, so default to the msvc triple + Some(TargetTriple(msvc_triple)) + } else { + // No msvc found, so use gnu triple as a fallback + Some(TargetTriple(gnu_triple)) + } + } + + #[cfg(not(windows))] + fn inner() -> Option { + use libc; + use std::mem; + use std::ffi::CStr; + + let mut sys_info; + let (sysname, machine) = unsafe { + sys_info = mem::zeroed(); + if libc::uname(&mut sys_info) != 0 { + return None; + } + + ( + CStr::from_ptr(sys_info.sysname.as_ptr()).to_bytes(), + CStr::from_ptr(sys_info.machine.as_ptr()).to_bytes(), + ) + }; + + let host_triple = match (sysname, machine) { + (b"Linux", b"x86_64") => Some("x86_64-unknown-linux-gnu"), + (b"Linux", b"i686") => Some("i686-unknown-linux-gnu"), + (b"Linux", b"mips") => Some("mips-unknown-linux-gnu"), + (b"Linux", b"mipsel") => Some("mipsel-unknown-linux-gnu"), + (b"Linux", b"arm") => Some("arm-unknown-linux-gnueabi"), + (b"Linux", b"aarch64") => Some("aarch64-unknown-linux-gnu"), + (b"Darwin", b"x86_64") => Some("x86_64-apple-darwin"), + (b"Darwin", b"i686") => Some("i686-apple-darwin"), + (b"FreeBSD", b"x86_64") => Some("x86_64-unknown-freebsd"), + (b"FreeBSD", b"i686") => Some("i686-unknown-freebsd"), + (b"OpenBSD", b"x86_64") => Some("x86_64-unknown-openbsd"), + (b"OpenBSD", b"i686") => Some("i686-unknown-openbsd"), + (b"NetBSD", b"x86_64") => Some("x86_64-unknown-netbsd"), + (b"NetBSD", b"i686") => Some("i686-unknown-netbsd"), + (b"DragonFly", b"x86_64") => Some("x86_64-unknown-dragonfly"), + _ => None + }; + + host_triple.map(TargetTriple::from_str) + } + + if let Ok(triple) = env::var("RUSTUP_OVERRIDE_HOST_TRIPLE") { + Some(TargetTriple(triple)) + } else { + inner() + } + } + + pub fn from_host_or_build() -> Self { + Self::from_host().unwrap_or_else(Self::from_build) + } } impl PartialTargetTriple { diff --git a/src/rustup-dist/src/lib.rs b/src/rustup-dist/src/lib.rs index a667129fbe..6d8716aa72 100644 --- a/src/rustup-dist/src/lib.rs +++ b/src/rustup-dist/src/lib.rs @@ -13,6 +13,19 @@ extern crate rustup_utils; extern crate error_chain; extern crate sha2; +#[cfg(windows)] +extern crate winapi; +#[cfg(windows)] +extern crate winreg; +#[cfg(windows)] +extern crate user32; +#[cfg(windows)] +extern crate kernel32; +#[cfg(windows)] +extern crate gcc; +#[cfg(not(windows))] +extern crate libc; + pub use errors::*; pub use notifications::{Notification, NotifyHandler}; diff --git a/src/rustup-mock/src/clitools.rs b/src/rustup-mock/src/clitools.rs index 6d32f25f2f..3619fba135 100644 --- a/src/rustup-mock/src/clitools.rs +++ b/src/rustup-mock/src/clitools.rs @@ -98,6 +98,11 @@ pub fn setup(s: Scenario, f: &Fn(&Config)) { fs::hard_link(rustup_path, rustc_path).unwrap(); fs::hard_link(rustup_path, cargo_path).unwrap(); + // Make sure the host triple matches the build triple. Otherwise testing a 32-bit build of + // rustup on a 64-bit machine will fail, because the tests do not have the host detection + // functionality built in. + run(&config, "rustup", &["set", "host", &this_host_triple()], &[]); + // Create some custom toolchains create_custom_toolchains(&config.customdir); @@ -208,6 +213,7 @@ pub fn env(config: &Config, cmd: &mut Command) { cmd.env("RUSTUP_HOME", config.rustupdir.to_string_lossy().to_string()); cmd.env("RUSTUP_DIST_ROOT", format!("file://{}", config.distdir.join("dist").to_string_lossy())); cmd.env("CARGO_HOME", config.cargodir.to_string_lossy().to_string()); + cmd.env("RUSTUP_OVERRIDE_HOST_TRIPLE", this_host_triple()); // This is only used for some installation tests on unix where CARGO_HOME // above is unset @@ -389,7 +395,7 @@ fn build_mock_channel(s: Scenario, channel: &str, date: &str, } pub fn this_host_triple() -> String { - if let Some(triple) = option_env!("RUSTUP_OVERRIDE_HOST_TRIPLE") { + if let Some(triple) = option_env!("RUSTUP_OVERRIDE_BUILD_TRIPLE") { triple.to_owned() } else { let arch = if cfg!(target_arch = "x86") { "i686" } diff --git a/src/rustup/config.rs b/src/rustup/config.rs index 29c3225032..6bab31bb8b 100644 --- a/src/rustup/config.rs +++ b/src/rustup/config.rs @@ -352,9 +352,22 @@ impl Cfg { toolchain.open_docs(relative) } + pub fn set_default_host_triple(&self, host_triple: &str) -> Result<()> { + self.settings_file.with_mut(|s| { + s.default_host_triple = Some(host_triple.to_owned()); + Ok(()) + }) + } + + pub fn get_default_host_triple(&self) -> Result { + Ok(try!(self.settings_file.with(|s| { + Ok(s.default_host_triple.as_ref().map(|s| dist::TargetTriple::from_str(&s))) + })).unwrap_or_else(dist::TargetTriple::from_build)) + } + pub fn resolve_toolchain(&self, name: &str) -> Result { if let Ok(desc) = dist::PartialToolchainDesc::from_str(name) { - let host = dist::TargetTriple::from_host(); + let host = try!(self.get_default_host_triple()); Ok(desc.resolve(&host).to_string()) } else { Ok(name.to_owned()) diff --git a/src/rustup/settings.rs b/src/rustup/settings.rs index f24d0bf73e..eca7e0f01a 100644 --- a/src/rustup/settings.rs +++ b/src/rustup/settings.rs @@ -124,6 +124,7 @@ pub enum TelemetryMode { #[derive(Clone, Debug, PartialEq)] pub struct Settings { pub version: String, + pub default_host_triple: Option, pub default_toolchain: Option, pub overrides: BTreeMap, pub telemetry: TelemetryMode @@ -133,6 +134,7 @@ impl Default for Settings { fn default() -> Self { Settings { version: DEFAULT_METADATA_VERSION.to_owned(), + default_host_triple: None, default_toolchain: None, overrides: BTreeMap::new(), telemetry: TelemetryMode::Off @@ -189,6 +191,7 @@ impl Settings { } Ok(Settings { version: version, + default_host_triple: try!(get_opt_string(&mut table, "default_host_triple", path)), default_toolchain: try!(get_opt_string(&mut table, "default_toolchain", path)), overrides: try!(Self::table_to_overrides(&mut table, path)), telemetry: if try!(get_opt_bool(&mut table, "telemetry", path)).unwrap_or(false) { @@ -204,6 +207,10 @@ impl Settings { result.insert("version".to_owned(), toml::Value::String(self.version)); + if let Some(v) = self.default_host_triple { + result.insert("default_host_triple".to_owned(), toml::Value::String(v)); + } + if let Some(v) = self.default_toolchain { result.insert("default_toolchain".to_owned(), toml::Value::String(v)); } diff --git a/tests/cli-inst-interactive.rs b/tests/cli-inst-interactive.rs index ea7490da65..87d7fb4ff5 100644 --- a/tests/cli-inst-interactive.rs +++ b/tests/cli-inst-interactive.rs @@ -63,7 +63,7 @@ fn update() { setup(&|config| { run_input(config, &["rustup-init"], "\n\n"); let out = run_input(config, &["rustup-init"], "\n\n"); - assert!(out.ok); + assert!(out.ok, "stdout:\n{}\nstderr:\n{}", out.stdout, out.stderr); }); } @@ -143,7 +143,7 @@ fn with_non_default_toolchain() { fn set_nightly_toolchain() { setup(&|config| { let out = run_input(config, &["rustup-init"], - "2\nnightly\n\n\n\n"); + "2\n\nnightly\n\n\n\n"); assert!(out.ok); expect_stdout_ok(config, &["rustup", "show"], "nightly"); @@ -154,7 +154,7 @@ fn set_nightly_toolchain() { fn set_no_modify_path() { setup(&|config| { let out = run_input(config, &["rustup-init"], - "2\n\nno\n\n\n"); + "2\n\n\nno\n\n\n"); assert!(out.ok); if cfg!(unix) { @@ -167,7 +167,7 @@ fn set_no_modify_path() { fn set_nightly_toolchain_and_unset() { setup(&|config| { let out = run_input(config, &["rustup-init"], - "2\nnightly\n\n2\nbeta\n\n\n\n"); + "2\n\nnightly\n\n2\n\nbeta\n\n\n\n"); assert!(out.ok); expect_stdout_ok(config, &["rustup", "show"], "beta"); @@ -178,7 +178,7 @@ fn set_nightly_toolchain_and_unset() { fn user_says_nope_after_advanced_install() { setup(&|config| { let out = run_input(config, &["rustup-init"], - "2\n\n\nn\n\n"); + "2\n\n\n\nn\n\n"); assert!(out.ok); assert!(!config.cargodir.join("bin").exists()); }); diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index facb9db285..e2953ad979 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -267,8 +267,10 @@ fn link() { fn show_toolchain_none() { setup(&|config| { expect_ok_ex(config, &["rustup", "show"], -r"no active toolchain -", +for_host!(r"Default host: {0} + +no active toolchain +"), r""); }); } @@ -278,7 +280,9 @@ fn show_toolchain_default() { setup(&|config| { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok_ex(config, &["rustup", "show"], -for_host!(r"nightly-{0} (default) +for_host!(r"Default host: {0} + +nightly-{0} (default) 1.3.0 (hash-n-2) "), r""); @@ -291,7 +295,9 @@ fn show_multiple_toolchains() { expect_ok(config, &["rustup", "default", "nightly"]); expect_ok(config, &["rustup", "update", "stable"]); expect_ok_ex(config, &["rustup", "show"], -for_host!(r"installed toolchains +for_host!(r"Default host: {0} + +installed toolchains -------------------- stable-{0} @@ -318,7 +324,9 @@ fn show_multiple_targets() { &format!("nightly-{}", clitools::MULTI_ARCH1)]); expect_ok(config, &["rustup", "target", "add", clitools::CROSS_ARCH2]); expect_ok_ex(config, &["rustup", "show"], -&format!(r"installed targets for active toolchain +&format!(r"Default host: {2} + +installed targets for active toolchain -------------------------------------- {1} @@ -330,7 +338,7 @@ active toolchain nightly-{0} (default) 1.3.0 (xxxx-n-2) -", clitools::MULTI_ARCH1, clitools::CROSS_ARCH2), +", clitools::MULTI_ARCH1, clitools::CROSS_ARCH2, this_host_triple()), r""); }); } @@ -346,7 +354,9 @@ fn show_multiple_toolchains_and_targets() { expect_ok(config, &["rustup", "update", &format!("stable-{}", clitools::MULTI_ARCH1)]); expect_ok_ex(config, &["rustup", "show"], -&format!(r"installed toolchains +&format!(r"Default host: {2} + +installed toolchains -------------------- stable-{0} @@ -364,7 +374,7 @@ active toolchain nightly-{0} (default) 1.3.0 (xxxx-n-2) -", clitools::MULTI_ARCH1, clitools::CROSS_ARCH2), +", clitools::MULTI_ARCH1, clitools::CROSS_ARCH2, this_host_triple()), r""); }); } @@ -389,7 +399,9 @@ fn show_toolchain_override() { let cwd = ::std::env::current_dir().unwrap(); expect_ok(config, &["rustup", "override", "add", "nightly"]); expect_ok_ex(config, &["rustup", "show"], -&format!(r"nightly-{} (directory override for '{}') +&format!(r"Default host: {0} + +nightly-{0} (directory override for '{1}') 1.3.0 (hash-n-2) ", this_host_triple(), cwd.display()), r""); @@ -418,7 +430,9 @@ fn show_toolchain_env() { let out = cmd.output().unwrap(); assert!(out.status.success()); let stdout = String::from_utf8(out.stdout).unwrap(); - assert!(&stdout == for_host!(r"nightly-{0} (environment override by RUSTUP_TOOLCHAIN) + assert!(&stdout == for_host!(r"Default host: {0} + +nightly-{0} (environment override by RUSTUP_TOOLCHAIN) 1.3.0 (hash-n-2) ")); }); @@ -453,7 +467,7 @@ fn update_doesnt_update_non_tracking_channels() { for_host!("syncing channel updates for 'nightly-2015-01-01-{}'"))); }); } - + #[test] fn toolchain_install_is_like_update() { setup(&|config| { diff --git a/tests/cli-self-upd.rs b/tests/cli-self-upd.rs index c7c3150930..6023ab682b 100644 --- a/tests/cli-self-upd.rs +++ b/tests/cli-self-upd.rs @@ -133,8 +133,8 @@ fn bins_are_executable() { #[test] fn install_creates_cargo_home() { setup(&|config| { - fs::remove_dir(&config.cargodir).unwrap(); - fs::remove_dir(&config.rustupdir).unwrap(); + fs::remove_dir_all(&config.cargodir).unwrap(); + fs::remove_dir_all(&config.rustupdir).unwrap(); expect_ok(config, &["rustup-init", "-y"]); assert!(config.cargodir.exists()); }); diff --git a/tests/cli-v2.rs b/tests/cli-v2.rs index 80c0fccf01..23213173b5 100644 --- a/tests/cli-v2.rs +++ b/tests/cli-v2.rs @@ -520,7 +520,7 @@ fn add_target_again() { #[test] fn add_target_host() { setup(&|config| { - let trip = TargetTriple::from_host(); + let trip = TargetTriple::from_build(); expect_ok(config, &["rustup", "default", "nightly"]); expect_err(config, &["rustup", "target", "add", &trip.to_string()], for_host!("component 'rust-std' for target '{0}' is required for toolchain 'nightly-{0}' and cannot be re-added")); @@ -603,7 +603,7 @@ fn remove_target_again() { #[test] fn remove_target_host() { setup(&|config| { - let trip = TargetTriple::from_host(); + let trip = TargetTriple::from_build(); expect_ok(config, &["rustup", "default", "nightly"]); expect_err(config, &["rustup", "target", "remove", &trip.to_string()], for_host!("component 'rust-std' for target '{0}' is required for toolchain 'nightly-{0}' and cannot be removed")); @@ -634,7 +634,7 @@ fn make_component_unavailable(config: &Config, name: &str, target: &TargetTriple #[test] fn update_unavailable_std() { setup(&|config| { - let ref trip = TargetTriple::from_host(); + let ref trip = TargetTriple::from_build(); make_component_unavailable(config, "rust-std", trip); expect_err(config, &["rustup", "update", "nightly"], &format!("component 'rust-std' for '{}' is unavailable for download", trip));