Skip to content

Commit

Permalink
test: clean up "--no-self-update" args
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed May 19, 2021
1 parent 669b7c6 commit e77a228
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 415 deletions.
55 changes: 23 additions & 32 deletions tests/cli-exact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn update_once() {
setup(&|config| {
expect_ok_ex(
config,
&["rustup", "update", "nightly", "--no-self-update"],
&["rustup", "update", "nightly"],
for_host!(
r"
nightly-{0} installed - 1.3.0 (hash-nightly-2)
Expand Down Expand Up @@ -47,14 +47,11 @@ info: default toolchain set to 'nightly-{0}'
#[test]
fn update_again() {
setup(&|config| {
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(
config,
&["rustup", "upgrade", "nightly", "--no-self-update"],
);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_ok(config, &["rustup", "upgrade", "nightly"]);
expect_ok_ex(
config,
&["rustup", "update", "nightly", "--no-self-update"],
&["rustup", "update", "nightly"],
for_host!(
r"
nightly-{0} unchanged - 1.3.0 (hash-nightly-2)
Expand All @@ -68,7 +65,7 @@ fn update_again() {
);
expect_ok_ex(
config,
&["rustup", "upgrade", "nightly", "--no-self-update"],
&["rustup", "upgrade", "nightly"],
for_host!(
r"
nightly-{0} unchanged - 1.3.0 (hash-nightly-2)
Expand All @@ -87,15 +84,12 @@ fn update_again() {
fn check_updates_none() {
check_update_setup(&|config| {
set_current_dist_date(config, "2015-01-01");
expect_ok(config, &["rustup", "update", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "upgrade", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "upgrade", "beta", "--no-self-update"]);
expect_ok(
config,
&["rustup", "upgrade", "nightly", "--no-self-update"],
);
expect_ok(config, &["rustup", "update", "stable"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_ok(config, &["rustup", "upgrade", "stable"]);
expect_ok(config, &["rustup", "upgrade", "beta"]);
expect_ok(config, &["rustup", "upgrade", "nightly"]);
expect_stdout_ok(
config,
&["rustup", "check"],
Expand All @@ -113,15 +107,12 @@ nightly-{0} - Up to date : 1.2.0 (hash-nightly-1)
fn check_updates_some() {
check_update_setup(&|config| {
set_current_dist_date(config, "2015-01-01");
expect_ok(config, &["rustup", "update", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "upgrade", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "upgrade", "beta", "--no-self-update"]);
expect_ok(
config,
&["rustup", "upgrade", "nightly", "--no-self-update"],
);
expect_ok(config, &["rustup", "update", "stable"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_ok(config, &["rustup", "upgrade", "stable"]);
expect_ok(config, &["rustup", "upgrade", "beta"]);
expect_ok(config, &["rustup", "upgrade", "nightly"]);
set_current_dist_date(config, "2015-01-02");
expect_stdout_ok(
config,
Expand Down Expand Up @@ -182,9 +173,9 @@ fn check_updates_self_no_change() {
fn check_updates_with_update() {
check_update_setup(&|config| {
set_current_dist_date(config, "2015-01-01");
expect_ok(config, &["rustup", "update", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "stable"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(
config,
&["rustup", "check"],
Expand All @@ -206,7 +197,7 @@ nightly-{0} - Update available : 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2
"
),
);
expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_stdout_ok(
config,
&["rustup", "check"],
Expand Down Expand Up @@ -613,7 +604,7 @@ fn install_unreleased_component() {
set_current_dist_date(config, "2019-09-13");
expect_ok_ex(
config,
&["rustup", "update", "nightly", "--no-self-update"],
&["rustup", "update", "nightly"],
&for_host!(
r"
nightly-{} unchanged - 1.37.0 (hash-nightly-1)
Expand All @@ -635,7 +626,7 @@ info: syncing channel updates for 'nightly-2019-09-12-{0}'
set_current_dist_date(config, "2019-09-14");
expect_ok_ex(
config,
&["rustup", "update", "nightly", "--no-self-update"],
&["rustup", "update", "nightly"],
&for_host!(
r"
nightly-{} unchanged - 1.37.0 (hash-nightly-1)
Expand Down
50 changes: 22 additions & 28 deletions tests/cli-misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn update_all_no_update_whitespace() {
setup(&|config| {
expect_stdout_ok(
config,
&["rustup", "update", "nightly", "--no-self-update"],
&["rustup", "update", "nightly"],
for_host!(
r"
nightly-{} installed - 1.3.0 (hash-nightly-2)
Expand All @@ -127,7 +127,7 @@ fn update_all_no_update_whitespace() {
#[test]
fn update_works_without_term() {
setup(&|config| {
let mut cmd = clitools::cmd(config, "rustup", &["update", "nightly", "--no-self-update"]);
let mut cmd = clitools::cmd(config, "rustup", &["update", "nightly"]);
clitools::env(config, &mut cmd);
cmd.env_remove("TERM");

Expand Down Expand Up @@ -234,13 +234,13 @@ fn custom_toolchain_cargo_fallback_proxy() {
);
expect_ok(config, &["rustup", "default", "mytoolchain"]);

expect_ok(config, &["rustup", "update", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "stable"]);
expect_stdout_ok(config, &["cargo", "--version"], "hash-stable-1.1.0");

expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_stdout_ok(config, &["cargo", "--version"], "hash-beta-1.2.0");

expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(config, &["cargo", "--version"], "hash-nightly-2");
});
}
Expand All @@ -262,21 +262,21 @@ fn custom_toolchain_cargo_fallback_run() {
);
expect_ok(config, &["rustup", "default", "mytoolchain"]);

expect_ok(config, &["rustup", "update", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "stable"]);
expect_stdout_ok(
config,
&["rustup", "run", "mytoolchain", "cargo", "--version"],
"hash-stable-1.1.0",
);

expect_ok(config, &["rustup", "update", "beta", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "beta"]);
expect_stdout_ok(
config,
&["rustup", "run", "mytoolchain", "cargo", "--version"],
"hash-beta-1.2.0",
);

expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(
config,
&["rustup", "run", "mytoolchain", "cargo", "--version"],
Expand Down Expand Up @@ -379,7 +379,7 @@ fn rustup_failed_path_search_toolchain() {
#[test]
fn rustup_run_not_installed() {
setup(&|config| {
expect_ok(config, &["rustup", "install", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "install", "stable"]);
expect_err(
config,
&["rustup", "run", "nightly", "rustc", "--version"],
Expand All @@ -391,7 +391,7 @@ fn rustup_run_not_installed() {
#[test]
fn rustup_run_install() {
setup(&|config| {
expect_ok(config, &["rustup", "install", "stable", "--no-self-update"]);
expect_ok(config, &["rustup", "install", "stable"]);
expect_stderr_ok(
config,
&[
Expand Down Expand Up @@ -471,7 +471,7 @@ fn run_rls_when_not_available_in_toolchain() {
);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);
expect_ok(config, &["rustup", "component", "add", "rls"]);

expect_ok(config, &["rls", "--version"]);
Expand Down Expand Up @@ -519,7 +519,7 @@ fn rename_rls_before() {
expect_ok(config, &["rustup", "component", "add", "rls"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);

assert!(config.exedir.join(format!("rls{}", EXE_SUFFIX)).exists());
expect_ok(config, &["rls", "--version"]);
Expand All @@ -533,7 +533,7 @@ fn rename_rls_after() {
expect_ok(config, &["rustup", "default", "nightly"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);
expect_ok(config, &["rustup", "component", "add", "rls-preview"]);

assert!(config.exedir.join(format!("rls{}", EXE_SUFFIX)).exists());
Expand All @@ -548,7 +548,7 @@ fn rename_rls_add_old_name() {
expect_ok(config, &["rustup", "default", "nightly"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);
expect_ok(config, &["rustup", "component", "add", "rls"]);

assert!(config.exedir.join(format!("rls{}", EXE_SUFFIX)).exists());
Expand All @@ -563,7 +563,7 @@ fn rename_rls_list() {
expect_ok(config, &["rustup", "default", "nightly"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);
expect_ok(config, &["rustup", "component", "add", "rls"]);

let out = run(config, "rustup", &["component", "list"], &[]);
Expand All @@ -579,7 +579,7 @@ fn rename_rls_preview_list() {
expect_ok(config, &["rustup", "default", "nightly"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);
expect_ok(config, &["rustup", "component", "add", "rls-preview"]);

let out = run(config, "rustup", &["component", "list"], &[]);
Expand All @@ -595,7 +595,7 @@ fn rename_rls_remove() {
expect_ok(config, &["rustup", "default", "nightly"]);

set_current_dist_date(config, "2015-01-02");
expect_ok(config, &["rustup", "update", "--no-self-update"]);
expect_ok(config, &["rustup", "update"]);

expect_ok(config, &["rustup", "component", "add", "rls"]);
expect_ok(config, &["rls", "--version"]);
Expand Down Expand Up @@ -677,7 +677,7 @@ fn update_unavailable_rustc() {
// latest nightly is unavailable
set_current_dist_date(config, "2015-01-02");
// update should do nothing
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-nightly-1");
});
}
Expand Down Expand Up @@ -717,7 +717,7 @@ fn update_nightly_even_with_incompat() {

expect_component_executable(config, "rls");
// update should bring us to latest nightly that does
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-nightly-2");
expect_component_executable(config, "rls");
});
Expand All @@ -737,7 +737,7 @@ fn nightly_backtrack_skips_missing() {
set_current_dist_date(config, "2019-09-18");

// update should not change nightly, and should not error
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);
expect_ok(config, &["rustup", "update", "nightly"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-nightly-1");
});
}
Expand Down Expand Up @@ -958,13 +958,7 @@ fn deprecated_interfaces() {
// In verbose mode we want the deprecated interfaces to complain
expect_ok_contains(
config,
&[
"rustup",
"--verbose",
"install",
"nightly",
"--no-self-update",
],
&["rustup", "--verbose", "install", "nightly"],
"",
"Please use `rustup toolchain install` instead",
);
Expand All @@ -977,7 +971,7 @@ fn deprecated_interfaces() {
// But if not verbose then they should *NOT* complain
expect_not_stderr_ok(
config,
&["rustup", "install", "nightly", "--no-self-update"],
&["rustup", "install", "nightly"],
"Please use `rustup toolchain install` instead",
);
expect_not_stderr_ok(
Expand Down
Loading

0 comments on commit e77a228

Please sign in to comment.