Skip to content

Commit

Permalink
Fix tests from the rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 5, 2016
1 parent e126f3c commit 11251e5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 8 deletions.
42 changes: 38 additions & 4 deletions src/bootstrap/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
24 changes: 24 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/test/compile-fail/windows-subsystem-invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 11251e5

Please sign in to comment.