diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs index 7288d77743..e675934fec 100644 --- a/src/rustup-cli/self_update.rs +++ b/src/rustup-cli/self_update.rs @@ -302,30 +302,29 @@ pub fn install(no_prompt: bool, verbose: bool, mut opts: InstallOpts) -> Result< process::exit(1); } - // More helpful advice, skip if -y - if !no_prompt { - let cargo_home = try!(canonical_cargo_home()); - let msg = if !opts.no_modify_path { - if cfg!(unix) { - format!(post_install_msg_unix!(), cargo_home = cargo_home) - } else { - format!(post_install_msg_win!(), cargo_home = cargo_home) - } + let cargo_home = try!(canonical_cargo_home()); + let msg = if !opts.no_modify_path { + if cfg!(unix) { + format!(post_install_msg_unix!(), cargo_home = cargo_home) } else { - if cfg!(unix) { - format!( - post_install_msg_unix_no_modify_path!(), - cargo_home = cargo_home - ) - } else { - format!( - post_install_msg_win_no_modify_path!(), - cargo_home = cargo_home - ) - } - }; - term2::stdout().md(msg); + format!(post_install_msg_win!(), cargo_home = cargo_home) + } + } else { + if cfg!(unix) { + format!( + post_install_msg_unix_no_modify_path!(), + cargo_home = cargo_home + ) + } else { + format!( + post_install_msg_win_no_modify_path!(), + cargo_home = cargo_home + ) + } + }; + term2::stdout().md(msg); + if !no_prompt { // On windows, where installation happens in a console // that may have opened just for this purpose, require // the user to press a key to continue. diff --git a/src/rustup-mock/src/clitools.rs b/src/rustup-mock/src/clitools.rs index 2f6533eaa6..d93fe8b25b 100644 --- a/src/rustup-mock/src/clitools.rs +++ b/src/rustup-mock/src/clitools.rs @@ -238,6 +238,18 @@ pub fn expect_err_ex(config: &Config, args: &[&str], stdout: &str, stderr: &str) } } +pub fn expect_ok_contains(config: &Config, args: &[&str], + stdout: &str, stderr: &str) { + let out = run(config, args[0], &args[1..], &[]); + if !out.ok || !out.stdout.contains(stdout) || !out.stderr.contains(stderr) { + print_command(args, &out); + println!("expected.ok: {}", true); + print_indented("expected.stdout.contains", stdout); + print_indented("expected.stderr.contains", stderr); + panic!(); + } +} + pub fn expect_timeout_ok(config: &Config, timeout: Duration, args: &[&str]) { let mut child = cmd(config, args[0], &args[1..]) .stdout(Stdio::null()) diff --git a/tests/cli-self-upd.rs b/tests/cli-self-upd.rs index 1520b58f7f..cc4165ab21 100644 --- a/tests/cli-self-upd.rs +++ b/tests/cli-self-upd.rs @@ -25,8 +25,9 @@ use std::path::Path; use std::fs; use std::process::Command; use remove_dir_all::remove_dir_all; -use rustup_mock::clitools::{self, expect_err, expect_err_ex, expect_ok, expect_ok_ex, - expect_stderr_ok, expect_stdout_ok, this_host_triple, Config, Scenario}; +use rustup_mock::clitools::{self, expect_err, expect_err_ex, expect_ok, expect_ok_contains, + expect_ok_ex, expect_stderr_ok, expect_stdout_ok, this_host_triple, + Config, Scenario}; use rustup_mock::dist::calc_hash; use rustup_mock::{get_path, restore_path}; use rustup_utils::{raw, utils}; @@ -813,10 +814,8 @@ fn as_rustup_setup() { #[test] fn first_install_exact() { setup(&|config| { - expect_ok_ex( - config, - &["rustup-init", "-y"], - r" + expect_ok_contains(config, &["rustup-init", "-y"], +r" stable installed - 1.1.0 (hash-s-2) ", @@ -842,14 +841,10 @@ info: default toolchain set to 'stable' fn reinstall_exact() { setup(&|config| { expect_ok(config, &["rustup-init", "-y"]); - expect_ok_ex( - config, - &["rustup-init", "-y"], - r" -", - r"info: updating existing rustup installation -", - ); + expect_stderr_ok(config, &["rustup-init", "-y"], +r"info: updating existing rustup installation +" + ); }); }