@@ -258,15 +258,12 @@ actual:\n\
258
258
}
259
259
260
260
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( )
269
265
} ;
266
+
270
267
let config = & mut config;
271
268
let check_lines = & props. check_lines;
272
269
let mut cmds = props. debugger_cmds. connect( "\n " ) ;
@@ -436,6 +433,20 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
436
433
check_lines[ i] ) , & ProcRes ) ;
437
434
}
438
435
}
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
+ }
439
450
}
440
451
441
452
fn check_error_patterns( props: & TestProps ,
0 commit comments