File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,16 +307,21 @@ fn main() {
307307 indicator. stop ( ) ;
308308
309309 let print_errors = config. get_print_errors ( & options) ;
310- print_any_errors ( print_errors, walk_data. errors ) ;
311-
312- print_output (
313- config,
314- options,
315- tree,
316- walk_data. by_filecount ,
317- is_colors,
318- terminal_width,
319- )
310+ let final_errors = walk_data. errors . lock ( ) . unwrap ( ) ;
311+ print_any_errors ( print_errors, & final_errors) ;
312+
313+ if tree. children . is_empty ( ) && !final_errors. file_not_found . is_empty ( ) {
314+ std:: process:: exit ( 1 )
315+ } else {
316+ print_output (
317+ config,
318+ options,
319+ tree,
320+ walk_data. by_filecount ,
321+ is_colors,
322+ terminal_width,
323+ )
324+ }
320325 } ) ;
321326}
322327
@@ -357,8 +362,7 @@ fn print_output(
357362 }
358363}
359364
360- fn print_any_errors ( print_errors : bool , errors : Arc < Mutex < RuntimeErrors > > ) {
361- let final_errors = errors. lock ( ) . unwrap ( ) ;
365+ fn print_any_errors ( print_errors : bool , final_errors : & RuntimeErrors ) {
362366 if !final_errors. file_not_found . is_empty ( ) {
363367 let err = final_errors
364368 . file_not_found
Original file line number Diff line number Diff line change @@ -107,7 +107,9 @@ pub fn test_ignore_all_in_file() {
107107#[ test]
108108pub fn test_with_bad_param ( ) {
109109 let mut cmd = Command :: cargo_bin ( "dust" ) . unwrap ( ) ;
110- let result = cmd. arg ( "bad_place" ) . unwrap ( ) ;
110+ cmd. arg ( "-P" ) . arg ( "bad_place" ) ;
111+ let output_error = cmd. unwrap_err ( ) ;
112+ let result = output_error. as_output ( ) . unwrap ( ) ;
111113 let stderr = str:: from_utf8 ( & result. stderr ) . unwrap ( ) ;
112114 assert ! ( stderr. contains( "No such file or directory" ) ) ;
113115}
You can’t perform that action at this time.
0 commit comments