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

Add --path option to 'rustup override set' #1524

Merged
merged 2 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 13 additions & 2 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::error::Error;
use std::fmt;
use std::io::Write;
use std::iter;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::str::FromStr;

Expand Down Expand Up @@ -351,6 +351,12 @@ pub fn cli() -> App<'static, 'static> {
Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true),
)
.arg(
Arg::with_name("path")
.long("path")
.takes_value(true)
.help("Path to the directory"),
),
)
.subcommand(
Expand Down Expand Up @@ -992,7 +998,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
None
};

toolchain.make_override(&utils::current_dir()?)?;
let path = if let Some(path) = m.value_of("path") {
PathBuf::from(path)
} else {
utils::current_dir()?
};
toolchain.make_override(&path)?;

if let Some(status) = status {
println!();
Expand Down
29 changes: 29 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,35 @@ fn show_toolchain_override_not_installed() {
});
}

#[test]
fn override_set_unset_with_path() {
setup(&|config| {
let workdir = config.current_dir();
let workdir = workdir.to_string_lossy();
config.change_dir(&config.emptydir, &|| {
expect_ok(
config,
&["rustup", "override", "set", "nightly", "--path", &workdir],
);
});
expect_ok_ex(
config,
&["rustup", "override", "list"],
&format!("{}\tnightly-x86_64-unknown-linux-gnu\n", &workdir),
pickfire marked this conversation as resolved.
Show resolved Hide resolved
r"",
);
config.change_dir(&config.emptydir, &|| {
expect_ok(config, &["rustup", "override", "unset", "--path", &workdir]);
});
expect_ok_ex(
config,
&["rustup", "override", "list"],
&"no overrides\n",
r"",
);
});
}

#[test]
fn show_toolchain_env() {
setup(&|config| {
Expand Down