@@ -12,10 +12,12 @@ fn setup_common_build_cmd() -> Command {
12
12
cmd
13
13
}
14
14
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( ) ) ;
19
21
std:: process:: exit ( 1 )
20
22
}
21
23
@@ -43,10 +45,14 @@ impl RustcInvocationBuilder {
43
45
self
44
46
}
45
47
48
+ #[ track_caller]
46
49
pub fn run ( & mut self ) -> Output {
50
+ let caller_location = std:: panic:: Location :: caller ( ) ;
51
+ let caller_line_number = caller_location. line ( ) ;
52
+
47
53
let output = self . cmd . output ( ) . unwrap ( ) ;
48
54
if !output. status . success ( ) {
49
- handle_failed_output ( & format ! ( "{:?}" , self . cmd) , output) ;
55
+ handle_failed_output ( & format ! ( "{:# ?}" , self . cmd) , output, caller_line_number ) ;
50
56
}
51
57
output
52
58
}
@@ -69,10 +75,14 @@ impl AuxBuildInvocationBuilder {
69
75
self
70
76
}
71
77
78
+ #[ track_caller]
72
79
pub fn run ( & mut self ) -> Output {
80
+ let caller_location = std:: panic:: Location :: caller ( ) ;
81
+ let caller_line_number = caller_location. line ( ) ;
82
+
73
83
let output = self . cmd . output ( ) . unwrap ( ) ;
74
84
if !output. status . success ( ) {
75
- handle_failed_output ( & format ! ( "{:?}" , self . cmd) , output) ;
85
+ handle_failed_output ( & format ! ( "{:# ?}" , self . cmd) , output, caller_line_number ) ;
76
86
}
77
87
output
78
88
}
@@ -104,19 +114,27 @@ fn run_common(bin_name: &str) -> (Command, Output) {
104
114
}
105
115
106
116
/// Run a built binary and make sure it succeeds.
117
+ #[ track_caller]
107
118
pub fn run ( bin_name : & str ) -> Output {
119
+ let caller_location = std:: panic:: Location :: caller ( ) ;
120
+ let caller_line_number = caller_location. line ( ) ;
121
+
108
122
let ( cmd, output) = run_common ( bin_name) ;
109
123
if !output. status . success ( ) {
110
- handle_failed_output ( & format ! ( "{:?}" , cmd) , output) ;
124
+ handle_failed_output ( & format ! ( "{:# ?}" , cmd) , output, caller_line_number ) ;
111
125
}
112
126
output
113
127
}
114
128
115
129
/// Run a built binary and make sure it fails.
130
+ #[ track_caller]
116
131
pub fn run_fail ( bin_name : & str ) -> Output {
132
+ let caller_location = std:: panic:: Location :: caller ( ) ;
133
+ let caller_line_number = caller_location. line ( ) ;
134
+
117
135
let ( cmd, output) = run_common ( bin_name) ;
118
136
if output. status . success ( ) {
119
- handle_failed_output ( & format ! ( "{:?}" , cmd) , output) ;
137
+ handle_failed_output ( & format ! ( "{:# ?}" , cmd) , output, caller_line_number ) ;
120
138
}
121
139
output
122
140
}
0 commit comments