@@ -12,10 +12,12 @@ fn setup_common_build_cmd() -> Command {
1212 cmd
1313}
1414
15- fn handle_failed_output ( cmd : & str , output : Output ) -> ! {
16- println ! ( "command failed: `{}`" , cmd) ;
17- println ! ( "=== STDOUT ===\n {}\n \n " , String :: from_utf8( output. stdout) . unwrap( ) ) ;
18- println ! ( "=== STDERR ===\n {}\n \n " , String :: from_utf8( output. stderr) . unwrap( ) ) ;
15+ fn handle_failed_output ( cmd : & str , output : Output , caller_line_number : u32 ) -> ! {
16+ eprintln ! ( "command failed at line {caller_line_number}" ) ;
17+ eprintln ! ( "{cmd}" ) ;
18+ eprintln ! ( "output status: `{}`" , output. status) ;
19+ eprintln ! ( "=== STDOUT ===\n {}\n \n " , String :: from_utf8( output. stdout) . unwrap( ) ) ;
20+ eprintln ! ( "=== STDERR ===\n {}\n \n " , String :: from_utf8( output. stderr) . unwrap( ) ) ;
1921 std:: process:: exit ( 1 )
2022}
2123
@@ -43,10 +45,14 @@ impl RustcInvocationBuilder {
4345 self
4446 }
4547
48+ #[ track_caller]
4649 pub fn run ( & mut self ) -> Output {
50+ let caller_location = std:: panic:: Location :: caller ( ) ;
51+ let caller_line_number = caller_location. line ( ) ;
52+
4753 let output = self . cmd . output ( ) . unwrap ( ) ;
4854 if !output. status . success ( ) {
49- handle_failed_output ( & format ! ( "{:?}" , self . cmd) , output) ;
55+ handle_failed_output ( & format ! ( "{:# ?}" , self . cmd) , output, caller_line_number ) ;
5056 }
5157 output
5258 }
@@ -69,10 +75,14 @@ impl AuxBuildInvocationBuilder {
6975 self
7076 }
7177
78+ #[ track_caller]
7279 pub fn run ( & mut self ) -> Output {
80+ let caller_location = std:: panic:: Location :: caller ( ) ;
81+ let caller_line_number = caller_location. line ( ) ;
82+
7383 let output = self . cmd . output ( ) . unwrap ( ) ;
7484 if !output. status . success ( ) {
75- handle_failed_output ( & format ! ( "{:?}" , self . cmd) , output) ;
85+ handle_failed_output ( & format ! ( "{:# ?}" , self . cmd) , output, caller_line_number ) ;
7686 }
7787 output
7888 }
@@ -104,19 +114,27 @@ fn run_common(bin_name: &str) -> (Command, Output) {
104114}
105115
106116/// Run a built binary and make sure it succeeds.
117+ #[ track_caller]
107118pub fn run ( bin_name : & str ) -> Output {
119+ let caller_location = std:: panic:: Location :: caller ( ) ;
120+ let caller_line_number = caller_location. line ( ) ;
121+
108122 let ( cmd, output) = run_common ( bin_name) ;
109123 if !output. status . success ( ) {
110- handle_failed_output ( & format ! ( "{:?}" , cmd) , output) ;
124+ handle_failed_output ( & format ! ( "{:# ?}" , cmd) , output, caller_line_number ) ;
111125 }
112126 output
113127}
114128
115129/// Run a built binary and make sure it fails.
130+ #[ track_caller]
116131pub fn run_fail ( bin_name : & str ) -> Output {
132+ let caller_location = std:: panic:: Location :: caller ( ) ;
133+ let caller_line_number = caller_location. line ( ) ;
134+
117135 let ( cmd, output) = run_common ( bin_name) ;
118136 if output. status . success ( ) {
119- handle_failed_output ( & format ! ( "{:?}" , cmd) , output) ;
137+ handle_failed_output ( & format ! ( "{:# ?}" , cmd) , output, caller_line_number ) ;
120138 }
121139 output
122140}
0 commit comments