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 | |
| parent | e126f3c6c699d7ca58a1be94bb9af4292a83436d (diff) | |
| download | rust-11251e59b9133f2d226c7bbc8a59a80b53edb0a7.tar.gz rust-11251e59b9133f2d226c7bbc8a59a80b53edb0a7.zip | |
Fix tests from the rollup
| -rw-r--r-- | src/bootstrap/clean.rs | 42 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 24 | ||||
| -rw-r--r-- | src/bootstrap/step.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/windows-subsystem-invalid.rs | 3 |
5 files changed, 67 insertions, 8 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, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f29f9ec4e4f..ba162087151 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -722,7 +722,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat ("windows_subsystem", Whitelisted, Gated(Stability::Unstable, "windows_subsystem", "the windows subsystem attribute \ - id currently unstable", + is currently unstable", cfg_fn!(windows_subsystem))), // Crate level attributes diff --git a/src/test/compile-fail/windows-subsystem-invalid.rs b/src/test/compile-fail/windows-subsystem-invalid.rs index 28c3950e76f..e0003440719 100644 --- a/src/test/compile-fail/windows-subsystem-invalid.rs +++ b/src/test/compile-fail/windows-subsystem-invalid.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// error-pattern: invalid windows subsystem `wrong`, only `windows` and `console` are allowed + #![feature(windows_subsystem)] #![windows_subsystem = "wrong"] -//~^ ERROR: invalid subsystem `wrong`, only `windows` and `console` are allowed fn main() {} |
