Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn if complete profile is used #2138

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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