Skip to content

Commit 63cd03e

Browse files
committed
WIP tests
1 parent b999849 commit 63cd03e

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ pub fn cli() -> App<'static, 'static> {
130130
.about("Show the active toolchain")
131131
.after_help(SHOW_ACTIVE_TOOLCHAIN_HELP),
132132
)
133-
.subcommand(
134-
SubCommand::with_name("profile")
135-
.about("Show the current profile"),
136-
),
133+
.subcommand(SubCommand::with_name("profile").about("Show the current profile")),
137134
)
138135
.subcommand(
139136
SubCommand::with_name("install")
@@ -1054,10 +1051,6 @@ fn self_uninstall(m: &ArgMatches<'_>) -> Result<()> {
10541051
self_update::uninstall(no_prompt)
10551052
}
10561053

1057-
<<<<<<< HEAD
1058-
fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1059-
cfg.set_default_host_triple(m.value_of("host_triple").expect(""))?;
1060-
=======
10611054
fn set_telemetry(cfg: &Cfg, t: TelemetryMode) -> Result<()> {
10621055
match t {
10631056
TelemetryMode::On => Ok(cfg.set_telemetry(true)?),
@@ -1070,8 +1063,8 @@ fn analyze_telemetry(cfg: &Cfg) -> Result<()> {
10701063
common::show_telemetry(analysis)
10711064
}
10721065

1073-
fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
1074-
cfg.set_default_host_triple(m.value_of("host_triple").unwrap())?;
1066+
fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
1067+
cfg.set_default_host_triple(m.value_of("host_triple").expect(""))?;
10751068
Ok(())
10761069
}
10771070

@@ -1081,7 +1074,6 @@ fn set_profile(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
10811074
}
10821075

10831076
fn show_profile(cfg: &Cfg) -> Result<()> {
1084-
println!("{}", cfg.get_profile()?);
1085-
>>>>>>> show and set profiles in the CLI
1077+
println!("{}", cfg.get_profile()?);
10861078
Ok(())
10871079
}

src/rustup-mock/src/clitools.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ fn build_mock_channel(
620620
date: date.to_string(),
621621
packages,
622622
renames,
623+
has_profiles: false,
623624
}
624625
}
625626

@@ -655,6 +656,7 @@ fn build_mock_unavailable_channel(channel: &str, date: &str, version: &'static s
655656
date: date.to_string(),
656657
packages,
657658
renames: HashMap::new(),
659+
has_profiles: false,
658660
}
659661
}
660662

src/rustup-mock/src/dist.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub struct MockChannel {
7474
pub date: String,
7575
pub packages: Vec<MockPackage>,
7676
pub renames: HashMap<String, String>,
77+
pub has_profiles: bool,
7778
}
7879

7980
// A single rust-installer package
@@ -399,6 +400,26 @@ impl MockDistServer {
399400
}
400401
toml_manifest.insert(String::from("renames"), toml::Value::Table(toml_renames));
401402

403+
if channel.has_profiles {
404+
let mut toml_profiles = toml::value::Table::new();
405+
let profiles = &[
406+
("minimal", vec!["rustc", "cargo", "rust-std"]),
407+
("default", vec!["rustc", "cargo", "rust-std", "rust-docs"]),
408+
(
409+
"complete",
410+
vec!["rustc", "cargo", "rust-std", "rust-docs", "rust-src"],
411+
),
412+
];
413+
for (profile, values) in profiles {
414+
let array = values
415+
.into_iter()
416+
.map(|v| toml::Value::String((**v).to_owned()))
417+
.collect();
418+
toml_profiles.insert(profile.to_string(), toml::Value::Array(array));
419+
}
420+
toml_manifest.insert(String::from("profiles"), toml::Value::Table(toml_profiles));
421+
}
422+
402423
let manifest_name = format!("dist/channel-rust-{}", channel.name);
403424
let ref manifest_path = self.path.join(format!("{}.toml", manifest_name));
404425
write_file(manifest_path, &toml::to_string(&toml_manifest).unwrap());

tests/cli-misc.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ fn profiles() {
794794
expect_stdout_ok(config, &["rustup", "show", "profile"], "default");
795795
expect_ok(config, &["rustup", "set", "profile", "minimal"]);
796796
expect_stdout_ok(config, &["rustup", "show", "profile"], "minimal");
797-
expect_err(config, &["rustup", "set", "profile", "maximal"], "unknown profile");
797+
expect_err(
798+
config,
799+
&["rustup", "set", "profile", "maximal"],
800+
"unknown profile",
801+
);
798802
});
799803
}

0 commit comments

Comments
 (0)