@@ -189,11 +189,12 @@ fn main() {
189189 . arg ( "-format=lcov" )
190190 . arg ( "-instr-profile" )
191191 . arg ( & profdata_file)
192- . arg ( "-ignore-filename-regex=' .*external/.+' " )
193- . arg ( "-ignore-filename-regex=' /tmp/.+' " )
194- . arg ( format ! ( "-path-equivalence=.,'{}' " , execroot. display( ) ) )
192+ . arg ( "-ignore-filename-regex=.*external/.+" )
193+ . arg ( "-ignore-filename-regex=/tmp/.+" )
194+ . arg ( format ! ( "-path-equivalence=.,{} " , execroot. display( ) ) )
195195 . arg ( test_binary)
196- . stdout ( process:: Stdio :: piped ( ) ) ;
196+ . stdout ( process:: Stdio :: piped ( ) )
197+ . stderr ( process:: Stdio :: piped ( ) ) ;
197198
198199 debug_log ! ( "Spawning {:#?}" , llvm_cov_cmd) ;
199200 let child = llvm_cov_cmd
@@ -202,6 +203,18 @@ fn main() {
202203
203204 let output = child. wait_with_output ( ) . expect ( "llvm-cov process failed" ) ;
204205
206+ if !output. status . success ( ) {
207+ let stderr = std:: str:: from_utf8 ( & output. stderr ) . unwrap_or ( "<non-utf8>" ) ;
208+ if stderr. contains ( "no coverage data found" ) {
209+ debug_log ! ( "No coverage data found in binary; writing empty report" ) ;
210+ fs:: write ( & coverage_output_file, "" ) . unwrap ( ) ;
211+ fs:: remove_file ( & profdata_file) . ok ( ) ;
212+ return ;
213+ }
214+ eprintln ! ( "llvm-cov export failed:\n {}" , stderr) ;
215+ process:: exit ( output. status . code ( ) . unwrap_or ( 1 ) ) ;
216+ }
217+
205218 // Parse the child process's stdout to a string now that it's complete.
206219 debug_log ! ( "Parsing llvm-cov output" ) ;
207220 let report_str = std:: str:: from_utf8 ( & output. stdout ) . expect ( "Failed to parse llvm-cov output" ) ;
0 commit comments