@@ -4,16 +4,17 @@ use std::io::{BufRead, BufReader};
44
55use camino:: { Utf8Path , Utf8PathBuf } ;
66
7+ use crate :: line_no:: LineNo ;
78use crate :: runtest:: ProcRes ;
89
910/// Representation of information to invoke a debugger and check its output
1011pub ( super ) struct DebuggerCommands {
1112 /// Commands for the debuuger
1213 pub commands : Vec < String > ,
1314 /// Lines to insert breakpoints at
14- pub breakpoint_lines : Vec < usize > ,
15+ pub breakpoint_lines : Vec < LineNo > ,
1516 /// Contains the source line number to check and the line itself
16- check_lines : Vec < ( usize , String ) > ,
17+ check_lines : Vec < ( LineNo , String ) > ,
1718 /// Source file name
1819 file : Utf8PathBuf ,
1920}
@@ -26,15 +27,13 @@ impl DebuggerCommands {
2627 let mut breakpoint_lines = vec ! [ ] ;
2728 let mut commands = vec ! [ ] ;
2829 let mut check_lines = vec ! [ ] ;
29- let mut counter = 0 ;
3030 let reader = BufReader :: new ( File :: open ( file. as_std_path ( ) ) . unwrap ( ) ) ;
3131 for ( line_no, line) in reader. lines ( ) . enumerate ( ) {
32- counter += 1 ;
3332 let line = line. map_err ( |e| format ! ( "Error while parsing debugger commands: {}" , e) ) ?;
3433
3534 // Breakpoints appear on lines with actual code, typically at the end of the line.
3635 if line. contains ( "#break" ) {
37- breakpoint_lines. push ( counter ) ;
36+ breakpoint_lines. push ( LineNo :: from_zero_based ( line_no ) ) ;
3837 continue ;
3938 }
4039
@@ -46,7 +45,7 @@ impl DebuggerCommands {
4645 commands. push ( command) ;
4746 }
4847 if let Some ( pattern) = parse_name_value ( & line, & check_directive) {
49- check_lines. push ( ( line_no, pattern) ) ;
48+ check_lines. push ( ( LineNo :: from_zero_based ( line_no) , pattern) ) ;
5049 }
5150 }
5251
@@ -88,15 +87,14 @@ impl DebuggerCommands {
8887 ) ;
8988
9089 for ( src_lineno, err_line) in missing {
91- write ! ( msg, "\n ({fname}:{num }) `{err_line}`" , num = src_lineno + 1 ) . unwrap ( ) ;
90+ write ! ( msg, "\n ({fname}:{src_lineno }) `{err_line}`" ) . unwrap ( ) ;
9291 }
9392
9493 if !found. is_empty ( ) {
9594 let init = "\n the following subset of check directive(s) was found successfully:" ;
9695 msg. push_str ( init) ;
9796 for ( src_lineno, found_line) in found {
98- write ! ( msg, "\n ({fname}:{num}) `{found_line}`" , num = src_lineno + 1 )
99- . unwrap ( ) ;
97+ write ! ( msg, "\n ({fname}:{src_lineno}) `{found_line}`" ) . unwrap ( ) ;
10098 }
10199 }
102100
0 commit comments