X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcompiletest%2Fcompiletest.rs;h=dfd99a9beae96cc5ac80615ea61c181f0dd79057;hb=c3db627cbf354ba02311fb0c523e365e8d017b00;hp=36c676391019bd1ad44a078aede726784cf786ee;hpb=0469be1eb70404a57dcc558aa8f53ab529aede47;p=rust.git diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 36c67639101..dfd99a9beae 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -13,12 +13,11 @@ #![feature(box_syntax)] #![feature(dynamic_lib)] #![feature(libc)] -#![feature(path_ext)] #![feature(rustc_private)] -#![feature(slice_splits)] #![feature(str_char)] #![feature(test)] #![feature(vec_push_all)] +#![feature(path_components_peek)] #![deny(warnings)] @@ -91,7 +90,7 @@ pub fn parse_config(args: Vec ) -> Config { optflag("h", "help", "show this message")); let (argv0, args_) = args.split_first().unwrap(); - if args[1] == "-h" || args[1] == "--help" { + if args.len() == 1 || args[1] == "-h" || args[1] == "--help" { let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0); println!("{}", getopts::usage(&message, &groups)); println!(""); @@ -177,7 +176,7 @@ pub fn log_config(config: &Config) { logv(c, format!("filter: {}", opt_str(&config.filter .as_ref() - .map(|re| re.to_string())))); + .map(|re| re.to_owned())))); logv(c, format!("runtool: {}", opt_str(&config.runtool))); logv(c, format!("host-rustcflags: {}", opt_str(&config.host_rustcflags))); @@ -204,19 +203,16 @@ pub fn opt_str<'a>(maybestr: &'a Option) -> &'a str { pub fn opt_str2(maybestr: Option) -> String { match maybestr { - None => "(none)".to_string(), + None => "(none)".to_owned(), Some(s) => s, } } pub fn run_tests(config: &Config) { if config.target.contains("android") { - match config.mode { - DebugInfoGdb => { - println!("{} debug-info test uses tcp 5039 port.\ - please reserve it", config.target); - } - _ =>{} + if let DebugInfoGdb = config.mode { + println!("{} debug-info test uses tcp 5039 port.\ + please reserve it", config.target); } // android debug-info test uses remote debugger @@ -288,10 +284,10 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool { // Pretty-printer does not work with .rc files yet let valid_extensions = match config.mode { - Pretty => vec!(".rs".to_string()), - _ => vec!(".rc".to_string(), ".rs".to_string()) + Pretty => vec!(".rs".to_owned()), + _ => vec!(".rc".to_owned(), ".rs".to_owned()) }; - let invalid_prefixes = vec!(".".to_string(), "#".to_string(), "~".to_string()); + let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned()); let name = testfile.file_name().unwrap().to_str().unwrap(); let mut valid = false; @@ -350,7 +346,7 @@ fn extract_gdb_version(full_version_line: Option) -> Option { if !full_version_line.trim().is_empty() => { let full_version_line = full_version_line.trim(); - // used to be a regex "(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)" + // used to be a regex "(^|[^0-9])([0-9]\.[0-9]+)" for (pos, c) in full_version_line.char_indices() { if !c.is_digit(10) { continue } if pos + 2 >= full_version_line.len() { continue } @@ -359,11 +355,12 @@ fn extract_gdb_version(full_version_line: Option) -> Option { if pos > 0 && full_version_line.char_at_reverse(pos).is_digit(10) { continue } - if pos + 3 < full_version_line.len() && - full_version_line.char_at(pos + 3).is_digit(10) { - continue + let mut end = pos + 3; + while end < full_version_line.len() && + full_version_line.char_at(end).is_digit(10) { + end += 1; } - return Some(full_version_line[pos..pos+3].to_string()); + return Some(full_version_line[pos..end].to_owned()); } println!("Could not extract GDB version from line '{}'", full_version_line); @@ -385,9 +382,8 @@ fn extract_lldb_version(full_version_line: Option) -> Option { // We are only interested in the major version number, so this function // will return `Some("179")` and `Some("300")` respectively. - match full_version_line { - Some(ref full_version_line) - if !full_version_line.trim().is_empty() => { + if let Some(ref full_version_line) = full_version_line { + if !full_version_line.trim().is_empty() { let full_version_line = full_version_line.trim(); for (pos, l) in full_version_line.char_indices() { @@ -409,8 +405,7 @@ fn extract_lldb_version(full_version_line: Option) -> Option { } println!("Could not extract LLDB version from line '{}'", full_version_line); - None - }, - _ => None + } } + None }