]> git.lizzy.rs Git - rust.git/blobdiff - src/compiletest/header.rs
Replace all ~"" with "".to_owned()
[rust.git] / src / compiletest / header.rs
index 0c965b7c6c39ca011bb3ed6169c25344024609ba..1e9ce5789d17446f70c58dacbaeb97cb08668d19 100644 (file)
 
 pub struct TestProps {
     // Lines that should be expected, in order, on standard out
-    error_patterns: ~[~str],
+    pub error_patterns: Vec<~str> ,
     // Extra flags to pass to the compiler
-    compile_flags: Option<~str>,
+    pub compile_flags: Option<~str>,
     // If present, the name of a file that this test should match when
     // pretty-printed
-    pp_exact: Option<Path>,
+    pub pp_exact: Option<Path>,
     // Modules from aux directory that should be compiled
-    aux_builds: ~[~str],
+    pub aux_builds: Vec<~str> ,
     // Environment settings to use during execution
-    exec_env: ~[(~str,~str)],
+    pub exec_env: Vec<(~str,~str)> ,
     // Commands to be given to the debugger, when testing debug info
-    debugger_cmds: ~[~str],
+    pub debugger_cmds: Vec<~str> ,
     // Lines to check if they appear in the expected debugger output
-    check_lines: ~[~str],
+    pub check_lines: Vec<~str> ,
     // Flag to force a crate to be built with the host architecture
-    force_host: bool,
+    pub force_host: bool,
+    // Check stdout for error-pattern output as well as stderr
+    pub check_stdout: bool,
+    // Don't force a --crate-type=dylib flag on the command line
+    pub no_prefer_dynamic: bool,
 }
 
 // Load any test directives embedded in the file
 pub fn load_props(testfile: &Path) -> TestProps {
-    let mut error_patterns = ~[];
-    let mut aux_builds = ~[];
-    let mut exec_env = ~[];
+    let mut error_patterns = Vec::new();
+    let mut aux_builds = Vec::new();
+    let mut exec_env = Vec::new();
     let mut compile_flags = None;
     let mut pp_exact = None;
-    let mut debugger_cmds = ~[];
-    let mut check_lines = ~[];
+    let mut debugger_cmds = Vec::new();
+    let mut check_lines = Vec::new();
     let mut force_host = false;
+    let mut check_stdout = false;
+    let mut no_prefer_dynamic = false;
     iter_header(testfile, |ln| {
         match parse_error_pattern(ln) {
           Some(ep) => error_patterns.push(ep),
@@ -60,6 +66,14 @@ pub fn load_props(testfile: &Path) -> TestProps {
             force_host = parse_force_host(ln);
         }
 
+        if !check_stdout {
+            check_stdout = parse_check_stdout(ln);
+        }
+
+        if !no_prefer_dynamic {
+            no_prefer_dynamic = parse_no_prefer_dynamic(ln);
+        }
+
         match parse_aux_build(ln) {
             Some(ab) => { aux_builds.push(ab); }
             None => {}
@@ -91,15 +105,17 @@ pub fn load_props(testfile: &Path) -> TestProps {
         debugger_cmds: debugger_cmds,
         check_lines: check_lines,
         force_host: force_host,
+        check_stdout: check_stdout,
+        no_prefer_dynamic: no_prefer_dynamic,
     };
 }
 
 pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
     fn ignore_target(config: &config) -> ~str {
-        ~"ignore-" + util::get_os(config.target)
+        "ignore-".to_owned() + util::get_os(config.target)
     }
     fn ignore_stage(config: &config) -> ~str {
-        ~"ignore-" + config.stage_id.split('-').next().unwrap()
+        "ignore-".to_owned() + config.stage_id.split('-').next().unwrap()
     }
 
     let val = iter_header(testfile, |ln| {
@@ -124,6 +140,7 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
         // 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.
+        let ln = ln.unwrap();
         if ln.starts_with("fn") || ln.starts_with("mod") {
             return true;
         } else { if !(it(ln.trim())) { return false; } }
@@ -132,36 +149,44 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
 }
 
 fn parse_error_pattern(line: &str) -> Option<~str> {
-    parse_name_value_directive(line, ~"error-pattern")
+    parse_name_value_directive(line, "error-pattern".to_owned())
 }
 
 fn parse_aux_build(line: &str) -> Option<~str> {
-    parse_name_value_directive(line, ~"aux-build")
+    parse_name_value_directive(line, "aux-build".to_owned())
 }
 
 fn parse_compile_flags(line: &str) -> Option<~str> {
-    parse_name_value_directive(line, ~"compile-flags")
+    parse_name_value_directive(line, "compile-flags".to_owned())
 }
 
 fn parse_debugger_cmd(line: &str) -> Option<~str> {
-    parse_name_value_directive(line, ~"debugger")
+    parse_name_value_directive(line, "debugger".to_owned())
 }
 
 fn parse_check_line(line: &str) -> Option<~str> {
-    parse_name_value_directive(line, ~"check")
+    parse_name_value_directive(line, "check".to_owned())
 }
 
 fn parse_force_host(line: &str) -> bool {
     parse_name_directive(line, "force-host")
 }
 
+fn parse_check_stdout(line: &str) -> bool {
+    parse_name_directive(line, "check-stdout")
+}
+
+fn parse_no_prefer_dynamic(line: &str) -> bool {
+    parse_name_directive(line, "no-prefer-dynamic")
+}
+
 fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
-    parse_name_value_directive(line, ~"exec-env").map(|nv| {
+    parse_name_value_directive(line, "exec-env".to_owned()).map(|nv| {
         // nv is either FOO or FOO=BAR
-        let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
+        let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
 
         match strs.len() {
-          1u => (strs.pop().unwrap(), ~""),
+          1u => (strs.pop().unwrap(), "".to_owned()),
           2u => {
               let end = strs.pop().unwrap();
               (strs.pop().unwrap(), end)
@@ -172,7 +197,7 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
 }
 
 fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
-    match parse_name_value_directive(line, ~"pp-exact") {
+    match parse_name_value_directive(line, "pp-exact".to_owned()) {
       Some(s) => Some(Path::new(s)),
       None => {
         if parse_name_directive(line, "pp-exact") {