@@ -182,6 +182,12 @@ struct BackgroundTasksShowArgs {
182182 /// "all", "dns_external", or "dns_internal".
183183 #[ clap( value_name = "TASK_NAME" ) ]
184184 tasks : Vec < String > ,
185+
186+ /// Do not display information about whether a task is currently executing.
187+ ///
188+ /// Useful for test output stability.
189+ #[ clap( long) ]
190+ no_executing_info : bool ,
185191}
186192
187193#[ derive( Debug , Args ) ]
@@ -906,6 +912,10 @@ async fn cmd_nexus_background_tasks_show(
906912 } ) ;
907913 }
908914
915+ let opts = BackgroundTasksPrintOpts {
916+ show_executing_info : !args. no_executing_info ,
917+ } ;
918+
909919 // Some tasks should be grouped and printed together in a certain order,
910920 // even though their names aren't alphabetical. Notably, the DNS tasks
911921 // logically go from config -> servers -> propagation, so we want to print
@@ -923,14 +933,14 @@ async fn cmd_nexus_background_tasks_show(
923933 "blueprint_executor" ,
924934 ] {
925935 if let Some ( bgtask) = tasks. remove ( name) {
926- print_task ( & bgtask) ;
936+ print_task ( & bgtask, & opts ) ;
927937 } else if selected_all {
928938 eprintln ! ( "warning: expected to find background task {:?}" , name) ;
929939 }
930940 }
931941
932942 for ( _, bgtask) in & tasks {
933- print_task ( bgtask) ;
943+ print_task ( bgtask, & opts ) ;
934944 }
935945
936946 Ok ( ( ) )
@@ -999,32 +1009,39 @@ async fn cmd_nexus_background_tasks_activate(
9991009 Ok ( ( ) )
10001010}
10011011
1002- fn print_task ( bgtask : & BackgroundTask ) {
1012+ #[ derive( Clone , Debug ) ]
1013+ struct BackgroundTasksPrintOpts {
1014+ show_executing_info : bool ,
1015+ }
1016+
1017+ fn print_task ( bgtask : & BackgroundTask , opts : & BackgroundTasksPrintOpts ) {
10031018 println ! ( "task: {:?}" , bgtask. name) ;
10041019 println ! (
10051020 " configured period: every {}" ,
10061021 humantime:: format_duration( bgtask. period. clone( ) . into( ) )
10071022 ) ;
1008- print ! ( " currently executing: " ) ;
1009- match & bgtask. current {
1010- CurrentStatus :: Idle => println ! ( "no" ) ,
1011- CurrentStatus :: Running ( current) => {
1012- let elapsed = std:: time:: SystemTime :: from ( current. start_time )
1013- . elapsed ( )
1014- . map ( |s| format ! ( "{:.3}ms" , s. as_millis( ) ) )
1015- . unwrap_or_else ( |error| format ! ( "(unknown: {:#})" , error) ) ;
1016- print ! (
1017- "iter {}, triggered by {}\n " ,
1018- current. iteration,
1019- reason_str( & current. reason)
1020- ) ;
1021- print ! (
1022- " started at {}, running for {}\n " ,
1023- humantime:: format_rfc3339_millis( current. start_time. into( ) ) ,
1024- elapsed,
1025- ) ;
1023+ if opts. show_executing_info {
1024+ print ! ( " currently executing: " ) ;
1025+ match & bgtask. current {
1026+ CurrentStatus :: Idle => println ! ( "no" ) ,
1027+ CurrentStatus :: Running ( current) => {
1028+ let elapsed = std:: time:: SystemTime :: from ( current. start_time )
1029+ . elapsed ( )
1030+ . map ( |s| format ! ( "{:.3}ms" , s. as_millis( ) ) )
1031+ . unwrap_or_else ( |error| format ! ( "(unknown: {:#})" , error) ) ;
1032+ print ! (
1033+ "iter {}, triggered by {}\n " ,
1034+ current. iteration,
1035+ reason_str( & current. reason)
1036+ ) ;
1037+ print ! (
1038+ " started at {}, running for {}\n " ,
1039+ humantime:: format_rfc3339_millis( current. start_time. into( ) ) ,
1040+ elapsed,
1041+ ) ;
1042+ }
10261043 }
1027- } ;
1044+ }
10281045
10291046 print ! ( " last completed activation: " ) ;
10301047 match & bgtask. last {
0 commit comments