about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-04-19 11:36:00 +0200
committerAdolfo OchagavĂ­a <aochagavia92@gmail.com>2014-04-20 12:54:34 +0200
commit49ff21ed87aaa2a720653bbd0ac42c4028138034 (patch)
tree53a2a1f2a4f84b1aed66b084ac35f5f439fd5303
parentd35804ea5e69c9a3a8957626533a856f976fe4e3 (diff)
downloadrust-49ff21ed87aaa2a720653bbd0ac42c4028138034.tar.gz
rust-49ff21ed87aaa2a720653bbd0ac42c4028138034.zip
Added run_flags directive to `compiletest`
Now it is possible to specify run-flags in tests. For example, by using `run-flags: --bench` the Bencher is run.
-rw-r--r--src/compiletest/header.rs17
-rw-r--r--src/compiletest/runtest.rs7
2 files changed, 21 insertions, 3 deletions
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index b45a68518a3..e8c0880226f 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -17,6 +17,8 @@ pub struct TestProps {
     pub error_patterns: Vec<~str> ,
     // Extra flags to pass to the compiler
     pub compile_flags: Option<~str>,
+    // Extra flags to pass when the compiled code is run (such as --bench)
+    pub run_flags: Option<~str>,
     // If present, the name of a file that this test should match when
     // pretty-printed
     pub pp_exact: Option<Path>,
@@ -42,6 +44,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
     let mut aux_builds = Vec::new();
     let mut exec_env = Vec::new();
     let mut compile_flags = None;
+    let mut run_flags = None;
     let mut pp_exact = None;
     let mut debugger_cmds = Vec::new();
     let mut check_lines = Vec::new();
@@ -58,6 +61,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
             compile_flags = parse_compile_flags(ln);
         }
 
+        if run_flags.is_none() {
+            run_flags = parse_run_flags(ln);
+        }
+
         if pp_exact.is_none() {
             pp_exact = parse_pp_exact(ln, testfile);
         }
@@ -96,9 +103,11 @@ pub fn load_props(testfile: &Path) -> TestProps {
 
         true
     });
-    return TestProps {
+
+    TestProps {
         error_patterns: error_patterns,
         compile_flags: compile_flags,
+        run_flags: run_flags,
         pp_exact: pp_exact,
         aux_builds: aux_builds,
         exec_env: exec_env,
@@ -107,7 +116,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
         force_host: force_host,
         check_stdout: check_stdout,
         no_prefer_dynamic: no_prefer_dynamic,
-    };
+    }
 }
 
 pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
@@ -160,6 +169,10 @@ fn parse_compile_flags(line: &str) -> Option<~str> {
     parse_name_value_directive(line, ~"compile-flags")
 }
 
+fn parse_run_flags(line: &str) -> Option<~str> {
+    parse_name_value_directive(line, ~"run-flags")
+}
+
 fn parse_debugger_cmd(line: &str) -> Option<~str> {
     parse_name_value_directive(line, ~"debugger")
 }
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index 1885f20bd88..cc417c7f430 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -834,14 +834,19 @@ fn make_exe_name(config: &config, testfile: &Path) -> Path {
     f
 }
 
-fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
+fn make_run_args(config: &config, props: &TestProps, testfile: &Path) ->
    ProcArgs {
     // If we've got another tool to run under (valgrind),
     // then split apart its command
     let mut args = split_maybe_args(&config.runtool);
     let exe_file = make_exe_name(config, testfile);
+
     // FIXME (#9639): This needs to handle non-utf8 paths
     args.push(exe_file.as_str().unwrap().to_owned());
+
+    // Add the arguments in the run_flags directive
+    args.push_all_move(split_maybe_args(&props.run_flags));
+
     let prog = args.shift().unwrap();
     return ProcArgs {prog: prog, args: args};
 }