Skip to content

Commit

Permalink
Add workaround for multirust directory in testing
Browse files Browse the repository at this point in the history
The home directory is a dummy one during the tests but the .multirust
directory in the real home remains in $PATH. Instead of filtering
$HOME/.multirust, it is necessary to filter any $PATH entry containing
.multirust as a component.
  • Loading branch information
meqif committed Aug 31, 2016
1 parent 35f7470 commit 3897c2a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use rustup_utils::utils;
use sha2::{Sha256, Digest};
use std::env;
use std::env::consts::EXE_SUFFIX;
use std::path::{Path, PathBuf};
use std::path::{Path, PathBuf, Component};
use std::process::{self, Command};
use std::fs::{self, File};
use std::io::Read;
Expand Down Expand Up @@ -298,9 +298,9 @@ fn rustc_or_cargo_exists_in_path() -> bool {
if let Some(paths) = env::var_os("PATH") {
// Ignore rustc and cargo if present in $HOME/.cargo/bin and $HOME/.multirust/,
// those are expected
let multirust_meta_path = env::home_dir().map(|path| path.join(".multirust")).unwrap();
let paths = env::split_paths(&paths)
.filter(|path| !path.ends_with(".cargo/bin") && !path.starts_with(&multirust_meta_path));
.filter(|path| !path.ends_with(".cargo/bin") &&
!path.components().any(|c| c == Component::Normal(".multirust".as_ref())));

for path in paths {
let rustc = path.join("rustc");
Expand Down

0 comments on commit 3897c2a

Please sign in to comment.