2014-01-04 14:16:57 -06:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
2012-12-03 18:48:01 -06:00
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-02-15 08:30:09 -06:00
|
|
|
use std::env;
|
2015-02-26 23:00:43 -06:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io::BufReader;
|
|
|
|
use std::io::prelude::*;
|
|
|
|
use std::path::{Path, PathBuf};
|
2015-02-15 08:30:09 -06:00
|
|
|
|
2014-04-15 23:56:39 -05:00
|
|
|
use common::Config;
|
2013-05-24 21:35:29 -05:00
|
|
|
use common;
|
2013-09-03 05:34:23 -05:00
|
|
|
use util;
|
2013-05-24 21:35:29 -05:00
|
|
|
|
2013-01-30 16:10:03 -06:00
|
|
|
pub struct TestProps {
|
2011-08-01 16:10:59 -05:00
|
|
|
// Lines that should be expected, in order, on standard out
|
2014-05-22 18:57:53 -05:00
|
|
|
pub error_patterns: Vec<String> ,
|
2011-08-01 16:10:59 -05:00
|
|
|
// Extra flags to pass to the compiler
|
2014-05-22 18:57:53 -05:00
|
|
|
pub compile_flags: Option<String>,
|
2014-04-19 04:36:00 -05:00
|
|
|
// Extra flags to pass when the compiled code is run (such as --bench)
|
2014-05-22 18:57:53 -05:00
|
|
|
pub run_flags: Option<String>,
|
2011-08-01 16:10:59 -05:00
|
|
|
// If present, the name of a file that this test should match when
|
|
|
|
// pretty-printed
|
2015-02-26 23:00:43 -06:00
|
|
|
pub pp_exact: Option<PathBuf>,
|
2012-02-27 23:23:49 -06:00
|
|
|
// Modules from aux directory that should be compiled
|
2014-05-22 18:57:53 -05:00
|
|
|
pub aux_builds: Vec<String> ,
|
2012-04-13 11:19:07 -05:00
|
|
|
// Environment settings to use during execution
|
2014-05-22 18:57:53 -05:00
|
|
|
pub exec_env: Vec<(String,String)> ,
|
2013-02-09 12:09:19 -06:00
|
|
|
// Lines to check if they appear in the expected debugger output
|
2014-05-22 18:57:53 -05:00
|
|
|
pub check_lines: Vec<String> ,
|
2014-01-17 12:18:02 -06:00
|
|
|
// Flag to force a crate to be built with the host architecture
|
2014-03-28 13:10:15 -05:00
|
|
|
pub force_host: bool,
|
2014-02-12 12:25:09 -06:00
|
|
|
// Check stdout for error-pattern output as well as stderr
|
2014-03-28 13:10:15 -05:00
|
|
|
pub check_stdout: bool,
|
2014-02-10 13:33:33 -06:00
|
|
|
// Don't force a --crate-type=dylib flag on the command line
|
2014-03-28 13:10:15 -05:00
|
|
|
pub no_prefer_dynamic: bool,
|
2015-03-22 15:13:15 -05:00
|
|
|
// Run --pretty expanded when running pretty printing tests
|
|
|
|
pub pretty_expanded: bool,
|
2014-07-22 18:39:10 -05:00
|
|
|
// Which pretty mode are we testing with, default to 'normal'
|
|
|
|
pub pretty_mode: String,
|
|
|
|
// Only compare pretty output and don't try compiling
|
|
|
|
pub pretty_compare_only: bool,
|
2014-09-16 16:47:19 -05:00
|
|
|
// Patterns which must not appear in the output of a cfail test.
|
|
|
|
pub forbid_output: Vec<String>,
|
2013-01-26 00:51:32 -06:00
|
|
|
}
|
2011-07-30 23:11:14 -05:00
|
|
|
|
|
|
|
// Load any test directives embedded in the file
|
2013-01-30 16:10:03 -06:00
|
|
|
pub fn load_props(testfile: &Path) -> TestProps {
|
2014-03-05 17:28:08 -06:00
|
|
|
let mut error_patterns = Vec::new();
|
|
|
|
let mut aux_builds = Vec::new();
|
|
|
|
let mut exec_env = Vec::new();
|
2012-12-28 10:28:36 -06:00
|
|
|
let mut compile_flags = None;
|
2014-04-19 04:36:00 -05:00
|
|
|
let mut run_flags = None;
|
2012-12-28 10:28:36 -06:00
|
|
|
let mut pp_exact = None;
|
2014-03-05 17:28:08 -06:00
|
|
|
let mut check_lines = Vec::new();
|
2014-01-17 12:18:02 -06:00
|
|
|
let mut force_host = false;
|
2014-02-12 12:25:09 -06:00
|
|
|
let mut check_stdout = false;
|
2014-02-10 13:33:33 -06:00
|
|
|
let mut no_prefer_dynamic = false;
|
2015-03-22 15:13:15 -05:00
|
|
|
let mut pretty_expanded = false;
|
2014-07-22 18:39:10 -05:00
|
|
|
let mut pretty_mode = None;
|
|
|
|
let mut pretty_compare_only = false;
|
2014-09-16 16:47:19 -05:00
|
|
|
let mut forbid_output = Vec::new();
|
2015-02-26 23:00:43 -06:00
|
|
|
iter_header(testfile, &mut |ln| {
|
2012-08-06 14:34:08 -05:00
|
|
|
match parse_error_pattern(ln) {
|
2012-12-28 10:28:36 -06:00
|
|
|
Some(ep) => error_patterns.push(ep),
|
|
|
|
None => ()
|
2011-10-21 06:14:28 -05:00
|
|
|
};
|
2011-07-30 23:11:14 -05:00
|
|
|
|
2012-09-21 21:37:57 -05:00
|
|
|
if compile_flags.is_none() {
|
2011-07-30 23:11:14 -05:00
|
|
|
compile_flags = parse_compile_flags(ln);
|
|
|
|
}
|
2011-08-01 16:10:59 -05:00
|
|
|
|
2014-04-19 04:36:00 -05:00
|
|
|
if run_flags.is_none() {
|
|
|
|
run_flags = parse_run_flags(ln);
|
|
|
|
}
|
|
|
|
|
2012-09-21 21:37:57 -05:00
|
|
|
if pp_exact.is_none() {
|
2011-08-01 16:10:59 -05:00
|
|
|
pp_exact = parse_pp_exact(ln, testfile);
|
|
|
|
}
|
2012-02-27 23:23:49 -06:00
|
|
|
|
2014-01-17 12:18:02 -06:00
|
|
|
if !force_host {
|
|
|
|
force_host = parse_force_host(ln);
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:25:09 -06:00
|
|
|
if !check_stdout {
|
|
|
|
check_stdout = parse_check_stdout(ln);
|
|
|
|
}
|
|
|
|
|
2014-02-10 13:33:33 -06:00
|
|
|
if !no_prefer_dynamic {
|
|
|
|
no_prefer_dynamic = parse_no_prefer_dynamic(ln);
|
|
|
|
}
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
if !pretty_expanded {
|
|
|
|
pretty_expanded = parse_pretty_expanded(ln);
|
2014-05-10 19:39:08 -05:00
|
|
|
}
|
|
|
|
|
2014-07-22 18:39:10 -05:00
|
|
|
if pretty_mode.is_none() {
|
|
|
|
pretty_mode = parse_pretty_mode(ln);
|
|
|
|
}
|
|
|
|
|
|
|
|
if !pretty_compare_only {
|
|
|
|
pretty_compare_only = parse_pretty_compare_only(ln);
|
|
|
|
}
|
|
|
|
|
2013-05-11 21:45:28 -05:00
|
|
|
match parse_aux_build(ln) {
|
|
|
|
Some(ab) => { aux_builds.push(ab); }
|
|
|
|
None => {}
|
2012-02-27 23:23:49 -06:00
|
|
|
}
|
2012-04-13 11:19:07 -05:00
|
|
|
|
2013-05-11 21:45:28 -05:00
|
|
|
match parse_exec_env(ln) {
|
|
|
|
Some(ee) => { exec_env.push(ee); }
|
|
|
|
None => {}
|
2012-04-13 11:19:07 -05:00
|
|
|
}
|
2013-02-09 12:09:19 -06:00
|
|
|
|
|
|
|
match parse_check_line(ln) {
|
|
|
|
Some(cl) => check_lines.push(cl),
|
|
|
|
None => ()
|
|
|
|
};
|
2013-08-02 01:17:20 -05:00
|
|
|
|
2014-09-16 16:47:19 -05:00
|
|
|
match parse_forbid_output(ln) {
|
|
|
|
Some(of) => forbid_output.push(of),
|
|
|
|
None => (),
|
|
|
|
}
|
|
|
|
|
2013-08-02 01:17:20 -05:00
|
|
|
true
|
2013-11-21 19:23:21 -06:00
|
|
|
});
|
2014-04-19 04:36:00 -05:00
|
|
|
|
2015-03-19 14:42:53 -05:00
|
|
|
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
|
2015-02-15 08:30:09 -06:00
|
|
|
match env::var(key) {
|
|
|
|
Ok(val) =>
|
|
|
|
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
|
|
|
|
exec_env.push((key.to_string(), val))
|
|
|
|
},
|
|
|
|
Err(..) => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-19 04:36:00 -05:00
|
|
|
TestProps {
|
2011-08-01 16:10:59 -05:00
|
|
|
error_patterns: error_patterns,
|
|
|
|
compile_flags: compile_flags,
|
2014-04-19 04:36:00 -05:00
|
|
|
run_flags: run_flags,
|
2012-02-27 23:23:49 -06:00
|
|
|
pp_exact: pp_exact,
|
2012-04-13 11:19:07 -05:00
|
|
|
aux_builds: aux_builds,
|
2013-02-09 12:09:19 -06:00
|
|
|
exec_env: exec_env,
|
2014-01-17 12:18:02 -06:00
|
|
|
check_lines: check_lines,
|
|
|
|
force_host: force_host,
|
2014-02-12 12:25:09 -06:00
|
|
|
check_stdout: check_stdout,
|
2014-02-10 13:33:33 -06:00
|
|
|
no_prefer_dynamic: no_prefer_dynamic,
|
2015-03-22 15:13:15 -05:00
|
|
|
pretty_expanded: pretty_expanded,
|
2014-07-22 18:39:10 -05:00
|
|
|
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
|
2014-09-16 16:47:19 -05:00
|
|
|
pretty_compare_only: pretty_compare_only,
|
|
|
|
forbid_output: forbid_output,
|
2014-04-19 04:36:00 -05:00
|
|
|
}
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2014-04-15 23:56:39 -05:00
|
|
|
pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
|
2014-05-22 18:57:53 -05:00
|
|
|
fn ignore_target(config: &Config) -> String {
|
2015-02-01 20:53:25 -06:00
|
|
|
format!("ignore-{}", util::get_os(&config.target))
|
2011-09-09 15:24:06 -05:00
|
|
|
}
|
2015-03-18 02:57:29 -05:00
|
|
|
fn ignore_architecture(config: &Config) -> String {
|
|
|
|
format!("ignore-{}", util::get_arch(&config.target))
|
|
|
|
}
|
2014-05-22 18:57:53 -05:00
|
|
|
fn ignore_stage(config: &Config) -> String {
|
2014-05-27 22:44:58 -05:00
|
|
|
format!("ignore-{}",
|
2015-01-26 20:21:15 -06:00
|
|
|
config.stage_id.split('-').next().unwrap())
|
2013-12-25 12:10:33 -06:00
|
|
|
}
|
2015-04-23 20:40:54 -05:00
|
|
|
fn ignore_env(config: &Config) -> String {
|
|
|
|
format!("ignore-{}", util::get_env(&config.target).unwrap_or("<unknown>"))
|
|
|
|
}
|
2014-08-20 05:53:50 -05:00
|
|
|
fn ignore_gdb(config: &Config, line: &str) -> bool {
|
|
|
|
if config.mode != common::DebugInfoGdb {
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-02 01:17:20 -05:00
|
|
|
|
2014-08-20 05:53:50 -05:00
|
|
|
if parse_name_directive(line, "ignore-gdb") {
|
|
|
|
return true;
|
2014-05-14 22:47:24 -05:00
|
|
|
}
|
2014-08-20 05:53:50 -05:00
|
|
|
|
|
|
|
match config.gdb_version {
|
|
|
|
Some(ref actual_version) => {
|
|
|
|
if line.contains("min-gdb-version") {
|
|
|
|
let min_version = line.trim()
|
|
|
|
.split(' ')
|
|
|
|
.last()
|
|
|
|
.expect("Malformed GDB version directive");
|
|
|
|
// Ignore if actual version is smaller the minimum required
|
|
|
|
// version
|
2015-02-01 20:53:25 -06:00
|
|
|
gdb_version_to_int(actual_version) <
|
|
|
|
gdb_version_to_int(min_version)
|
2014-08-20 05:53:50 -05:00
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-02 04:35:24 -05:00
|
|
|
fn ignore_lldb(config: &Config, line: &str) -> bool {
|
|
|
|
if config.mode != common::DebugInfoLldb {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if parse_name_directive(line, "ignore-lldb") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
match config.lldb_version {
|
|
|
|
Some(ref actual_version) => {
|
|
|
|
if line.contains("min-lldb-version") {
|
|
|
|
let min_version = line.trim()
|
|
|
|
.split(' ')
|
|
|
|
.last()
|
|
|
|
.expect("Malformed lldb version directive");
|
|
|
|
// Ignore if actual version is smaller the minimum required
|
|
|
|
// version
|
2015-02-01 20:53:25 -06:00
|
|
|
lldb_version_to_int(actual_version) <
|
|
|
|
lldb_version_to_int(min_version)
|
2014-10-02 04:35:24 -05:00
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:00:43 -06:00
|
|
|
let val = iter_header(testfile, &mut |ln| {
|
2014-08-20 05:53:50 -05:00
|
|
|
!parse_name_directive(ln, "ignore-test") &&
|
2015-02-01 20:53:25 -06:00
|
|
|
!parse_name_directive(ln, &ignore_target(config)) &&
|
2015-03-18 02:57:29 -05:00
|
|
|
!parse_name_directive(ln, &ignore_architecture(config)) &&
|
2015-02-01 20:53:25 -06:00
|
|
|
!parse_name_directive(ln, &ignore_stage(config)) &&
|
2015-04-23 20:40:54 -05:00
|
|
|
!parse_name_directive(ln, &ignore_env(config)) &&
|
2014-08-20 05:53:50 -05:00
|
|
|
!(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
|
|
|
|
!(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
|
|
|
|
!ignore_gdb(config, ln) &&
|
2014-10-02 04:35:24 -05:00
|
|
|
!ignore_lldb(config, ln)
|
2013-11-21 19:23:21 -06:00
|
|
|
});
|
2013-08-02 01:17:20 -05:00
|
|
|
|
|
|
|
!val
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:00:43 -06:00
|
|
|
fn iter_header(testfile: &Path, it: &mut FnMut(&str) -> bool) -> bool {
|
|
|
|
let rdr = BufReader::new(File::open(testfile).unwrap());
|
2013-12-08 01:12:07 -06:00
|
|
|
for ln in rdr.lines() {
|
2011-07-30 23:11:14 -05:00
|
|
|
// Assume that any directives will be found before the first
|
|
|
|
// module or function. This doesn't seem to be an optimization
|
|
|
|
// with a warm page cache. Maybe with a cold one.
|
2014-02-19 20:53:46 -06:00
|
|
|
let ln = ln.unwrap();
|
2015-01-26 20:21:15 -06:00
|
|
|
if ln.starts_with("fn") ||
|
|
|
|
ln.starts_with("mod") {
|
2013-08-02 01:17:20 -05:00
|
|
|
return true;
|
2014-05-16 12:45:16 -05:00
|
|
|
} else {
|
2015-01-26 20:21:15 -06:00
|
|
|
if !(it(ln.trim())) {
|
2014-05-16 12:45:16 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
2012-08-01 19:30:05 -05:00
|
|
|
return true;
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_error_pattern(line: &str) -> Option<String> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "error-pattern")
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2014-09-16 16:47:19 -05:00
|
|
|
fn parse_forbid_output(line: &str) -> Option<String> {
|
|
|
|
parse_name_value_directive(line, "forbid-output")
|
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_aux_build(line: &str) -> Option<String> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "aux-build")
|
2012-02-27 23:23:49 -06:00
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_compile_flags(line: &str) -> Option<String> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "compile-flags")
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_run_flags(line: &str) -> Option<String> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "run-flags")
|
2014-04-19 04:36:00 -05:00
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_check_line(line: &str) -> Option<String> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "check")
|
2013-02-09 12:09:19 -06:00
|
|
|
}
|
|
|
|
|
2014-01-17 12:18:02 -06:00
|
|
|
fn parse_force_host(line: &str) -> bool {
|
|
|
|
parse_name_directive(line, "force-host")
|
|
|
|
}
|
|
|
|
|
2014-02-12 12:25:09 -06:00
|
|
|
fn parse_check_stdout(line: &str) -> bool {
|
|
|
|
parse_name_directive(line, "check-stdout")
|
|
|
|
}
|
|
|
|
|
2014-02-10 13:33:33 -06:00
|
|
|
fn parse_no_prefer_dynamic(line: &str) -> bool {
|
|
|
|
parse_name_directive(line, "no-prefer-dynamic")
|
|
|
|
}
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
fn parse_pretty_expanded(line: &str) -> bool {
|
|
|
|
parse_name_directive(line, "pretty-expanded")
|
2014-05-10 19:39:08 -05:00
|
|
|
}
|
|
|
|
|
2014-07-22 18:39:10 -05:00
|
|
|
fn parse_pretty_mode(line: &str) -> Option<String> {
|
|
|
|
parse_name_value_directive(line, "pretty-mode")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn parse_pretty_compare_only(line: &str) -> bool {
|
|
|
|
parse_name_directive(line, "pretty-compare-only")
|
|
|
|
}
|
|
|
|
|
2014-05-22 18:57:53 -05:00
|
|
|
fn parse_exec_env(line: &str) -> Option<(String, String)> {
|
2014-06-25 00:35:54 -05:00
|
|
|
parse_name_value_directive(line, "exec-env").map(|nv| {
|
2012-04-13 11:19:07 -05:00
|
|
|
// nv is either FOO or FOO=BAR
|
2015-02-01 20:53:25 -06:00
|
|
|
let mut strs: Vec<String> = nv
|
2015-04-01 13:28:34 -05:00
|
|
|
.splitn(2, '=')
|
2014-05-25 05:17:19 -05:00
|
|
|
.map(|s| s.to_string())
|
2014-05-14 22:47:24 -05:00
|
|
|
.collect();
|
2013-06-09 08:10:50 -05:00
|
|
|
|
2012-08-06 14:34:08 -05:00
|
|
|
match strs.len() {
|
2015-01-24 08:39:32 -06:00
|
|
|
1 => (strs.pop().unwrap(), "".to_string()),
|
|
|
|
2 => {
|
2013-12-23 09:20:52 -06:00
|
|
|
let end = strs.pop().unwrap();
|
|
|
|
(strs.pop().unwrap(), end)
|
2013-05-11 21:45:28 -05:00
|
|
|
}
|
2014-10-09 14:17:22 -05:00
|
|
|
n => panic!("Expected 1 or 2 strings, not {}", n)
|
2012-04-13 11:19:07 -05:00
|
|
|
}
|
2013-11-21 19:23:21 -06:00
|
|
|
})
|
2012-04-13 11:19:07 -05:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:00:43 -06:00
|
|
|
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<PathBuf> {
|
2014-06-25 00:35:54 -05:00
|
|
|
match parse_name_value_directive(line, "pp-exact") {
|
2015-03-18 11:14:54 -05:00
|
|
|
Some(s) => Some(PathBuf::from(&s)),
|
2012-12-28 10:28:36 -06:00
|
|
|
None => {
|
2013-05-11 21:45:28 -05:00
|
|
|
if parse_name_directive(line, "pp-exact") {
|
2015-03-18 11:14:54 -05:00
|
|
|
testfile.file_name().map(|s| PathBuf::from(s))
|
2011-08-01 16:10:59 -05:00
|
|
|
} else {
|
2012-12-28 10:28:36 -06:00
|
|
|
None
|
2011-08-01 16:10:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-11 21:45:28 -05:00
|
|
|
fn parse_name_directive(line: &str, directive: &str) -> bool {
|
2015-03-22 15:13:15 -05:00
|
|
|
// This 'no-' rule is a quick hack to allow pretty-expanded and no-pretty-expanded to coexist
|
|
|
|
line.contains(directive) && !line.contains(&("no-".to_string() + directive))
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
|
|
|
|
2014-06-25 00:35:54 -05:00
|
|
|
pub fn parse_name_value_directive(line: &str, directive: &str)
|
2014-05-22 18:57:53 -05:00
|
|
|
-> Option<String> {
|
2014-05-27 22:44:58 -05:00
|
|
|
let keycolon = format!("{}:", directive);
|
2015-02-19 07:36:58 -06:00
|
|
|
match line.find(&keycolon) {
|
2013-04-09 01:08:16 -05:00
|
|
|
Some(colon) => {
|
2015-01-17 18:15:52 -06:00
|
|
|
let value = line[(colon + keycolon.len()) .. line.len()].to_string();
|
2014-05-14 22:47:24 -05:00
|
|
|
debug!("{}: {}", directive, value);
|
2013-04-09 01:08:16 -05:00
|
|
|
Some(value)
|
2012-02-13 00:00:56 -06:00
|
|
|
}
|
2013-04-09 01:08:16 -05:00
|
|
|
None => None
|
2012-02-13 00:00:56 -06:00
|
|
|
}
|
2011-07-30 23:11:14 -05:00
|
|
|
}
|
2014-08-20 05:53:50 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
pub fn gdb_version_to_int(version_string: &str) -> isize {
|
2014-08-20 05:53:50 -05:00
|
|
|
let error_string = format!(
|
|
|
|
"Encountered GDB version string with unexpected format: {}",
|
|
|
|
version_string);
|
2015-02-01 20:53:25 -06:00
|
|
|
let error_string = error_string;
|
2014-08-20 05:53:50 -05:00
|
|
|
|
|
|
|
let components: Vec<&str> = version_string.trim().split('.').collect();
|
|
|
|
|
|
|
|
if components.len() != 2 {
|
2014-10-09 14:17:22 -05:00
|
|
|
panic!("{}", error_string);
|
2014-08-20 05:53:50 -05:00
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
let major: isize = components[0].parse().ok().expect(&error_string);
|
|
|
|
let minor: isize = components[1].parse().ok().expect(&error_string);
|
2014-08-20 05:53:50 -05:00
|
|
|
|
|
|
|
return major * 1000 + minor;
|
|
|
|
}
|
2014-10-02 04:35:24 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
pub fn lldb_version_to_int(version_string: &str) -> isize {
|
2014-10-02 04:35:24 -05:00
|
|
|
let error_string = format!(
|
|
|
|
"Encountered LLDB version string with unexpected format: {}",
|
|
|
|
version_string);
|
2015-02-01 20:53:25 -06:00
|
|
|
let error_string = error_string;
|
2015-03-25 19:06:52 -05:00
|
|
|
let major: isize = version_string.parse().ok().expect(&error_string);
|
2014-10-02 04:35:24 -05:00
|
|
|
return major;
|
|
|
|
}
|