Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/rustup-mock/src/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
23 changes: 9 additions & 14 deletions tests/cli-self-upd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)

",
Expand All @@ -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
"
);
});
}

Expand Down