Skip to content
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
6 changes: 3 additions & 3 deletions src/multirust/override_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl OverrideDB {
}

let dir = utils::canonicalize_path(dir_unresolved, ntfy!(&notify_handler));
let mut path = &*dir;
while let Some(parent) = path.parent() {
let mut maybe_path = Some(&*dir);
while let Some(path) = maybe_path {
let key = try!(self.path_to_db_key(path, notify_handler));
if let Some(toolchain) = try!(utils::match_file("override db", &self.0, |line| {
if line.starts_with(&key) {
Expand All @@ -94,7 +94,7 @@ impl OverrideDB {
return Ok(Some((toolchain, path.to_owned())));
}

path = parent;
maybe_path = path.parent();
}

Ok(None)
Expand Down
28 changes: 28 additions & 0 deletions tests/cli-v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,34 @@ fn multiple_overrides() {
});
}

// #316
#[test]
#[cfg(windows)]
fn override_windows_root() {
setup(&|config| {
use std::path::{PathBuf, Component};

let cwd = ::std::env::current_dir().unwrap();
let prefix = cwd.components().next().unwrap();
let prefix = match prefix {
Component::Prefix(p) => p,
_ => panic!()
};

// This value is probably "C:"
// Really sketchy to be messing with C:\ in a test...
let prefix = prefix.as_os_str().to_str().unwrap();
let prefix = format!("{}\\", prefix);
change_dir(&PathBuf::from(&prefix), &|| {
expect_ok(config, &["rustup", "default", "stable"]);
expect_ok(config, &["rustup", "override", "add", "nightly"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-n-2");
expect_ok(config, &["rustup", "override", "remove"]);
expect_stdout_ok(config, &["rustc", "--version"], "hash-s-2");
});
});
}

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