Skip to content

Commit

Permalink
Auto merge of #317 - brson:winoverride, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix overrides for C:\. Fixes #316
  • Loading branch information
bors committed Apr 15, 2016
2 parents 26bcb72 + c20fc10 commit 1c15b56
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
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

0 comments on commit 1c15b56

Please sign in to comment.