Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Jan 9, 2019
1 parent fda7cb9 commit b132485
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/rustup-cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ pub fn update_all_channels(cfg: &Cfg, do_self_update: bool, force_update: bool)
}

pub fn self_update<F>(before_restart: F) -> Result<()>
where F: FnOnce() -> Result<()>
where
F: FnOnce() -> Result<()>,
{
let setup_path = self_update::prepare_update()?;

Expand Down
6 changes: 1 addition & 5 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,7 @@ fn update(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
common::self_update(|| Ok(()))?;
}
} else {
common::update_all_channels(
cfg,
self_update,
m.is_present("force"),
)?;
common::update_all_channels(cfg, self_update, m.is_present("force"))?;
}

Ok(())
Expand Down
156 changes: 138 additions & 18 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,13 @@ fn rustup_xz() {
set_current_dist_date(config, "2015-01-01");
expect_stderr_ok(
config,
&["rustup", "--verbose", "update", "nightly", "--no-self-update"],
&[
"rustup",
"--verbose",
"update",
"nightly",
"--no-self-update",
],
for_host!(r"dist/2015-01-01/rust-std-nightly-{0}.tar.xz"),
);
});
Expand Down Expand Up @@ -904,7 +910,10 @@ fn set_default_host_invalid_triple() {
fn update_doesnt_update_non_tracking_channels() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "nightly"]);
expect_ok(config, &["rustup", "update", "nightly-2015-01-01", "--no-self-update"]);
expect_ok(
config,
&["rustup", "update", "nightly-2015-01-01", "--no-self-update"],
);
let mut cmd = clitools::cmd(config, "rustup", &["update"]);
clitools::env(config, &mut cmd);
let out = cmd.output().unwrap();
Expand All @@ -918,7 +927,16 @@ fn update_doesnt_update_non_tracking_channels() {
#[test]
fn toolchain_install_is_like_update() {
setup(&|config| {
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);
expect_stdout_ok(
config,
&["rustup", "run", "nightly", "rustc", "--version"],
Expand All @@ -941,7 +959,16 @@ fn toolchain_install_is_like_update_except_that_bare_install_is_an_error() {
#[test]
fn toolchain_update_is_like_update() {
setup(&|config| {
expect_ok(config, &["rustup", "toolchain", "update", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"update",
"nightly",
"--no-self-update",
],
);
expect_stdout_ok(
config,
&["rustup", "run", "nightly", "rustc", "--version"],
Expand Down Expand Up @@ -978,7 +1005,16 @@ fn toolchain_update_is_like_update_except_that_bare_install_is_an_error() {
fn proxy_toolchain_shorthand() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "update", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"update",
"nightly",
"--no-self-update",
],
);
expect_stdout_ok(config, &["rustc", "--version"], "hash-s-2");
expect_stdout_ok(config, &["rustc", "+stable", "--version"], "hash-s-2");
expect_stdout_ok(config, &["rustc", "+nightly", "--version"], "hash-n-2");
Expand Down Expand Up @@ -1237,7 +1273,16 @@ fn multirust_upgrade_works_with_proxy() {
fn file_override() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

expect_stdout_ok(config, &["rustc", "--version"], "hash-s-2");

Expand All @@ -1253,7 +1298,16 @@ fn file_override() {
fn file_override_subdir() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

expect_stdout_ok(config, &["rustc", "--version"], "hash-s-2");

Expand All @@ -1275,7 +1329,13 @@ fn file_override_with_archive() {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "nightly-2015-01-01", "--no-self-update"],
&[
"rustup",
"toolchain",
"install",
"nightly-2015-01-01",
"--no-self-update",
],
);

expect_stdout_ok(config, &["rustc", "--version"], "hash-s-2");
Expand All @@ -1292,8 +1352,20 @@ fn file_override_with_archive() {
fn directory_override_beats_file_override() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "beta", "--no-self-update"],
);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

expect_ok(config, &["rustup", "override", "set", "beta"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-b-2");
Expand All @@ -1310,8 +1382,20 @@ fn directory_override_beats_file_override() {
fn close_file_override_beats_far_directory_override() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "beta", "--no-self-update"],
);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

expect_ok(config, &["rustup", "override", "set", "beta"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-b-2");
Expand All @@ -1334,7 +1418,10 @@ fn close_file_override_beats_far_directory_override() {
fn directory_override_doesnt_need_to_exist_unless_it_is_selected() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "beta", "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "beta", "--no-self-update"],
);
// not installing nightly

expect_ok(config, &["rustup", "override", "set", "beta"]);
Expand All @@ -1352,8 +1439,20 @@ fn directory_override_doesnt_need_to_exist_unless_it_is_selected() {
fn env_override_beats_file_override() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "beta", "--no-self-update"],
);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

let cwd = config.current_dir();
let toolchain_file = cwd.join("rust-toolchain");
Expand All @@ -1372,8 +1471,20 @@ fn env_override_beats_file_override() {
fn plus_override_beats_file_override() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", "install", "beta", "--no-self-update"],
);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

let cwd = config.current_dir();
let toolchain_file = cwd.join("rust-toolchain");
Expand Down Expand Up @@ -1417,7 +1528,16 @@ fn file_override_with_target_info() {
fn docs_with_path() {
setup(&|config| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "toolchain", "install", "nightly", "--no-self-update"]);
expect_ok(
config,
&[
"rustup",
"toolchain",
"install",
"nightly",
"--no-self-update",
],
);

let mut cmd = clitools::cmd(config, "rustup", &["doc", "--path"]);
clitools::env(config, &mut cmd);
Expand Down
11 changes: 9 additions & 2 deletions tests/cli-v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ fn update_channel() {
fn list_toolchains() {
clitools::setup(Scenario::ArchivesV1, &|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta-2015-01-01", "--no-self-update"]);
expect_ok(
config,
&["rustup", "update", "beta-2015-01-01", "--no-self-update"],
);
expect_stdout_ok(config, &["rustup", "toolchain", "list"], "nightly");
expect_stdout_ok(config, &["rustup", "toolchain", "list"], "beta-2015-01-01");
});
Expand Down Expand Up @@ -321,7 +324,11 @@ fn remove_override_with_multiple_overrides() {
fn no_update_on_channel_when_date_has_not_changed() {
setup(&|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_stdout_ok(config, &["rustup", "update", "nightly", "--no-self-update"], "unchanged");
expect_stdout_ok(
config,
&["rustup", "update", "nightly", "--no-self-update"],
"unchanged",
);
});
}

Expand Down
16 changes: 13 additions & 3 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ fn update_channel() {
fn list_toolchains() {
clitools::setup(Scenario::ArchivesV2, &|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta-2015-01-01", "--no-self-update"]);
expect_ok(
config,
&["rustup", "update", "beta-2015-01-01", "--no-self-update"],
);
expect_stdout_ok(config, &["rustup", "toolchain", "list"], "nightly");
expect_stdout_ok(config, &["rustup", "toolchain", "list"], "beta-2015-01-01");
});
Expand Down Expand Up @@ -152,7 +155,10 @@ fn add_remove_multiple_toolchains() {
let tch1 = "beta";
let tch2 = "nightly";

expect_ok(config, &["rustup", "toolchain", add, tch1, tch2, "--no-self-update"]);
expect_ok(
config,
&["rustup", "toolchain", add, tch1, tch2, "--no-self-update"],
);
expect_ok(config, &["rustup", "toolchain", "list"]);
expect_stdout_ok(config, &["rustup", "toolchain", "list"], tch1);
expect_stdout_ok(config, &["rustup", "toolchain", "list"], tch2);
Expand Down Expand Up @@ -418,7 +424,11 @@ fn remove_override_with_multiple_overrides() {
fn no_update_on_channel_when_date_has_not_changed() {
setup(&|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_stdout_ok(config, &["rustup", "update", "nightly", "--no-self-update"], "unchanged");
expect_stdout_ok(
config,
&["rustup", "update", "nightly", "--no-self-update"],
"unchanged",
);
});
}

Expand Down

0 comments on commit b132485

Please sign in to comment.