Skip to content

Commit 6656e5c

Browse files
debuginfo: Fix a RUSTFLAGS incompatibility in test runner.
1 parent 3ce04dc commit 6656e5c

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/compiletest/runtest.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,12 @@ actual:\n\
258258
}
259259

260260
fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
261-
262-
// do not optimize debuginfo tests
263-
let mut config = match config.target_rustcflags {
264-
Some(ref flags) => config {
265-
target_rustcflags: Some(flags.replace("-O", "")),
266-
.. (*config).clone()
267-
},
268-
None => (*config).clone()
261+
let mut config = config {
262+
target_rustcflags: cleanup_debug_info_options(&config.target_rustcflags),
263+
host_rustcflags: cleanup_debug_info_options(&config.host_rustcflags),
264+
.. config.clone()
269265
};
266+
270267
let config = &mut config;
271268
let check_lines = &props.check_lines;
272269
let mut cmds = props.debugger_cmds.connect("\n");
@@ -436,6 +433,20 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
436433
check_lines[i]), &ProcRes);
437434
}
438435
}
436+
437+
fn cleanup_debug_info_options(options: &Option<~str>) -> Option<~str> {
438+
if options.is_none() {
439+
return None;
440+
}
441+
442+
// Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS.
443+
let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"];
444+
let new_options = split_maybe_args(options).move_iter()
445+
.filter(|x| !options_to_remove.contains(x))
446+
.to_owned_vec()
447+
.connect(" ");
448+
Some(new_options)
449+
}
439450
}
440451

441452
fn check_error_patterns(props: &TestProps,

0 commit comments

Comments
 (0)