use std::collections::HashSet;
use std::env;
use std::fmt;
-use std::fs::{self, File};
+use std::fs::{self, File, create_dir_all};
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::path::{Path, PathBuf};
let out_dir = self.output_base_name().with_extension("pretty-out");
let _ = fs::remove_dir_all(&out_dir);
- self.create_dir_racy(&out_dir);
+ create_dir_all(&out_dir).unwrap();
// FIXME (#9639): This needs to handle non-utf8 paths
let mut args = vec!["-".to_owned(),
fn compose_and_run_compiler(&self, args: ProcArgs, input: Option<String>) -> ProcRes {
if !self.props.aux_builds.is_empty() {
- self.create_dir_racy(&self.aux_output_dir_name());
+ create_dir_all(&self.aux_output_dir_name()).unwrap();
}
let aux_dir = self.aux_output_dir_name();
input)
}
- // Like std::fs::create_dir_all, except handles concurrent calls among multiple
- // threads or processes.
- fn create_dir_racy(&self, path: &Path) {
- match fs::create_dir(path) {
- Ok(()) => return,
- Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return,
- Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
- Err(e) => panic!("failed to create dir {:?}: {}", path, e),
- }
- self.create_dir_racy(path.parent().unwrap());
- match fs::create_dir(path) {
- Ok(()) => {}
- Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => {}
- Err(e) => panic!("failed to create dir {:?}: {}", path, e),
- }
- }
fn compose_and_run(&self,
ProcArgs{ args, prog }: ProcArgs,
let mir_dump_dir = self.get_mir_dump_dir();
- self.create_dir_racy(mir_dump_dir.as_path());
+ create_dir_all(mir_dump_dir.as_path()).unwrap();
let mut dir_opt = "dump-mir-dir=".to_string();
dir_opt.push_str(mir_dump_dir.to_str().unwrap());
debug!("dir_opt: {:?}", dir_opt);
}
fn dump_output(&self, out: &str, err: &str) {
- self.dump_output_file(out, "out");
- self.dump_output_file(err, "err");
+ let revision = if let Some(r) = self.revision {
+ format!("{}.", r)
+ } else {
+ String::new()
+ };
+
+ self.dump_output_file(out, &format!("{}out", revision));
+ self.dump_output_file(err, &format!("{}err", revision));
self.maybe_dump_to_stdout(out, err);
}
let out_dir = self.output_base_name();
let _ = fs::remove_dir_all(&out_dir);
- self.create_dir_racy(&out_dir);
+ create_dir_all(&out_dir).unwrap();
let proc_res = self.document(&out_dir);
if !proc_res.status.success() {
fn check_rustdoc_test_option(&self, res: ProcRes) {
let mut other_files = Vec::new();
let mut files: HashMap<String, Vec<usize>> = HashMap::new();
- files.insert(self.testpaths.file.to_str().unwrap().to_owned(),
+ let cwd = env::current_dir().unwrap();
+ files.insert(self.testpaths.file.strip_prefix(&cwd)
+ .unwrap_or(&self.testpaths.file)
+ .to_str()
+ .unwrap()
+ .replace('\\', "/"),
self.get_lines(&self.testpaths.file, Some(&mut other_files)));
for other_file in other_files {
let mut path = self.testpaths.file.clone();
path.set_file_name(&format!("{}.rs", other_file));
- files.insert(path.to_str().unwrap().to_owned(), self.get_lines(&path, None));
+ files.insert(path.strip_prefix(&cwd)
+ .unwrap_or(&path)
+ .to_str()
+ .unwrap()
+ .replace('\\', "/"),
+ self.get_lines(&path, None));
}
let mut tested = 0;
let tmp: Vec<&str> = s.split(" - ").collect();
if tmp.len() == 2 {
let path = tmp[0].rsplit("test ").next().unwrap();
- if let Some(ref mut v) = files.get_mut(path) {
+ if let Some(ref mut v) = files.get_mut(
+ &path.replace('\\', "/")) {
tested += 1;
let mut iter = tmp[1].split("(line ");
iter.next();
if tmpdir.exists() {
self.aggressive_rm_rf(&tmpdir).unwrap();
}
- self.create_dir_racy(&tmpdir);
+ create_dir_all(&tmpdir).unwrap();
let host = &self.config.host;
let make = if host.contains("bitrig") || host.contains("dragonfly") ||