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.
This commit is contained in:
Adolfo Ochagavía 2014-04-19 11:36:00 +02:00
parent d35804ea5e
commit 49ff21ed87
2 changed files with 21 additions and 3 deletions

View File

@ -17,6 +17,8 @@ pub struct TestProps {
pub error_patterns: Vec<~str> , pub error_patterns: Vec<~str> ,
// Extra flags to pass to the compiler // Extra flags to pass to the compiler
pub compile_flags: Option<~str>, 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 // If present, the name of a file that this test should match when
// pretty-printed // pretty-printed
pub pp_exact: Option<Path>, pub pp_exact: Option<Path>,
@ -42,6 +44,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut aux_builds = Vec::new(); let mut aux_builds = Vec::new();
let mut exec_env = Vec::new(); let mut exec_env = Vec::new();
let mut compile_flags = None; let mut compile_flags = None;
let mut run_flags = None;
let mut pp_exact = None; let mut pp_exact = None;
let mut debugger_cmds = Vec::new(); let mut debugger_cmds = Vec::new();
let mut check_lines = 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); compile_flags = parse_compile_flags(ln);
} }
if run_flags.is_none() {
run_flags = parse_run_flags(ln);
}
if pp_exact.is_none() { if pp_exact.is_none() {
pp_exact = parse_pp_exact(ln, testfile); pp_exact = parse_pp_exact(ln, testfile);
} }
@ -96,9 +103,11 @@ pub fn load_props(testfile: &Path) -> TestProps {
true true
}); });
return TestProps {
TestProps {
error_patterns: error_patterns, error_patterns: error_patterns,
compile_flags: compile_flags, compile_flags: compile_flags,
run_flags: run_flags,
pp_exact: pp_exact, pp_exact: pp_exact,
aux_builds: aux_builds, aux_builds: aux_builds,
exec_env: exec_env, exec_env: exec_env,
@ -107,7 +116,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
force_host: force_host, force_host: force_host,
check_stdout: check_stdout, check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic, no_prefer_dynamic: no_prefer_dynamic,
}; }
} }
pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { 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") 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> { fn parse_debugger_cmd(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"debugger") parse_name_value_directive(line, ~"debugger")
} }

View File

@ -834,14 +834,19 @@ fn make_exe_name(config: &config, testfile: &Path) -> Path {
f f
} }
fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) -> fn make_run_args(config: &config, props: &TestProps, testfile: &Path) ->
ProcArgs { ProcArgs {
// If we've got another tool to run under (valgrind), // If we've got another tool to run under (valgrind),
// then split apart its command // then split apart its command
let mut args = split_maybe_args(&config.runtool); let mut args = split_maybe_args(&config.runtool);
let exe_file = make_exe_name(config, testfile); let exe_file = make_exe_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
args.push(exe_file.as_str().unwrap().to_owned()); 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(); let prog = args.shift().unwrap();
return ProcArgs {prog: prog, args: args}; return ProcArgs {prog: prog, args: args};
} }