diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 63fc193a814..b51b51d48e3 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -8,13 +8,15 @@ use std::str::FromStr; use anyhow::{anyhow, bail, Error, Result}; use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, Shell, SubCommand}; -use super::common; use super::help::*; use super::self_update; use super::term2; use super::term2::Terminal; use super::topical_doc; -use crate::cli::self_update::{check_rustup_update, SELF_UPDATE_MODES}; +use super::{ + common, + self_update::{check_rustup_update, SELF_UPDATE_MODES}, +}; use crate::dist::dist::{ PartialTargetTriple, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc, }; diff --git a/tests/cli-exact.rs b/tests/cli-exact.rs index dd8a933cf85..e7fa2124916 100644 --- a/tests/cli-exact.rs +++ b/tests/cli-exact.rs @@ -44,6 +44,86 @@ info: default toolchain set to 'nightly-{0}' }); } +#[test] +fn update_once_and_check_self_update() { + let test_version = "2.0.0"; + + self_update_setup( + &|config, _| { + expect_ok(config, &["rustup-init", "-y", "--no-modify-path"]); + expect_ok(config, &["rustup", "set", "auto-self-update", "check-only"]); + let current_version = env!("CARGO_PKG_VERSION"); + + expect_ok_ex( + config, + &["rustup", "update", "nightly"], + &format!( + r" + nightly-{} installed - 1.3.0 (hash-nightly-2) + +rustup - Update available : {} -> {} +", + &this_host_triple(), + current_version, + test_version + ), + for_host!( + r"info: syncing channel updates for 'nightly-{0}' +info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: downloading component 'cargo' +info: downloading component 'rust-docs' +info: downloading component 'rust-std' +info: downloading component 'rustc' +info: installing component 'cargo' +info: installing component 'rust-docs' +info: installing component 'rust-std' +info: installing component 'rustc' +" + ), + ); + }, + test_version, + ) +} + +#[test] +fn update_once_and_self_update() { + let test_version = "2.0.0"; + + self_update_setup( + &|config, _| { + expect_ok(config, &["rustup-init", "-y", "--no-modify-path"]); + expect_ok(config, &["rustup", "set", "auto-self-update", "enable"]); + expect_ok_ex( + config, + &["rustup", "update", "nightly"], + for_host!( + r" + nightly-{0} installed - 1.3.0 (hash-nightly-2) + +" + ), + for_host!( + r"info: syncing channel updates for 'nightly-{0}' +info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +info: downloading component 'cargo' +info: downloading component 'rust-docs' +info: downloading component 'rust-std' +info: downloading component 'rustc' +info: installing component 'cargo' +info: installing component 'rust-docs' +info: installing component 'rust-std' +info: installing component 'rustc' +info: checking for self-updates +info: downloading self-update +" + ), + ); + }, + test_version, + ) +} + #[test] fn update_again() { setup(&|config| { diff --git a/tests/cli-v2.rs b/tests/cli-v2.rs index 877b90f7942..d0b2ebf92ab 100644 --- a/tests/cli-v2.rs +++ b/tests/cli-v2.rs @@ -1319,6 +1319,7 @@ fn install_with_component_and_target() { #[test] fn test_warn_if_complete_profile_is_used() { setup(&|config| { + expect_ok(config, &["rustup", "set", "auto-self-update", "enable"]); expect_err( config, &[