Skip to content

Commit

Permalink
test: add check-only and enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed May 19, 2021
1 parent e77a228 commit fdcde20
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
80 changes: 80 additions & 0 deletions tests/cli-exact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
1 change: 1 addition & 0 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
&[
Expand Down

0 comments on commit fdcde20

Please sign in to comment.