compiletest: rustfmt
This commit is contained in:
parent
b559710e58
commit
2438434054
9 changed files with 249 additions and 234 deletions
|
@ -10,8 +10,8 @@
|
|||
pub use self::Mode::*;
|
||||
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
|
||||
use test::ColorConfig;
|
||||
|
||||
|
@ -103,7 +103,7 @@ pub enum CompareMode {
|
|||
impl CompareMode {
|
||||
pub(crate) fn to_str(&self) -> &'static str {
|
||||
match *self {
|
||||
CompareMode::Nll => "nll"
|
||||
CompareMode::Nll => "nll",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,16 +253,21 @@ pub struct TestPaths {
|
|||
}
|
||||
|
||||
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
|
||||
pub fn expected_output_path(testpaths: &TestPaths,
|
||||
revision: Option<&str>,
|
||||
compare_mode: &Option<CompareMode>,
|
||||
kind: &str) -> PathBuf {
|
||||
|
||||
pub fn expected_output_path(
|
||||
testpaths: &TestPaths,
|
||||
revision: Option<&str>,
|
||||
compare_mode: &Option<CompareMode>,
|
||||
kind: &str,
|
||||
) -> PathBuf {
|
||||
assert!(UI_EXTENSIONS.contains(&kind));
|
||||
let mut parts = Vec::new();
|
||||
|
||||
if let Some(x) = revision { parts.push(x); }
|
||||
if let Some(ref x) = *compare_mode { parts.push(x.to_str()); }
|
||||
if let Some(x) = revision {
|
||||
parts.push(x);
|
||||
}
|
||||
if let Some(ref x) = *compare_mode {
|
||||
parts.push(x.to_str());
|
||||
}
|
||||
parts.push(kind);
|
||||
|
||||
let extension = parts.join(".");
|
||||
|
|
|
@ -11,8 +11,8 @@ use self::WhichLine::*;
|
|||
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
@ -35,8 +35,7 @@ impl FromStr for ErrorKind {
|
|||
"ERROR" => Ok(ErrorKind::Error),
|
||||
"NOTE" => Ok(ErrorKind::Note),
|
||||
"SUGGESTION" => Ok(ErrorKind::Suggestion),
|
||||
"WARN" |
|
||||
"WARNING" => Ok(ErrorKind::Warning),
|
||||
"WARN" | "WARNING" => Ok(ErrorKind::Warning),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -101,23 +100,25 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
|
|||
rdr.lines()
|
||||
.enumerate()
|
||||
.filter_map(|(line_num, line)| {
|
||||
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), &tag)
|
||||
.map(|(which, error)| {
|
||||
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), &tag).map(
|
||||
|(which, error)| {
|
||||
match which {
|
||||
FollowPrevious(_) => {}
|
||||
_ => last_nonfollow_error = Some(error.line_num),
|
||||
}
|
||||
error
|
||||
})
|
||||
},
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse_expected(last_nonfollow_error: Option<usize>,
|
||||
line_num: usize,
|
||||
line: &str,
|
||||
tag: &str)
|
||||
-> Option<(WhichLine, Error)> {
|
||||
fn parse_expected(
|
||||
last_nonfollow_error: Option<usize>,
|
||||
line_num: usize,
|
||||
line: &str,
|
||||
tag: &str,
|
||||
) -> Option<(WhichLine, Error)> {
|
||||
let start = match line.find(tag) {
|
||||
Some(i) => i,
|
||||
None => return None,
|
||||
|
@ -125,7 +126,13 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
|||
let (follow, adjusts) = if line[start + tag.len()..].chars().next().unwrap() == '|' {
|
||||
(true, 0)
|
||||
} else {
|
||||
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
|
||||
(
|
||||
false,
|
||||
line[start + tag.len()..]
|
||||
.chars()
|
||||
.take_while(|c| *c == '^')
|
||||
.count(),
|
||||
)
|
||||
};
|
||||
let kind_start = start + tag.len() + adjusts + (follow as usize);
|
||||
let (kind, msg);
|
||||
|
@ -133,12 +140,14 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
|||
.split_whitespace()
|
||||
.next()
|
||||
.expect("Encountered unexpected empty comment")
|
||||
.parse::<ErrorKind>() {
|
||||
.parse::<ErrorKind>()
|
||||
{
|
||||
Ok(k) => {
|
||||
// If we find `//~ ERROR foo` or something like that:
|
||||
kind = Some(k);
|
||||
let letters = line[kind_start..].chars();
|
||||
msg = letters.skip_while(|c| c.is_whitespace())
|
||||
msg = letters
|
||||
.skip_while(|c| c.is_whitespace())
|
||||
.skip_while(|c| !c.is_whitespace())
|
||||
.collect::<String>();
|
||||
}
|
||||
|
@ -146,7 +155,8 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
|||
// Otherwise we found `//~ foo`:
|
||||
kind = None;
|
||||
let letters = line[kind_start..].chars();
|
||||
msg = letters.skip_while(|c| c.is_whitespace())
|
||||
msg = letters
|
||||
.skip_while(|c| c.is_whitespace())
|
||||
.collect::<String>();
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +164,10 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
|||
|
||||
let (which, line_num) = if follow {
|
||||
assert_eq!(adjusts, 0, "use either //~| or //~^, not both.");
|
||||
let line_num = last_nonfollow_error.expect("encountered //~| without \
|
||||
preceding //~^ line.");
|
||||
let line_num = last_nonfollow_error.expect(
|
||||
"encountered //~| without \
|
||||
preceding //~^ line.",
|
||||
);
|
||||
(FollowPrevious(line_num), line_num)
|
||||
} else {
|
||||
let which = if adjusts > 0 {
|
||||
|
@ -167,16 +179,16 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
|||
(which, line_num)
|
||||
};
|
||||
|
||||
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
|
||||
line_num,
|
||||
tag,
|
||||
which,
|
||||
kind,
|
||||
msg);
|
||||
Some((which,
|
||||
Error {
|
||||
line_num,
|
||||
kind,
|
||||
msg,
|
||||
}))
|
||||
debug!(
|
||||
"line={} tag={:?} which={:?} kind={:?} msg={:?}",
|
||||
line_num, tag, which, kind, msg
|
||||
);
|
||||
Some((
|
||||
which,
|
||||
Error {
|
||||
line_num,
|
||||
kind,
|
||||
msg,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use common::Config;
|
||||
use common;
|
||||
use common::Config;
|
||||
use util;
|
||||
|
||||
use extract_gdb_version;
|
||||
|
@ -38,19 +38,14 @@ impl EarlyProps {
|
|||
revisions: vec![],
|
||||
};
|
||||
|
||||
iter_header(testfile,
|
||||
None,
|
||||
&mut |ln| {
|
||||
iter_header(testfile, None, &mut |ln| {
|
||||
// we should check if any only-<platform> exists and if it exists
|
||||
// and does not matches the current platform, skip the test
|
||||
props.ignore =
|
||||
props.ignore ||
|
||||
config.parse_cfg_name_directive(ln, "ignore") ||
|
||||
(config.has_cfg_prefix(ln, "only") &&
|
||||
!config.parse_cfg_name_directive(ln, "only")) ||
|
||||
ignore_gdb(config, ln) ||
|
||||
ignore_lldb(config, ln) ||
|
||||
ignore_llvm(config, ln);
|
||||
props.ignore = props.ignore || config.parse_cfg_name_directive(ln, "ignore")
|
||||
|| (config.has_cfg_prefix(ln, "only")
|
||||
&& !config.parse_cfg_name_directive(ln, "only"))
|
||||
|| ignore_gdb(config, ln) || ignore_lldb(config, ln)
|
||||
|| ignore_llvm(config, ln);
|
||||
|
||||
if let Some(s) = config.parse_aux_build(ln) {
|
||||
props.aux.push(s);
|
||||
|
@ -149,7 +144,7 @@ impl EarlyProps {
|
|||
|
||||
fn ignore_llvm(config: &Config, line: &str) -> bool {
|
||||
if config.system_llvm && line.starts_with("no-system-llvm") {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
if let Some(ref actual_version) = config.llvm_version {
|
||||
if line.starts_with("min-llvm-version") {
|
||||
|
@ -272,11 +267,7 @@ impl TestProps {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn from_aux_file(&self,
|
||||
testfile: &Path,
|
||||
cfg: Option<&str>,
|
||||
config: &Config)
|
||||
-> Self {
|
||||
pub fn from_aux_file(&self, testfile: &Path, cfg: Option<&str>, config: &Config) -> Self {
|
||||
let mut props = TestProps::new();
|
||||
|
||||
// copy over select properties to the aux build:
|
||||
|
@ -296,20 +287,15 @@ impl TestProps {
|
|||
/// tied to a particular revision `foo` (indicated by writing
|
||||
/// `//[foo]`), then the property is ignored unless `cfg` is
|
||||
/// `Some("foo")`.
|
||||
fn load_from(&mut self,
|
||||
testfile: &Path,
|
||||
cfg: Option<&str>,
|
||||
config: &Config) {
|
||||
iter_header(testfile,
|
||||
cfg,
|
||||
&mut |ln| {
|
||||
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
||||
iter_header(testfile, cfg, &mut |ln| {
|
||||
if let Some(ep) = config.parse_error_pattern(ln) {
|
||||
self.error_patterns.push(ep);
|
||||
}
|
||||
|
||||
if let Some(flags) = config.parse_compile_flags(ln) {
|
||||
self.compile_flags.extend(flags.split_whitespace()
|
||||
.map(|s| s.to_owned()));
|
||||
self.compile_flags
|
||||
.extend(flags.split_whitespace().map(|s| s.to_owned()));
|
||||
}
|
||||
|
||||
if let Some(r) = config.parse_revisions(ln) {
|
||||
|
@ -382,8 +368,7 @@ impl TestProps {
|
|||
|
||||
if !self.compile_pass {
|
||||
// run-pass implies must_compile_sucessfully
|
||||
self.compile_pass =
|
||||
config.parse_compile_pass(ln) || self.run_pass;
|
||||
self.compile_pass = config.parse_compile_pass(ln) || self.run_pass;
|
||||
}
|
||||
|
||||
if !self.skip_trans {
|
||||
|
@ -453,7 +438,7 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
|
|||
None => false,
|
||||
};
|
||||
if matches {
|
||||
it(ln[(close_brace + 1) ..].trim_left());
|
||||
it(ln[(close_brace + 1)..].trim_left());
|
||||
}
|
||||
} else {
|
||||
panic!("malformed condition directive: expected `{}foo]`, found `{}`",
|
||||
|
@ -554,9 +539,7 @@ impl Config {
|
|||
fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
|
||||
self.parse_name_value_directive(line, name).map(|nv| {
|
||||
// nv is either FOO or FOO=BAR
|
||||
let mut strs: Vec<String> = nv.splitn(2, '=')
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
let mut strs: Vec<String> = nv.splitn(2, '=').map(str::to_owned).collect();
|
||||
|
||||
match strs.len() {
|
||||
1 => (strs.pop().unwrap(), "".to_owned()),
|
||||
|
@ -599,7 +582,10 @@ impl Config {
|
|||
/// or `normalize-stderr-32bit`. Returns `true` if the line matches it.
|
||||
fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> bool {
|
||||
if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') {
|
||||
let name = line[prefix.len()+1 ..].split(&[':', ' '][..]).next().unwrap();
|
||||
let name = line[prefix.len() + 1..]
|
||||
.split(&[':', ' '][..])
|
||||
.next()
|
||||
.unwrap();
|
||||
|
||||
name == "test" ||
|
||||
util::matches_os(&self.target, name) || // target
|
||||
|
@ -612,8 +598,7 @@ impl Config {
|
|||
common::DebugInfoLldb => name == "lldb",
|
||||
common::Pretty => name == "pretty",
|
||||
_ => false,
|
||||
} ||
|
||||
(self.target != self.host && name == "cross-compile")
|
||||
} || (self.target != self.host && name == "cross-compile")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -631,14 +616,14 @@ impl Config {
|
|||
// the line says "ignore-x86_64".
|
||||
line.starts_with(directive) && match line.as_bytes().get(directive.len()) {
|
||||
None | Some(&b' ') | Some(&b':') => true,
|
||||
_ => false
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_name_value_directive(&self, line: &str, directive: &str) -> Option<String> {
|
||||
let colon = directive.len();
|
||||
if line.starts_with(directive) && line.as_bytes().get(colon) == Some(&b':') {
|
||||
let value = line[(colon + 1) ..].to_owned();
|
||||
let value = line[(colon + 1)..].to_owned();
|
||||
debug!("{}: {}", directive, value);
|
||||
Some(expand_variables(value, self))
|
||||
} else {
|
||||
|
@ -665,8 +650,10 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn lldb_version_to_int(version_string: &str) -> isize {
|
||||
let error_string = format!("Encountered LLDB version string with unexpected format: {}",
|
||||
version_string);
|
||||
let error_string = format!(
|
||||
"Encountered LLDB version string with unexpected format: {}",
|
||||
version_string
|
||||
);
|
||||
version_string.parse().expect(&error_string)
|
||||
}
|
||||
|
||||
|
@ -713,6 +700,6 @@ fn parse_normalization_string(line: &mut &str) -> Option<String> {
|
|||
None => return None,
|
||||
};
|
||||
let result = line[begin..end].to_owned();
|
||||
*line = &line[end+1..];
|
||||
*line = &line[end + 1..];
|
||||
Some(result)
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
use errors::{Error, ErrorKind};
|
||||
use serde_json;
|
||||
use std::str::FromStr;
|
||||
use std::path::Path;
|
||||
use runtest::ProcRes;
|
||||
use serde_json;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
|
||||
// These structs are a subset of the ones found in
|
||||
// `syntax::json`.
|
||||
|
@ -58,26 +58,30 @@ struct DiagnosticCode {
|
|||
}
|
||||
|
||||
pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
|
||||
output.lines()
|
||||
.filter_map(|line| if line.starts_with('{') {
|
||||
match serde_json::from_str::<Diagnostic>(line) {
|
||||
Ok(diagnostic) => diagnostic.rendered,
|
||||
Err(error) => {
|
||||
proc_res.fatal(Some(&format!("failed to decode compiler output as json: \
|
||||
`{}`\noutput: {}\nline: {}",
|
||||
error,
|
||||
line,
|
||||
output)));
|
||||
output
|
||||
.lines()
|
||||
.filter_map(|line| {
|
||||
if line.starts_with('{') {
|
||||
match serde_json::from_str::<Diagnostic>(line) {
|
||||
Ok(diagnostic) => diagnostic.rendered,
|
||||
Err(error) => {
|
||||
proc_res.fatal(Some(&format!(
|
||||
"failed to decode compiler output as json: \
|
||||
`{}`\noutput: {}\nline: {}",
|
||||
error, line, output
|
||||
)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
|
||||
output.lines()
|
||||
output
|
||||
.lines()
|
||||
.flat_map(|line| parse_line(file_name, line, output, proc_res))
|
||||
.collect()
|
||||
}
|
||||
|
@ -93,11 +97,11 @@ fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) ->
|
|||
expected_errors
|
||||
}
|
||||
Err(error) => {
|
||||
proc_res.fatal(Some(&format!("failed to decode compiler output as json: \
|
||||
`{}`\noutput: {}\nline: {}",
|
||||
error,
|
||||
line,
|
||||
output)));
|
||||
proc_res.fatal(Some(&format!(
|
||||
"failed to decode compiler output as json: \
|
||||
`{}`\noutput: {}\nline: {}",
|
||||
error, line, output
|
||||
)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -105,11 +109,14 @@ fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) ->
|
|||
}
|
||||
}
|
||||
|
||||
fn push_expected_errors(expected_errors: &mut Vec<Error>,
|
||||
diagnostic: &Diagnostic,
|
||||
default_spans: &[&DiagnosticSpan],
|
||||
file_name: &str) {
|
||||
let spans_in_this_file: Vec<_> = diagnostic.spans
|
||||
fn push_expected_errors(
|
||||
expected_errors: &mut Vec<Error>,
|
||||
diagnostic: &Diagnostic,
|
||||
default_spans: &[&DiagnosticSpan],
|
||||
file_name: &str,
|
||||
) {
|
||||
let spans_in_this_file: Vec<_> = diagnostic
|
||||
.spans
|
||||
.iter()
|
||||
.filter(|span| Path::new(&span.file_name) == Path::new(&file_name))
|
||||
.collect();
|
||||
|
@ -204,8 +211,10 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
|
|||
}
|
||||
|
||||
// Add notes for any labels that appear in the message.
|
||||
for span in spans_in_this_file.iter()
|
||||
.filter(|span| span.label.is_some()) {
|
||||
for span in spans_in_this_file
|
||||
.iter()
|
||||
.filter(|span| span.label.is_some())
|
||||
{
|
||||
expected_errors.push(Error {
|
||||
line_num: span.line_start,
|
||||
kind: Some(ErrorKind::Note),
|
||||
|
@ -219,9 +228,11 @@ fn push_expected_errors(expected_errors: &mut Vec<Error>,
|
|||
}
|
||||
}
|
||||
|
||||
fn push_backtrace(expected_errors: &mut Vec<Error>,
|
||||
expansion: &DiagnosticSpanMacroExpansion,
|
||||
file_name: &str) {
|
||||
fn push_backtrace(
|
||||
expected_errors: &mut Vec<Error>,
|
||||
expansion: &DiagnosticSpanMacroExpansion,
|
||||
file_name: &str,
|
||||
) {
|
||||
if Path::new(&expansion.span.file_name) == Path::new(&file_name) {
|
||||
expected_errors.push(Error {
|
||||
line_num: expansion.span.line_start,
|
||||
|
|
|
@ -31,31 +31,31 @@ extern crate serde_json;
|
|||
extern crate test;
|
||||
extern crate rustfix;
|
||||
|
||||
use common::CompareMode;
|
||||
use common::{expected_output_path, UI_EXTENSIONS};
|
||||
use common::{Config, TestPaths};
|
||||
use common::{DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
|
||||
use filetime::FileTime;
|
||||
use getopts::Options;
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use filetime::FileTime;
|
||||
use getopts::Options;
|
||||
use common::{Config, TestPaths};
|
||||
use common::{DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
|
||||
use common::{expected_output_path, UI_EXTENSIONS};
|
||||
use common::CompareMode;
|
||||
use test::ColorConfig;
|
||||
use util::logv;
|
||||
|
||||
use self::header::EarlyProps;
|
||||
|
||||
pub mod util;
|
||||
mod json;
|
||||
pub mod header;
|
||||
pub mod runtest;
|
||||
pub mod common;
|
||||
pub mod errors;
|
||||
pub mod header;
|
||||
mod json;
|
||||
mod raise_fd_limit;
|
||||
mod read2;
|
||||
pub mod runtest;
|
||||
pub mod util;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
|
@ -236,7 +236,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
"",
|
||||
"compare-mode",
|
||||
"mode describing what file the actual ui output will be compared to",
|
||||
"COMPARE MODE"
|
||||
"COMPARE MODE",
|
||||
)
|
||||
.optflag("h", "help", "show this message");
|
||||
|
||||
|
@ -501,7 +501,11 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
|
|||
filter: config.filter.clone(),
|
||||
filter_exact: config.filter_exact,
|
||||
run_ignored: config.run_ignored,
|
||||
format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty },
|
||||
format: if config.quiet {
|
||||
test::OutputFormat::Terse
|
||||
} else {
|
||||
test::OutputFormat::Pretty
|
||||
},
|
||||
logfile: config.logfile.clone(),
|
||||
run_tests: true,
|
||||
bench_benchmarks: true,
|
||||
|
@ -634,8 +638,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn
|
|||
};
|
||||
|
||||
// Debugging emscripten code doesn't make sense today
|
||||
let ignore = early_props.ignore
|
||||
|| !up_to_date(config, testpaths, &early_props)
|
||||
let ignore = early_props.ignore || !up_to_date(config, testpaths, &early_props)
|
||||
|| (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb)
|
||||
&& config.target.contains("emscripten");
|
||||
|
||||
|
@ -694,8 +697,7 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo
|
|||
for pretty_printer_file in &pretty_printer_files {
|
||||
inputs.push(mtime(&rust_src_dir.join(pretty_printer_file)));
|
||||
}
|
||||
let mut entries = config.run_lib_path.read_dir().unwrap()
|
||||
.collect::<Vec<_>>();
|
||||
let mut entries = config.run_lib_path.read_dir().unwrap().collect::<Vec<_>>();
|
||||
while let Some(entry) = entries.pop() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
|
@ -713,10 +715,8 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo
|
|||
// UI test files.
|
||||
for extension in UI_EXTENSIONS {
|
||||
for revision in &props.revisions {
|
||||
let path = &expected_output_path(testpaths,
|
||||
Some(revision),
|
||||
&config.compare_mode,
|
||||
extension);
|
||||
let path =
|
||||
&expected_output_path(testpaths, Some(revision), &config.compare_mode, extension);
|
||||
inputs.push(mtime(path));
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,12 @@ pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName
|
|||
Some(ref mode) => format!(" ({})", mode.to_str()),
|
||||
None => format!(""),
|
||||
};
|
||||
test::DynTestName(format!("[{}{}] {}", config.mode, mode_suffix, path.display()))
|
||||
test::DynTestName(format!(
|
||||
"[{}{}] {}",
|
||||
config.mode,
|
||||
mode_suffix,
|
||||
path.display()
|
||||
))
|
||||
}
|
||||
|
||||
pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn {
|
||||
|
|
|
@ -34,12 +34,15 @@ pub unsafe fn raise_fd_limit() {
|
|||
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
|
||||
let mut maxfiles: libc::c_int = 0;
|
||||
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
|
||||
if libc::sysctl(&mut mib[0],
|
||||
2,
|
||||
&mut maxfiles as *mut _ as *mut _,
|
||||
&mut size,
|
||||
null_mut(),
|
||||
0) != 0 {
|
||||
if libc::sysctl(
|
||||
&mut mib[0],
|
||||
2,
|
||||
&mut maxfiles as *mut _ as *mut _,
|
||||
&mut size,
|
||||
null_mut(),
|
||||
0,
|
||||
) != 0
|
||||
{
|
||||
let err = io::Error::last_os_error();
|
||||
panic!("raise_fd_limit: error calling sysctl: {}", err);
|
||||
}
|
||||
|
|
|
@ -16,11 +16,13 @@ pub use self::imp::read2;
|
|||
#[cfg(not(any(unix, windows)))]
|
||||
mod imp {
|
||||
use std::io::{self, Read};
|
||||
use std::process::{ChildStdout, ChildStderr};
|
||||
use std::process::{ChildStderr, ChildStdout};
|
||||
|
||||
pub fn read2(out_pipe: ChildStdout,
|
||||
err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool)) -> io::Result<()> {
|
||||
pub fn read2(
|
||||
out_pipe: ChildStdout,
|
||||
err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool),
|
||||
) -> io::Result<()> {
|
||||
let mut buffer = Vec::new();
|
||||
out_pipe.read_to_end(&mut buffer)?;
|
||||
data(true, &mut buffer, true);
|
||||
|
@ -33,16 +35,18 @@ mod imp {
|
|||
|
||||
#[cfg(unix)]
|
||||
mod imp {
|
||||
use std::io::prelude::*;
|
||||
use libc;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::mem;
|
||||
use std::os::unix::prelude::*;
|
||||
use std::process::{ChildStdout, ChildStderr};
|
||||
use libc;
|
||||
use std::process::{ChildStderr, ChildStdout};
|
||||
|
||||
pub fn read2(mut out_pipe: ChildStdout,
|
||||
mut err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool)) -> io::Result<()> {
|
||||
pub fn read2(
|
||||
mut out_pipe: ChildStdout,
|
||||
mut err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool),
|
||||
) -> io::Result<()> {
|
||||
unsafe {
|
||||
libc::fcntl(out_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
|
||||
libc::fcntl(err_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
|
||||
|
@ -67,9 +71,9 @@ mod imp {
|
|||
if r == -1 {
|
||||
let err = io::Error::last_os_error();
|
||||
if err.kind() == io::ErrorKind::Interrupted {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
return Err(err)
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
// Read as much as we can from each pipe, ignoring EWOULDBLOCK or
|
||||
|
@ -77,15 +81,13 @@ mod imp {
|
|||
// reader will return Ok(0), in which case we'll see `Ok` ourselves. In
|
||||
// this case we flip the other fd back into blocking mode and read
|
||||
// whatever's leftover on that file descriptor.
|
||||
let handle = |res: io::Result<_>| {
|
||||
match res {
|
||||
Ok(_) => Ok(true),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
Ok(false)
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
let handle = |res: io::Result<_>| match res {
|
||||
Ok(_) => Ok(true),
|
||||
Err(e) => {
|
||||
if e.kind() == io::ErrorKind::WouldBlock {
|
||||
Ok(false)
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -113,7 +115,7 @@ mod imp {
|
|||
|
||||
use std::io;
|
||||
use std::os::windows::prelude::*;
|
||||
use std::process::{ChildStdout, ChildStderr};
|
||||
use std::process::{ChildStderr, ChildStdout};
|
||||
use std::slice;
|
||||
|
||||
use self::miow::iocp::{CompletionPort, CompletionStatus};
|
||||
|
@ -128,9 +130,11 @@ mod imp {
|
|||
done: bool,
|
||||
}
|
||||
|
||||
pub fn read2(out_pipe: ChildStdout,
|
||||
err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool)) -> io::Result<()> {
|
||||
pub fn read2(
|
||||
out_pipe: ChildStdout,
|
||||
err_pipe: ChildStderr,
|
||||
data: &mut FnMut(bool, &mut Vec<u8>, bool),
|
||||
) -> io::Result<()> {
|
||||
let mut out = Vec::new();
|
||||
let mut err = Vec::new();
|
||||
|
||||
|
@ -206,7 +210,9 @@ mod imp {
|
|||
if v.capacity() == v.len() {
|
||||
v.reserve(1);
|
||||
}
|
||||
slice::from_raw_parts_mut(v.as_mut_ptr().offset(v.len() as isize),
|
||||
v.capacity() - v.len())
|
||||
slice::from_raw_parts_mut(
|
||||
v.as_mut_ptr().offset(v.len() as isize),
|
||||
v.capacity() - v.len(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,28 +8,28 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use common::{Config, TestPaths};
|
||||
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
|
||||
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
|
||||
use common::{Incremental, MirOpt, RunMake, Ui};
|
||||
use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
|
||||
use common::CompareMode;
|
||||
use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
|
||||
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
|
||||
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
|
||||
use common::{Config, TestPaths};
|
||||
use common::{Incremental, MirOpt, RunMake, Ui};
|
||||
use diff;
|
||||
use errors::{self, Error, ErrorKind};
|
||||
use filetime::FileTime;
|
||||
use json;
|
||||
use header::TestProps;
|
||||
use util::logv;
|
||||
use json;
|
||||
use regex::Regex;
|
||||
use rustfix::{apply_suggestions, get_suggestions_from_json};
|
||||
use util::logv;
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
use std::env;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::{self, create_dir_all, File};
|
||||
use std::fmt;
|
||||
use std::fs::{self, create_dir_all, File};
|
||||
use std::io::prelude::*;
|
||||
use std::io::{self, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -355,9 +355,10 @@ impl<'test> TestCx<'test> {
|
|||
|
||||
if expected_status != received_status {
|
||||
self.fatal_proc_rec(
|
||||
&format!("Error: expected failure status ({:?}) but received status {:?}.",
|
||||
expected_status,
|
||||
received_status),
|
||||
&format!(
|
||||
"Error: expected failure status ({:?}) but received status {:?}.",
|
||||
expected_status, received_status
|
||||
),
|
||||
proc_res,
|
||||
);
|
||||
}
|
||||
|
@ -440,8 +441,7 @@ impl<'test> TestCx<'test> {
|
|||
self.config,
|
||||
format!(
|
||||
"pretty-printing round {} revision {:?}",
|
||||
round,
|
||||
self.revision
|
||||
round, self.revision
|
||||
),
|
||||
);
|
||||
let proc_res = self.print_source(srcs[round].to_owned(), &self.props.pretty_mode);
|
||||
|
@ -450,8 +450,7 @@ impl<'test> TestCx<'test> {
|
|||
self.fatal_proc_rec(
|
||||
&format!(
|
||||
"pretty-printing failed in round {} revision {:?}",
|
||||
round,
|
||||
self.revision
|
||||
round, self.revision
|
||||
),
|
||||
&proc_res,
|
||||
);
|
||||
|
@ -555,8 +554,7 @@ impl<'test> TestCx<'test> {
|
|||
{}\n\
|
||||
------------------------------------------\n\
|
||||
\n",
|
||||
expected,
|
||||
actual
|
||||
expected, actual
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -661,8 +659,7 @@ impl<'test> TestCx<'test> {
|
|||
script_str.push_str(&format!(
|
||||
"set solib-search-path \
|
||||
./{}/stage2/lib/rustlib/{}/lib/\n",
|
||||
self.config.host,
|
||||
self.config.target
|
||||
self.config.host, self.config.target
|
||||
));
|
||||
for line in &breakpoint_lines {
|
||||
script_str.push_str(
|
||||
|
@ -881,7 +878,6 @@ impl<'test> TestCx<'test> {
|
|||
..self.config.clone()
|
||||
};
|
||||
|
||||
|
||||
let test_cx = TestCx {
|
||||
config: &config,
|
||||
..*self
|
||||
|
@ -952,8 +948,7 @@ impl<'test> TestCx<'test> {
|
|||
for line in &breakpoint_lines {
|
||||
script_str.push_str(&format!(
|
||||
"breakpoint set --file '{}' --line {}\n",
|
||||
source_file_name,
|
||||
line
|
||||
source_file_name, line
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1028,9 +1023,7 @@ impl<'test> TestCx<'test> {
|
|||
fn parse_debugger_commands(&self, debugger_prefixes: &[&str]) -> DebuggerCommands {
|
||||
let directives = debugger_prefixes
|
||||
.iter()
|
||||
.map(|prefix| {
|
||||
(format!("{}-command", prefix), format!("{}-check", prefix))
|
||||
})
|
||||
.map(|prefix| (format!("{}-command", prefix), format!("{}-check", prefix)))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut breakpoint_lines = vec![];
|
||||
|
@ -1041,12 +1034,11 @@ impl<'test> TestCx<'test> {
|
|||
for line in reader.lines() {
|
||||
match line {
|
||||
Ok(line) => {
|
||||
let line =
|
||||
if line.starts_with("//") {
|
||||
line[2..].trim_left()
|
||||
} else {
|
||||
line.as_str()
|
||||
};
|
||||
let line = if line.starts_with("//") {
|
||||
line[2..].trim_left()
|
||||
} else {
|
||||
line.as_str()
|
||||
};
|
||||
|
||||
if line.contains("#break") {
|
||||
breakpoint_lines.push(counter);
|
||||
|
@ -1645,7 +1637,10 @@ impl<'test> TestCx<'test> {
|
|||
let mut rustc = if !is_rustdoc {
|
||||
Command::new(&self.config.rustc_path)
|
||||
} else {
|
||||
Command::new(&self.config.rustdoc_path.clone().expect("no rustdoc built yet"))
|
||||
Command::new(&self.config
|
||||
.rustdoc_path
|
||||
.clone()
|
||||
.expect("no rustdoc built yet"))
|
||||
};
|
||||
rustc.arg(input_file).arg("-L").arg(&self.config.build_base);
|
||||
|
||||
|
@ -1671,10 +1666,7 @@ impl<'test> TestCx<'test> {
|
|||
|
||||
if !is_rustdoc {
|
||||
if let Some(ref incremental_dir) = self.props.incremental_dir {
|
||||
rustc.args(&[
|
||||
"-C",
|
||||
&format!("incremental={}", incremental_dir.display()),
|
||||
]);
|
||||
rustc.args(&["-C", &format!("incremental={}", incremental_dir.display())]);
|
||||
rustc.args(&["-Z", "incremental-verify-ich"]);
|
||||
rustc.args(&["-Z", "incremental-queries"]);
|
||||
}
|
||||
|
@ -1697,7 +1689,11 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
}
|
||||
Ui => {
|
||||
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
|
||||
if !self.props
|
||||
.compile_flags
|
||||
.iter()
|
||||
.any(|s| s.starts_with("--error-format"))
|
||||
{
|
||||
rustc.args(&["--error-format", "json"]);
|
||||
}
|
||||
if !self.props.disable_ui_testing_normalization {
|
||||
|
@ -1720,16 +1716,8 @@ impl<'test> TestCx<'test> {
|
|||
|
||||
rustc.arg(dir_opt);
|
||||
}
|
||||
RunPass |
|
||||
RunFail |
|
||||
RunPassValgrind |
|
||||
Pretty |
|
||||
DebugInfoGdb |
|
||||
DebugInfoLldb |
|
||||
Codegen |
|
||||
Rustdoc |
|
||||
RunMake |
|
||||
CodegenUnits => {
|
||||
RunPass | RunFail | RunPassValgrind | Pretty | DebugInfoGdb | DebugInfoLldb
|
||||
| Codegen | Rustdoc | RunMake | CodegenUnits => {
|
||||
// do not use JSON output
|
||||
}
|
||||
}
|
||||
|
@ -1759,8 +1747,8 @@ impl<'test> TestCx<'test> {
|
|||
match self.config.compare_mode {
|
||||
Some(CompareMode::Nll) => {
|
||||
rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]);
|
||||
},
|
||||
None => {},
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
if self.props.force_host {
|
||||
|
@ -1923,7 +1911,8 @@ impl<'test> TestCx<'test> {
|
|||
/// Same as `output_base_name`, but includes the stage ID as an extension,
|
||||
/// such as: `.../compile-fail/foo/bar.stage1-<triple>`
|
||||
fn output_base_name_stage(&self) -> PathBuf {
|
||||
self.output_base_name().with_extension(&self.config.stage_id)
|
||||
self.output_base_name()
|
||||
.with_extension(&self.config.stage_id)
|
||||
}
|
||||
|
||||
fn maybe_dump_to_stdout(&self, out: &str, err: &str) {
|
||||
|
@ -2417,8 +2406,7 @@ impl<'test> TestCx<'test> {
|
|||
if self.config.verbose {
|
||||
print!(
|
||||
"revision={:?} revision_props={:#?}",
|
||||
revision,
|
||||
revision_props
|
||||
revision, revision_props
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2731,8 +2719,7 @@ impl<'test> TestCx<'test> {
|
|||
if source_time > output_time {
|
||||
debug!(
|
||||
"source file time: {:?} output file time: {:?}",
|
||||
source_time,
|
||||
output_time
|
||||
source_time, output_time
|
||||
);
|
||||
panic!(
|
||||
"test source file `{}` is newer than potentially stale output file `{}`.",
|
||||
|
@ -2906,10 +2893,12 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
|
||||
fn expected_output_path(&self, kind: &str) -> PathBuf {
|
||||
let mut path = expected_output_path(&self.testpaths,
|
||||
self.revision,
|
||||
&self.config.compare_mode,
|
||||
kind);
|
||||
let mut path = expected_output_path(
|
||||
&self.testpaths,
|
||||
self.revision,
|
||||
&self.config.compare_mode,
|
||||
kind,
|
||||
);
|
||||
if !path.exists() && self.config.compare_mode.is_some() {
|
||||
// fallback!
|
||||
path = expected_output_path(&self.testpaths, self.revision, &None, kind);
|
||||
|
@ -2959,14 +2948,14 @@ impl<'test> TestCx<'test> {
|
|||
DiffLine::Expected(e) => {
|
||||
println!("-\t{}", e);
|
||||
line_number += 1;
|
||||
},
|
||||
}
|
||||
DiffLine::Context(c) => {
|
||||
println!("{}\t{}", line_number, c);
|
||||
line_number += 1;
|
||||
},
|
||||
}
|
||||
DiffLine::Resulting(r) => {
|
||||
println!("+\t{}", r);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("");
|
||||
|
@ -3025,10 +3014,7 @@ impl ProcRes {
|
|||
{}\n\
|
||||
------------------------------------------\n\
|
||||
\n",
|
||||
self.status,
|
||||
self.cmdline,
|
||||
self.stdout,
|
||||
self.stderr
|
||||
self.status, self.cmdline, self.stdout, self.stderr
|
||||
);
|
||||
panic!();
|
||||
}
|
||||
|
@ -3072,8 +3058,8 @@ fn nocomment_mir_line(line: &str) -> &str {
|
|||
}
|
||||
|
||||
fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
|
||||
use std::mem::replace;
|
||||
use read2::read2;
|
||||
use std::mem::replace;
|
||||
|
||||
const HEAD_LEN: usize = 160 * 1024;
|
||||
const TAIL_LEN: usize = 256 * 1024;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::env;
|
||||
use common::Config;
|
||||
use std::env;
|
||||
|
||||
/// Conversion table from triple OS name to Rust SYSNAME
|
||||
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
|
||||
|
@ -73,7 +73,7 @@ pub fn matches_os(triple: &str, name: &str) -> bool {
|
|||
// For the wasm32 bare target we ignore anything also ignored on emscripten
|
||||
// and then we also recognize `wasm32-bare` as the os for the target
|
||||
if triple == "wasm32-unknown-unknown" {
|
||||
return name == "emscripten" || name == "wasm32-bare"
|
||||
return name == "emscripten" || name == "wasm32-bare";
|
||||
}
|
||||
let triple: Vec<_> = triple.split('-').collect();
|
||||
for &(triple_os, os) in OS_TABLE {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue