diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-11-04 17:44:53 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-11-05 10:51:04 -0700 |
| commit | 11251e59b9133f2d226c7bbc8a59a80b53edb0a7 (patch) | |
| tree | b4a46951a90158d2f4628e6a81954ab672f2d06b /src/bootstrap | |
| parent | e126f3c6c699d7ca58a1be94bb9af4292a83436d (diff) | |
| download | rust-11251e59b9133f2d226c7bbc8a59a80b53edb0a7.tar.gz rust-11251e59b9133f2d226c7bbc8a59a80b53edb0a7.zip | |
Fix tests from the rollup
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/clean.rs | 42 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 24 | ||||
| -rw-r--r-- | src/bootstrap/step.rs | 4 |
3 files changed, 64 insertions, 6 deletions
diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs index 3d338cf4f94..d8b840297b8 100644 --- a/src/bootstrap/clean.rs +++ b/src/bootstrap/clean.rs @@ -16,6 +16,7 @@ //! directory as we want that cached between builds. use std::fs; +use std::io::{self, ErrorKind}; use std::path::Path; use Build; @@ -35,14 +36,47 @@ pub fn clean(build: &Build) { if entry.file_name().to_str() == Some("llvm") { continue } - t!(fs::remove_dir_all(&entry.path())); + rm_rf(build, &entry.path()); } } } fn rm_rf(build: &Build, path: &Path) { - if path.exists() { - build.verbose(&format!("removing `{}`", path.display())); - t!(fs::remove_dir_all(path)); + if !path.exists() { + return + } + + for file in t!(fs::read_dir(path)) { + let file = t!(file).path(); + + if file.is_dir() { + rm_rf(build, &file); + } else { + // On windows we can't remove a readonly file, and git will + // often clone files as readonly. As a result, we have some + // special logic to remove readonly files on windows. + do_op(&file, "remove file", |p| fs::remove_file(p)); + } + } + do_op(path, "remove dir", |p| fs::remove_dir(p)); +} + +fn do_op<F>(path: &Path, desc: &str, mut f: F) + where F: FnMut(&Path) -> io::Result<()> +{ + match f(path) { + Ok(()) => {} + Err(ref e) if cfg!(windows) && + e.kind() == ErrorKind::PermissionDenied => { + let mut p = t!(path.metadata()).permissions(); + p.set_readonly(false); + t!(fs::set_permissions(path, p)); + f(path).unwrap_or_else(|e| { + panic!("failed to {} {}: {}", desc, path.display(), e); + }) + } + Err(e) => { + panic!("failed to {} {}: {}", desc, path.display(), e); + } } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index abaa9389d80..1cadb634dfc 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -454,6 +454,30 @@ impl Config { } } +#[cfg(not(windows))] +fn parse_configure_path(path: &str) -> PathBuf { + path.into() +} + +#[cfg(windows)] +fn parse_configure_path(path: &str) -> PathBuf { + // on windows, configure produces unix style paths e.g. /c/some/path but we + // only want real windows paths + + use std::process::Command; + use build_helper; + + // '/' is invalid in windows paths, so we can detect unix paths by the presence of it + if !path.contains('/') { + return path.into(); + } + + let win_path = build_helper::output(Command::new("cygpath").arg("-w").arg(path)); + let win_path = win_path.trim(); + + win_path.into() +} + fn set<T>(field: &mut T, val: Option<T>) { if let Some(v) = val { *field = v; diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs index 4a7cfa1cc6a..ef6f9c52639 100644 --- a/src/bootstrap/step.rs +++ b/src/bootstrap/step.rs @@ -288,13 +288,13 @@ pub fn build_rules(build: &Build) -> Rules { None)); for (krate, path, _default) in krates("rustc-main") { rules.test(&krate.test_step, path) - .dep(|s| s.name("libtest")) + .dep(|s| s.name("librustc")) .host(true) .run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Librustc, Some(&krate.name))); } rules.test("check-rustc-all", "path/to/nowhere") - .dep(|s| s.name("libtest")) + .dep(|s| s.name("librustc")) .default(true) .host(true) .run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Librustc, |
