Skip to content

Commit 11251e5

Browse files
committed
Fix tests from the rollup
1 parent e126f3c commit 11251e5

File tree

5 files changed

+67
-8
lines changed

5 files changed

+67
-8
lines changed

src/bootstrap/clean.rs

+38-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! directory as we want that cached between builds.
1717
1818
use std::fs;
19+
use std::io::{self, ErrorKind};
1920
use std::path::Path;
2021

2122
use Build;
@@ -35,14 +36,47 @@ pub fn clean(build: &Build) {
3536
if entry.file_name().to_str() == Some("llvm") {
3637
continue
3738
}
38-
t!(fs::remove_dir_all(&entry.path()));
39+
rm_rf(build, &entry.path());
3940
}
4041
}
4142
}
4243

4344
fn rm_rf(build: &Build, path: &Path) {
44-
if path.exists() {
45-
build.verbose(&format!("removing `{}`", path.display()));
46-
t!(fs::remove_dir_all(path));
45+
if !path.exists() {
46+
return
47+
}
48+
49+
for file in t!(fs::read_dir(path)) {
50+
let file = t!(file).path();
51+
52+
if file.is_dir() {
53+
rm_rf(build, &file);
54+
} else {
55+
// On windows we can't remove a readonly file, and git will
56+
// often clone files as readonly. As a result, we have some
57+
// special logic to remove readonly files on windows.
58+
do_op(&file, "remove file", |p| fs::remove_file(p));
59+
}
60+
}
61+
do_op(path, "remove dir", |p| fs::remove_dir(p));
62+
}
63+
64+
fn do_op<F>(path: &Path, desc: &str, mut f: F)
65+
where F: FnMut(&Path) -> io::Result<()>
66+
{
67+
match f(path) {
68+
Ok(()) => {}
69+
Err(ref e) if cfg!(windows) &&
70+
e.kind() == ErrorKind::PermissionDenied => {
71+
let mut p = t!(path.metadata()).permissions();
72+
p.set_readonly(false);
73+
t!(fs::set_permissions(path, p));
74+
f(path).unwrap_or_else(|e| {
75+
panic!("failed to {} {}: {}", desc, path.display(), e);
76+
})
77+
}
78+
Err(e) => {
79+
panic!("failed to {} {}: {}", desc, path.display(), e);
80+
}
4781
}
4882
}

src/bootstrap/config.rs

+24
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,30 @@ impl Config {
454454
}
455455
}
456456

457+
#[cfg(not(windows))]
458+
fn parse_configure_path(path: &str) -> PathBuf {
459+
path.into()
460+
}
461+
462+
#[cfg(windows)]
463+
fn parse_configure_path(path: &str) -> PathBuf {
464+
// on windows, configure produces unix style paths e.g. /c/some/path but we
465+
// only want real windows paths
466+
467+
use std::process::Command;
468+
use build_helper;
469+
470+
// '/' is invalid in windows paths, so we can detect unix paths by the presence of it
471+
if !path.contains('/') {
472+
return path.into();
473+
}
474+
475+
let win_path = build_helper::output(Command::new("cygpath").arg("-w").arg(path));
476+
let win_path = win_path.trim();
477+
478+
win_path.into()
479+
}
480+
457481
fn set<T>(field: &mut T, val: Option<T>) {
458482
if let Some(v) = val {
459483
*field = v;

src/bootstrap/step.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,13 @@ pub fn build_rules(build: &Build) -> Rules {
288288
None));
289289
for (krate, path, _default) in krates("rustc-main") {
290290
rules.test(&krate.test_step, path)
291-
.dep(|s| s.name("libtest"))
291+
.dep(|s| s.name("librustc"))
292292
.host(true)
293293
.run(move |s| check::krate(build, &s.compiler(), s.target,
294294
Mode::Librustc, Some(&krate.name)));
295295
}
296296
rules.test("check-rustc-all", "path/to/nowhere")
297-
.dep(|s| s.name("libtest"))
297+
.dep(|s| s.name("librustc"))
298298
.default(true)
299299
.host(true)
300300
.run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Librustc,

src/libsyntax/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat
722722
("windows_subsystem", Whitelisted, Gated(Stability::Unstable,
723723
"windows_subsystem",
724724
"the windows subsystem attribute \
725-
id currently unstable",
725+
is currently unstable",
726726
cfg_fn!(windows_subsystem))),
727727

728728
// Crate level attributes

src/test/compile-fail/windows-subsystem-invalid.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// error-pattern: invalid windows subsystem `wrong`, only `windows` and `console` are allowed
12+
1113
#![feature(windows_subsystem)]
1214
#![windows_subsystem = "wrong"]
13-
//~^ ERROR: invalid subsystem `wrong`, only `windows` and `console` are allowed
1415

1516
fn main() {}

0 commit comments

Comments
 (0)