check_stdout: false,
no_prefer_dynamic: false,
pretty_expanded: false,
- pretty_mode: format!("normal"),
+ pretty_mode: "normal".to_string(),
pretty_compare_only: false,
forbid_output: vec![],
incremental_dir: None,
}
});
- for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
- match env::var(key) {
- Ok(val) => {
- if self.exec_env.iter().find(|&&(ref x, _)| *x == key).is_none() {
- self.exec_env.push((key.to_owned(), val))
- }
+ for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
+ if let Ok(val) = env::var(key) {
+ if self.exec_env.iter().find(|&&(ref x, _)| x == key).is_none() {
+ self.exec_env.push(((*key).to_owned(), val))
}
- Err(..) => {}
}
}
}
return;
} else if ln.starts_with("//[") {
// A comment like `//[foo]` is specific to revision `foo`
- if let Some(close_brace) = ln.find("]") {
+ if let Some(close_brace) = ln.find(']') {
let lncfg = &ln[3..close_brace];
let matches = match cfg {
Some(s) => s == &lncfg[..],
fn parse_pp_exact(&self, line: &str, testfile: &Path) -> Option<PathBuf> {
if let Some(s) = self.parse_name_value_directive(line, "pp-exact") {
Some(PathBuf::from(&s))
+ } else if self.parse_name_directive(line, "pp-exact") {
+ testfile.file_name().map(PathBuf::from)
} else {
- if self.parse_name_directive(line, "pp-exact") {
- testfile.file_name().map(PathBuf::from)
- } else {
- None
- }
+ None
}
}
let error_string = format!("Encountered LLDB version string with unexpected format: {}",
version_string);
let error_string = error_string;
- let major: isize = version_string.parse().ok().expect(&error_string);
- return major;
+ let major: isize = version_string.parse().expect(&error_string);
+ major
}
fn expand_variables(mut value: String, config: &Config) -> String {
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
stage_id: matches.opt_str("stage-id").unwrap(),
- mode: matches.opt_str("mode").unwrap().parse().ok().expect("invalid mode"),
+ mode: matches.opt_str("mode").unwrap().parse().expect("invalid mode"),
run_ignored: matches.opt_present("ignored"),
filter: matches.free.first().cloned(),
filter_exact: matches.opt_present("exact"),
pub fn log_config(config: &Config) {
let c = config;
- logv(c, format!("configuration:"));
+ logv(c, "configuration:".to_string());
logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
config.adb_device_status));
logv(c, format!("verbose: {}", config.verbose));
logv(c, format!("quiet: {}", config.quiet));
- logv(c, format!("\n"));
+ logv(c, "\n".to_string());
}
-pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
+pub fn opt_str(maybestr: &Option<String>) -> &str {
match *maybestr {
None => "(none)",
Some(ref s) => s,
};
// Debugging emscripten code doesn't make sense today
- let mut ignore = early_props.ignore || !up_to_date(config, testpaths, &early_props);
- if (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) &&
- config.target.contains("emscripten") {
- ignore = true;
- }
+ let ignore = early_props.ignore || !up_to_date(config, testpaths, &early_props) ||
+ (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) &&
+ config.target.contains("emscripten");
test::TestDescAndFn {
desc: test::TestDesc {
.to_str().unwrap(),
config.stage_id);
config.build_base.canonicalize()
- .unwrap_or(config.build_base.clone())
+ .unwrap_or_else(|_| config.build_base.clone())
.join(stamp_name)
}
fn mtime(path: &Path) -> FileTime {
fs::metadata(path).map(|f| {
FileTime::from_last_modification_time(&f)
- }).unwrap_or(FileTime::zero())
+ }).unwrap_or_else(|_| FileTime::zero())
}
pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName {
let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST);
- return (Some(gdb.to_owned()), version, gdb_native_rust);
+ (Some(gdb.to_owned()), version, gdb_native_rust)
}
fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
Some(idx) => if line.as_bytes()[idx] == b'.' {
let patch = &line[idx + 1..];
- let patch_len = patch.find(|c: char| !c.is_digit(10)).unwrap_or(patch.len());
+ let patch_len = patch.find(|c: char| !c.is_digit(10)).unwrap_or_else(|| patch.len());
let patch = &patch[..patch_len];
let patch = if patch_len > 3 || patch_len == 0 { None } else { Some(patch) };
} else {
for revision in &base_props.revisions {
let mut revision_props = base_props.clone();
- revision_props.load_from(&testpaths.file, Some(&revision), &config);
+ revision_props.load_from(&testpaths.file, Some(revision), &config);
let rev_cx = TestCx {
config: &config,
props: &revision_props,
base_cx.complete_all();
- File::create(::stamp(&config, &testpaths)).unwrap();
+ File::create(::stamp(&config, testpaths)).unwrap();
}
struct TestCx<'test> {
/// invoked once before any revisions have been processed
fn init_all(&self) {
assert!(self.revision.is_none(), "init_all invoked for a revision");
- match self.config.mode {
- Incremental => self.init_incremental_test(),
- _ => { }
+ if let Incremental = self.config.mode {
+ self.init_incremental_test()
}
}
/// revisions, exactly once, with revision == None).
fn run_revision(&self) {
match self.config.mode {
- CompileFail => self.run_cfail_test(),
+ CompileFail |
ParseFail => self.run_cfail_test(),
RunFail => self.run_rfail_test(),
RunPass => self.run_rpass_test(),
aux_dir.to_str().unwrap().to_owned()];
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
args.extend(self.props.compile_flags.iter().cloned());
- return ProcArgs {
+ ProcArgs {
prog: self.config.rustc_path.to_str().unwrap().to_owned(),
args: args,
- };
+ }
}
fn compare_source(&self,
aux_dir.to_str().unwrap().to_owned()];
if let Some(revision) = self.revision {
args.extend(vec![
- format!("--cfg"),
- format!("{}", revision),
+ "--cfg".to_string(),
+ revision.to_string(),
]);
}
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
args.extend(self.props.compile_flags.iter().cloned());
// FIXME (#9639): This needs to handle non-utf8 paths
- return ProcArgs {
+ ProcArgs {
prog: self.config.rustc_path.to_str().unwrap().to_owned(),
args: args,
- };
+ }
}
fn run_debuginfo_gdb_test(&self) {
}
}
- return None;
+ None
}
fn run_debuginfo_lldb_test(&self) {
for &(ref command_directive, ref check_directive) in &directives {
self.config.parse_name_value_directive(
&line,
- &command_directive).map(|cmd| {
+ command_directive).map(|cmd| {
commands.push(cmd)
});
self.config.parse_name_value_directive(
&line,
- &check_directive).map(|cmd| {
+ check_directive).map(|cmd| {
check_lines.push(cmd)
});
}
(line, 0)
};
- for fragment_index in first_fragment .. check_fragments.len() {
- let current_fragment = check_fragments[fragment_index];
+ for current_fragment in &check_fragments[first_fragment..] {
match rest.find(current_fragment) {
Some(pos) => {
rest = &rest[pos + current_fragment.len() .. ];
return false;
}
- return true;
+ true
}
}
let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note));
// Parse the JSON output from the compiler and extract out the messages.
- let actual_errors = json::parse_output(&file_name, &proc_res.stderr, &proc_res);
+ let actual_errors = json::parse_output(&file_name, &proc_res.stderr, proc_res);
let mut unexpected = Vec::new();
let mut found = vec![false; expected_errors.len()];
for actual_error in &actual_errors {
.map_or(String::from("message"),
|k| k.to_string()),
actual_error.msg));
- unexpected.push(actual_error.clone());
+ unexpected.push(actual_error);
}
}
}
.map_or("message".into(),
|k| k.to_string()),
expected_error.msg));
- not_found.push(expected_error.clone());
+ not_found.push(expected_error);
}
}
- if unexpected.len() > 0 || not_found.len() > 0 {
+ if !unexpected.is_empty() || !not_found.is_empty() {
self.error(
&format!("{} unexpected errors found, {} expected errors not found",
unexpected.len(), not_found.len()));
- print!("status: {}\ncommand: {}\n",
+ println!("status: {}\ncommand: {}",
proc_res.status, proc_res.cmdline);
- if unexpected.len() > 0 {
+ if !unexpected.is_empty() {
println!("unexpected errors (from JSON output): {:#?}\n", unexpected);
}
- if not_found.len() > 0 {
+ if !not_found.is_empty() {
println!("not found errors (from test file): {:#?}\n", not_found);
}
panic!();
match actual_error.kind {
Some(ErrorKind::Help) => expect_help,
Some(ErrorKind::Note) => expect_note,
- Some(ErrorKind::Error) => true,
+ Some(ErrorKind::Error) |
Some(ErrorKind::Warning) => true,
- Some(ErrorKind::Suggestion) => false,
+ Some(ErrorKind::Suggestion) |
None => false
}
}
self.config);
let mut crate_type = if aux_props.no_prefer_dynamic {
Vec::new()
- } else {
+ } else if (self.config.target.contains("musl") && !aux_props.force_host) ||
+ self.config.target.contains("emscripten") {
// We primarily compile all auxiliary libraries as dynamic libraries
// to avoid code size bloat and large binaries as much as possible
// for the test suite (otherwise including libstd statically in all
// dynamic libraries so we just go back to building a normal library. Note,
// however, that for MUSL if the library is built with `force_host` then
// it's ok to be a dylib as the host should always support dylibs.
- if (self.config.target.contains("musl") && !aux_props.force_host) ||
- self.config.target.contains("emscripten")
- {
- vec!["--crate-type=lib".to_owned()]
- } else {
- vec!["--crate-type=dylib".to_owned()]
- }
+ vec!["--crate-type=lib".to_owned()]
+ } else {
+ vec!["--crate-type=dylib".to_owned()]
};
crate_type.extend(extra_link_args.clone());
let aux_output = {
lib_path: &str,
aux_path: Option<&str>,
input: Option<String>) -> ProcRes {
- return self.program_output(lib_path, prog, aux_path, args, procenv, input);
+ self.program_output(lib_path, prog, aux_path, args, procenv, input)
}
fn make_compile_args(&self,
// Optionally prevent default --target if specified in test compile-flags.
let custom_target = self.props.compile_flags
.iter()
- .fold(false, |acc, ref x| acc || x.starts_with("--target"));
+ .fold(false, |acc, x| acc || x.starts_with("--target"));
if !custom_target {
args.extend(vec![
if let Some(revision) = self.revision {
args.extend(vec![
- format!("--cfg"),
- format!("{}", revision),
+ "--cfg".to_string(),
+ revision.to_string(),
]);
}
if let Some(ref incremental_dir) = self.props.incremental_dir {
args.extend(vec![
- format!("-Z"),
+ "-Z".to_string(),
format!("incremental={}", incremental_dir.display()),
]);
}
args.extend(self.split_maybe_args(&self.config.target_rustcflags));
}
args.extend(self.props.compile_flags.iter().cloned());
- return ProcArgs {
+ ProcArgs {
prog: self.config.rustc_path.to_str().unwrap().to_owned(),
args: args,
- };
+ }
}
fn make_lib_name(&self, auxfile: &Path) -> PathBuf {
args.extend(self.split_maybe_args(&self.props.run_flags));
let prog = args.remove(0);
- return ProcArgs {
+ ProcArgs {
prog: prog,
args: args,
- };
+ }
}
fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> {
env,
input).expect(&format!("failed to exec `{}`", prog));
self.dump_output(&out, &err);
- return ProcRes {
+ ProcRes {
status: status,
stdout: out,
stderr: err,
cmdline: cmdline,
- };
+ }
}
fn make_cmdline(&self, libpath: &str, prog: &str, args: &[String]) -> String {
self.fatal_proc_rec("rustdoc failed!", &proc_res);
}
- if self.props.check_test_line_numbers_match == true {
+ if self.props.check_test_line_numbers_match {
self.check_rustdoc_test_option(proc_res);
} else {
let root = self.find_rust_src_root().unwrap();
.filter_map(|(line_nb, line)| {
if (line.trim_left().starts_with("pub mod ") ||
line.trim_left().starts_with("mod ")) &&
- line.ends_with(";") {
+ line.ends_with(';') {
if let Some(ref mut other_files) = other_files {
other_files.push(line.rsplit("mod ")
.next()
}
let mut tested = 0;
- for _ in res.stdout.split("\n")
+ for _ in res.stdout.split('\n')
.filter(|s| s.starts_with("test "))
.inspect(|s| {
let tmp: Vec<&str> = s.split(" - ").collect();
iter.next();
let line = iter.next()
.unwrap_or(")")
- .split(")")
+ .split(')')
.next()
.unwrap_or("0")
.parse()
self.fatal_proc_rec(&format!("No test has been found... {:?}", files), &res);
} else {
for (entry, v) in &files {
- if v.len() != 0 {
+ if !v.is_empty() {
self.fatal_proc_rec(&format!("Not found test at line{} \"{}\":{:?}",
if v.len() > 1 { "s" } else { "" }, entry, v),
&res);
.find(|ti| ti.name == expected_item.name);
if let Some(actual_item) = actual_item_with_same_name {
- if !expected_item.codegen_units.is_empty() {
- // Also check for codegen units
- if expected_item.codegen_units != actual_item.codegen_units {
- wrong_cgus.push((expected_item.clone(), actual_item.clone()));
- }
+ if !expected_item.codegen_units.is_empty() &&
+ // Also check for codegen units
+ expected_item.codegen_units != actual_item.codegen_units {
+ wrong_cgus.push((expected_item.clone(), actual_item.clone()));
}
} else {
missing.push(expected_item.string.clone());
let cgus = if parts.len() > 1 {
let cgus_str = parts[1];
- cgus_str.split(" ")
+ cgus_str.split(' ')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_owned)
}
}
- fn compare_mir_test_output(&self, test_name: &str, expected_content: &Vec<&str>) {
+ fn compare_mir_test_output(&self, test_name: &str, expected_content: &[&str]) {
let mut output_file = PathBuf::new();
output_file.push(self.get_mir_dump_dir());
output_file.push(test_name);