Skip to content

Commit 658b524

Browse files
authored
Merge pull request #47 from mcarton/master
Rustup to *rustc 1.13.0-nightly (4f9812a59 2016-09-21)*
2 parents 8bcc045 + b81c456 commit 658b524

File tree

10 files changed

+493
-318
lines changed

10 files changed

+493
-318
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "compiletest_rs"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
authors = [ "The Rust Project Developers"
55
, "Thomas Bracht Laumann Jespersen <[email protected]>"
66
, "Manish Goregaokar <[email protected]>"

src/common.rs

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,53 @@ pub enum Mode {
2929
Incremental,
3030
RunMake,
3131
Ui,
32+
MirOpt,
3233
}
3334

3435
impl FromStr for Mode {
3536
type Err = ();
3637
fn from_str(s: &str) -> Result<Mode, ()> {
3738
match s {
38-
"compile-fail" => Ok(CompileFail),
39-
"parse-fail" => Ok(ParseFail),
40-
"run-fail" => Ok(RunFail),
41-
"run-pass" => Ok(RunPass),
42-
"run-pass-valgrind" => Ok(RunPassValgrind),
43-
"pretty" => Ok(Pretty),
44-
"debuginfo-lldb" => Ok(DebugInfoLldb),
45-
"debuginfo-gdb" => Ok(DebugInfoGdb),
46-
"codegen" => Ok(Codegen),
47-
"rustdoc" => Ok(Rustdoc),
48-
"codegen-units" => Ok(CodegenUnits),
49-
"incremental" => Ok(Incremental),
50-
"run-make" => Ok(RunMake),
51-
"ui" => Ok(Ui),
52-
_ => Err(()),
39+
"compile-fail" => Ok(CompileFail),
40+
"parse-fail" => Ok(ParseFail),
41+
"run-fail" => Ok(RunFail),
42+
"run-pass" => Ok(RunPass),
43+
"run-pass-valgrind" => Ok(RunPassValgrind),
44+
"pretty" => Ok(Pretty),
45+
"debuginfo-lldb" => Ok(DebugInfoLldb),
46+
"debuginfo-gdb" => Ok(DebugInfoGdb),
47+
"codegen" => Ok(Codegen),
48+
"rustdoc" => Ok(Rustdoc),
49+
"codegen-units" => Ok(CodegenUnits),
50+
"incremental" => Ok(Incremental),
51+
"run-make" => Ok(RunMake),
52+
"ui" => Ok(Ui),
53+
"mir-opt" => Ok(MirOpt),
54+
_ => Err(()),
5355
}
5456
}
5557
}
5658

5759
impl fmt::Display for Mode {
5860
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5961
fmt::Display::fmt(match *self {
60-
CompileFail => "compile-fail",
61-
ParseFail => "parse-fail",
62-
RunFail => "run-fail",
63-
RunPass => "run-pass",
64-
RunPassValgrind => "run-pass-valgrind",
65-
Pretty => "pretty",
66-
DebugInfoGdb => "debuginfo-gdb",
67-
DebugInfoLldb => "debuginfo-lldb",
68-
Codegen => "codegen",
69-
Rustdoc => "rustdoc",
70-
CodegenUnits => "codegen-units",
71-
Incremental => "incremental",
72-
RunMake => "run-make",
73-
Ui => "ui",
74-
}, f)
62+
CompileFail => "compile-fail",
63+
ParseFail => "parse-fail",
64+
RunFail => "run-fail",
65+
RunPass => "run-pass",
66+
RunPassValgrind => "run-pass-valgrind",
67+
Pretty => "pretty",
68+
DebugInfoGdb => "debuginfo-gdb",
69+
DebugInfoLldb => "debuginfo-lldb",
70+
Codegen => "codegen",
71+
Rustdoc => "rustdoc",
72+
CodegenUnits => "codegen-units",
73+
Incremental => "incremental",
74+
RunMake => "run-make",
75+
Ui => "ui",
76+
MirOpt => "mir-opt",
77+
},
78+
f)
7579
}
7680
}
7781

@@ -148,6 +152,9 @@ pub struct Config {
148152
// Version of LLDB
149153
pub lldb_version: Option<String>,
150154

155+
// Version of LLVM
156+
pub llvm_version: Option<String>,
157+
151158
// Path to the android tools
152159
pub android_cross_path: PathBuf,
153160

src/compiletest.rs

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ extern crate rustc_serialize;
2323
extern crate log;
2424

2525
use std::env;
26+
use std::ffi::OsString;
2627
use std::fs;
2728
use std::io;
2829
use std::path::{Path, PathBuf};
@@ -68,6 +69,7 @@ pub fn default_config() -> Config {
6869
host: "(none)".to_owned(),
6970
gdb_version: None,
7071
lldb_version: None,
72+
llvm_version: None,
7173
android_cross_path: PathBuf::from("android-cross-path"),
7274
adb_path: "adb-path".to_owned(),
7375
adb_test_dir: "adb-test-dir/target".to_owned(),
@@ -85,9 +87,9 @@ pub fn default_config() -> Config {
8587

8688
pub fn run_tests(config: &Config) {
8789
if config.target.contains("android") {
88-
if config.mode == DebugInfoGdb {
90+
if let DebugInfoGdb = config.mode {
8991
println!("{} debug-info test uses tcp 5039 port.\
90-
please reserve it", config.target);
92+
please reserve it", config.target);
9193
}
9294

9395
// android debug-info test uses remote debugger
@@ -162,18 +164,39 @@ fn collect_tests_from_dir(config: &Config,
162164
// `compiletest-ignore-dir`.
163165
for file in try!(fs::read_dir(dir)) {
164166
let file = try!(file);
165-
if file.file_name() == *"compiletest-ignore-dir" {
167+
let name = file.file_name();
168+
if name == *"compiletest-ignore-dir" {
166169
return Ok(());
167170
}
171+
if name == *"Makefile" && config.mode == Mode::RunMake {
172+
let paths = TestPaths {
173+
file: dir.to_path_buf(),
174+
base: base.to_path_buf(),
175+
relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
176+
};
177+
tests.push(make_test(config, &paths));
178+
return Ok(())
179+
}
168180
}
169181

182+
// If we find a test foo/bar.rs, we have to build the
183+
// output directory `$build/foo` so we can write
184+
// `$build/foo/bar` into it. We do this *now* in this
185+
// sequential loop because otherwise, if we do it in the
186+
// tests themselves, they race for the privilege of
187+
// creating the directories and sometimes fail randomly.
188+
let build_dir = config.build_base.join(&relative_dir_path);
189+
fs::create_dir_all(&build_dir).unwrap();
190+
191+
// Add each `.rs` file as a test, and recurse further on any
192+
// subdirectories we find, except for `aux` directories.
170193
let dirs = try!(fs::read_dir(dir));
171194
for file in dirs {
172195
let file = try!(file);
173196
let file_path = file.path();
174-
debug!("inspecting file {:?}", file_path.display());
175-
if is_test(config, &file_path) {
176-
// If we find a test foo/bar.rs, we have to build the
197+
let file_name = file.file_name();
198+
if is_test(&file_name) {
199+
debug!("found test file: {:?}", file_path.display());
177200
// output directory `$build/foo` so we can write
178201
// `$build/foo/bar` into it. We do this *now* in this
179202
// sequential loop because otherwise, if we do it in the
@@ -190,41 +213,39 @@ fn collect_tests_from_dir(config: &Config,
190213
tests.push(make_test(config, &paths))
191214
} else if file_path.is_dir() {
192215
let relative_file_path = relative_dir_path.join(file.file_name());
193-
try!(collect_tests_from_dir(config,
194-
base,
195-
&file_path,
196-
&relative_file_path,
197-
tests));
216+
if &file_name == "auxiliary" {
217+
// `aux` directories contain other crates used for
218+
// cross-crate tests. Don't search them for tests, but
219+
// do create a directory in the build dir for them,
220+
// since we will dump intermediate output in there
221+
// sometimes.
222+
let build_dir = config.build_base.join(&relative_file_path);
223+
fs::create_dir_all(&build_dir).unwrap();
224+
} else {
225+
debug!("found directory: {:?}", file_path.display());
226+
try!(collect_tests_from_dir(config,
227+
base,
228+
&file_path,
229+
&relative_file_path,
230+
tests));
231+
}
232+
} else {
233+
debug!("found other file/directory: {:?}", file_path.display());
198234
}
199235
}
200236
Ok(())
201237
}
202238

203-
pub fn is_test(config: &Config, testfile: &Path) -> bool {
204-
// Pretty-printer does not work with .rc files yet
205-
let valid_extensions =
206-
match config.mode {
207-
Pretty => vec!(".rs".to_owned()),
208-
_ => vec!(".rc".to_owned(), ".rs".to_owned())
209-
};
210-
let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
211-
let name = testfile.file_name().unwrap().to_str().unwrap();
212-
213-
let mut valid = false;
214-
215-
for ext in &valid_extensions {
216-
if name.ends_with(ext) {
217-
valid = true;
218-
}
219-
}
239+
pub fn is_test(file_name: &OsString) -> bool {
240+
let file_name = file_name.to_str().unwrap();
220241

221-
for pre in &invalid_prefixes {
222-
if name.starts_with(pre) {
223-
valid = false;
224-
}
242+
if !file_name.ends_with(".rs") {
243+
return false;
225244
}
226245

227-
valid
246+
// `.`, `#`, and `~` are common temp-file prefixes.
247+
let invalid_prefixes = &[".", "#", "~"];
248+
!invalid_prefixes.iter().any(|p| file_name.starts_with(p))
228249
}
229250

230251
pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn {
@@ -352,3 +373,8 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
352373
}
353374
None
354375
}
376+
377+
#[allow(dead_code)]
378+
fn is_blacklisted_lldb_version(version: &str) -> bool {
379+
version == "350"
380+
}

src/errors.rs

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ pub struct Error {
6464
}
6565

6666
#[derive(PartialEq, Debug)]
67-
enum WhichLine { ThisLine, FollowPrevious(usize), AdjustBackward(usize) }
67+
enum WhichLine {
68+
ThisLine,
69+
FollowPrevious(usize),
70+
AdjustBackward(usize),
71+
}
6872

6973
/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
7074
/// The former is a "follow" that inherits its target from the preceding line;
@@ -91,60 +95,59 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
9195

9296
let tag = match cfg {
9397
Some(rev) => format!("//[{}]~", rev),
94-
None => format!("//~")
98+
None => format!("//~"),
9599
};
96100

97101
rdr.lines()
98-
.enumerate()
99-
.filter_map(|(line_num, line)| {
100-
parse_expected(last_nonfollow_error,
101-
line_num + 1,
102-
&line.unwrap(),
103-
&tag)
104-
.map(|(which, error)| {
105-
match which {
106-
FollowPrevious(_) => {}
107-
_ => last_nonfollow_error = Some(error.line_num),
108-
}
109-
error
110-
})
111-
})
112-
.collect()
102+
.enumerate()
103+
.filter_map(|(line_num, line)| {
104+
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), &tag)
105+
.map(|(which, error)| {
106+
match which {
107+
FollowPrevious(_) => {}
108+
_ => last_nonfollow_error = Some(error.line_num),
109+
}
110+
error
111+
})
112+
})
113+
.collect()
113114
}
114115

115116
fn parse_expected(last_nonfollow_error: Option<usize>,
116117
line_num: usize,
117118
line: &str,
118119
tag: &str)
119120
-> Option<(WhichLine, Error)> {
120-
let start = match line.find(tag) { Some(i) => i, None => return None };
121+
let start = match line.find(tag) {
122+
Some(i) => i,
123+
None => return None,
124+
};
121125
let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
122126
(true, 0)
123127
} else {
124128
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
125129
};
126130
let kind_start = start + tag.len() + adjusts + (follow as usize);
127131
let (kind, msg);
128-
match
129-
line[kind_start..].split_whitespace()
130-
.next()
131-
.expect("Encountered unexpected empty comment")
132-
.parse::<ErrorKind>()
133-
{
132+
match line[kind_start..]
133+
.split_whitespace()
134+
.next()
135+
.expect("Encountered unexpected empty comment")
136+
.parse::<ErrorKind>() {
134137
Ok(k) => {
135138
// If we find `//~ ERROR foo` or something like that:
136139
kind = Some(k);
137140
let letters = line[kind_start..].chars();
138141
msg = letters.skip_while(|c| c.is_whitespace())
139-
.skip_while(|c| !c.is_whitespace())
140-
.collect::<String>();
142+
.skip_while(|c| !c.is_whitespace())
143+
.collect::<String>();
141144
}
142145
Err(_) => {
143146
// Otherwise we found `//~ foo`:
144147
kind = None;
145148
let letters = line[kind_start..].chars();
146149
msg = letters.skip_while(|c| c.is_whitespace())
147-
.collect::<String>();
150+
.collect::<String>();
148151
}
149152
}
150153
let msg = msg.trim().to_owned();
@@ -155,15 +158,25 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
155158
preceding //~^ line.");
156159
(FollowPrevious(line_num), line_num)
157160
} else {
158-
let which =
159-
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
161+
let which = if adjusts > 0 {
162+
AdjustBackward(adjusts)
163+
} else {
164+
ThisLine
165+
};
160166
let line_num = line_num - adjusts;
161167
(which, line_num)
162168
};
163169

164170
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
165-
line_num, tag, which, kind, msg);
166-
Some((which, Error { line_num: line_num,
167-
kind: kind,
168-
msg: msg, }))
171+
line_num,
172+
tag,
173+
which,
174+
kind,
175+
msg);
176+
Some((which,
177+
Error {
178+
line_num: line_num,
179+
kind: kind,
180+
msg: msg,
181+
}))
169182
}

0 commit comments

Comments
 (0)