Skip to content

Commit

Permalink
Merge pull request #2138 from Stupremee/warn-on-complete-profile
Browse files Browse the repository at this point in the history
Warn if complete profile is used
  • Loading branch information
kinnison authored Nov 26, 2019
2 parents 3f9e3ba + 22596e1 commit 2200a24
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use std::{cmp, env, iter};
use term2::Terminal;
use wait_timeout::ChildExt;

pub const WARN_COMPLETE_PROFILE: &str = "downloading with complete profile isn't recommended unless you are a developer of the rust language";

pub fn confirm(question: &str, default: bool) -> Result<bool> {
print!("{} ", question);
let _ = std::io::stdout().flush();
Expand Down
3 changes: 3 additions & 0 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<()> {
cfg.set_profile_override(p);
}
let cfg = &cfg;
if cfg.get_profile()? == Profile::Complete {
warn!("{}", common::WARN_COMPLETE_PROFILE);
}
if let Some(names) = m.values_of("toolchain") {
for name in names {
update_bare_triple_check(cfg, name)?;
Expand Down
4 changes: 4 additions & 0 deletions src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ pub fn main() -> Result<()> {
targets: &targets,
};

if profile == "complete" {
warn!("{}", common::WARN_COMPLETE_PROFILE);
}

self_update::install(no_prompt, verbose, quiet, opts)?;

Ok(())
Expand Down
14 changes: 13 additions & 1 deletion tests/cli-inst-interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
pub mod mock;

use crate::mock::clitools::{
self, expect_stdout_ok, set_current_dist_date, Config, SanitizedOutput, Scenario,
self, expect_stderr_ok, expect_stdout_ok, set_current_dist_date, Config, SanitizedOutput,
Scenario,
};
use crate::mock::{get_path, restore_path};
use lazy_static::lazy_static;
Expand Down Expand Up @@ -254,3 +255,14 @@ fn install_forces_and_skips_rls() {
.contains("warning: Force-skipping unavailable component"));
});
}

#[test]
fn test_warn_if_complete_profile_is_used() {
setup(&|config| {
expect_stderr_ok(
config,
&["rustup-init", "-y", "--profile", "complete"],
"warning: downloading with complete profile",
);
});
}
18 changes: 18 additions & 0 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,24 @@ fn install_with_component_and_target() {
})
}

#[test]
fn test_warn_if_complete_profile_is_used() {
setup(&|config| {
expect_err(
config,
&[
"rustup",
"toolchain",
"install",
"--profile",
"complete",
"stable",
],
"warning: downloading with complete profile",
);
});
}

#[test]
fn test_complete_profile_skips_missing_when_forced() {
setup_complex(&|config| {
Expand Down

0 comments on commit 2200a24

Please sign in to comment.