Skip to content

Commit db93392

Browse files
committed
auto merge of #13553 : aochagavia/rust/pr, r=alexcrichton
Now it is possible to specify run-flags in tests. For example, by using `run-flags: --bench` the Bencher is run.
2 parents 1c101da + 49ff21e commit db93392

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/compiletest/header.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub struct TestProps {
1717
pub error_patterns: Vec<~str> ,
1818
// Extra flags to pass to the compiler
1919
pub compile_flags: Option<~str>,
20+
// Extra flags to pass when the compiled code is run (such as --bench)
21+
pub run_flags: Option<~str>,
2022
// If present, the name of a file that this test should match when
2123
// pretty-printed
2224
pub pp_exact: Option<Path>,
@@ -42,6 +44,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
4244
let mut aux_builds = Vec::new();
4345
let mut exec_env = Vec::new();
4446
let mut compile_flags = None;
47+
let mut run_flags = None;
4548
let mut pp_exact = None;
4649
let mut debugger_cmds = Vec::new();
4750
let mut check_lines = Vec::new();
@@ -58,6 +61,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
5861
compile_flags = parse_compile_flags(ln);
5962
}
6063

64+
if run_flags.is_none() {
65+
run_flags = parse_run_flags(ln);
66+
}
67+
6168
if pp_exact.is_none() {
6269
pp_exact = parse_pp_exact(ln, testfile);
6370
}
@@ -96,9 +103,11 @@ pub fn load_props(testfile: &Path) -> TestProps {
96103

97104
true
98105
});
99-
return TestProps {
106+
107+
TestProps {
100108
error_patterns: error_patterns,
101109
compile_flags: compile_flags,
110+
run_flags: run_flags,
102111
pp_exact: pp_exact,
103112
aux_builds: aux_builds,
104113
exec_env: exec_env,
@@ -107,7 +116,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
107116
force_host: force_host,
108117
check_stdout: check_stdout,
109118
no_prefer_dynamic: no_prefer_dynamic,
110-
};
119+
}
111120
}
112121

113122
pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
@@ -160,6 +169,10 @@ fn parse_compile_flags(line: &str) -> Option<~str> {
160169
parse_name_value_directive(line, "compile-flags".to_owned())
161170
}
162171

172+
fn parse_run_flags(line: &str) -> Option<~str> {
173+
parse_name_value_directive(line, ~"run-flags")
174+
}
175+
163176
fn parse_debugger_cmd(line: &str) -> Option<~str> {
164177
parse_name_value_directive(line, "debugger".to_owned())
165178
}

src/compiletest/runtest.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -835,14 +835,19 @@ fn make_exe_name(config: &config, testfile: &Path) -> Path {
835835
f
836836
}
837837

838-
fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
838+
fn make_run_args(config: &config, props: &TestProps, testfile: &Path) ->
839839
ProcArgs {
840840
// If we've got another tool to run under (valgrind),
841841
// then split apart its command
842842
let mut args = split_maybe_args(&config.runtool);
843843
let exe_file = make_exe_name(config, testfile);
844+
844845
// FIXME (#9639): This needs to handle non-utf8 paths
845846
args.push(exe_file.as_str().unwrap().to_owned());
847+
848+
// Add the arguments in the run_flags directive
849+
args.push_all_move(split_maybe_args(&props.run_flags));
850+
846851
let prog = args.shift().unwrap();
847852
return ProcArgs {prog: prog, args: args};
848853
}

0 commit comments

Comments
 (0)