1515// Unfortunately, LLVM has no "disable" option for this, so we have to set
1616// "enable" to 0 instead.
1717
18- // compile-flags:-g -Cllvm-args=-enable-tail-merge=0
18+ // compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0
1919// ignore-pretty issue #37195
2020// ignore-cloudabi spawning processes is not supported
2121// ignore-emscripten spawning processes is not supported
2222
23+ // note that above `-opt-bisect-limit=0` is used to basically disable
24+ // optimizations
25+
2326use std:: env;
2427
2528#[ path = "backtrace-debuginfo-aux.rs" ] mod aux;
@@ -114,25 +117,34 @@ fn outer(mut counter: i32, main_pos: Pos) {
114117 inner_inlined ( & mut counter, main_pos, pos ! ( ) ) ;
115118}
116119
117- fn check_trace ( output : & str , error : & str ) {
120+ fn check_trace ( output : & str , error : & str ) -> Result < ( ) , String > {
118121 // reverse the position list so we can start with the last item (which was the first line)
119122 let mut remaining: Vec < & str > = output. lines ( ) . map ( |s| s. trim ( ) ) . rev ( ) . collect ( ) ;
120123
121- assert ! ( error. contains( "stack backtrace" ) , "no backtrace in the error: {}" , error) ;
124+ if !error. contains ( "stack backtrace" ) {
125+ return Err ( format ! ( "no backtrace found in stderr:\n {}" , error) )
126+ }
122127 for line in error. lines ( ) {
123128 if !remaining. is_empty ( ) && line. contains ( remaining. last ( ) . unwrap ( ) ) {
124129 remaining. pop ( ) ;
125130 }
126131 }
127- assert ! ( remaining. is_empty( ) ,
128- "trace does not match position list: {}\n ---\n {}" , error, output) ;
132+ if !remaining. is_empty ( ) {
133+ return Err ( format ! ( "trace does not match position list\n \
134+ still need to find {:?}\n \n \
135+ --- stdout\n {}\n \
136+ --- stderr\n {}",
137+ remaining, output, error) )
138+ }
139+ Ok ( ( ) )
129140}
130141
131142fn run_test ( me : & str ) {
132143 use std:: str;
133144 use std:: process:: Command ;
134145
135146 let mut i = 0 ;
147+ let mut errors = Vec :: new ( ) ;
136148 loop {
137149 let out = Command :: new ( me)
138150 . env ( "RUST_BACKTRACE" , "full" )
@@ -143,10 +155,20 @@ fn run_test(me: &str) {
143155 assert ! ( output. contains( "done." ) , "bad output for successful run: {}" , output) ;
144156 break ;
145157 } else {
146- check_trace ( output, error) ;
158+ if let Err ( e) = check_trace ( output, error) {
159+ errors. push ( e) ;
160+ }
147161 }
148162 i += 1 ;
149163 }
164+ if errors. len ( ) > 0 {
165+ for error in errors {
166+ println ! ( "---------------------------------------" ) ;
167+ println ! ( "{}" , error) ;
168+ }
169+
170+ panic ! ( "found some errors" ) ;
171+ }
150172}
151173
152174#[ inline( never) ]
0 commit comments