@@ -54,6 +54,7 @@ pub(crate) struct DisplayReporterBuilder {
5454 pub ( crate ) failure_output : Option < TestOutputDisplay > ,
5555 pub ( crate ) should_colorize : bool ,
5656 pub ( crate ) no_capture : bool ,
57+ pub ( crate ) verbose : bool ,
5758 pub ( crate ) show_progress : ShowProgress ,
5859 pub ( crate ) no_output_indent : bool ,
5960 pub ( crate ) max_progress_running : MaxProgressRunning ,
@@ -141,6 +142,7 @@ impl DisplayReporterBuilder {
141142 final_status_level : self . status_levels . final_status_level ,
142143 } ,
143144 no_capture : self . no_capture ,
145+ verbose : self . verbose ,
144146 no_output_indent : self . no_output_indent ,
145147 counter_width,
146148 styles,
@@ -377,6 +379,7 @@ struct DisplayReporterImpl<'a> {
377379 default_filter : CompiledDefaultFilter ,
378380 status_levels : StatusLevels ,
379381 no_capture : bool ,
382+ verbose : bool ,
380383 no_output_indent : bool ,
381384 // None if no counter is displayed. If a counter is displayed, this is the
382385 // width of the total number of tests to run.
@@ -623,6 +626,10 @@ impl<'a> DisplayReporterImpl<'a> {
623626 ) ,
624627 ) ?;
625628 }
629+
630+ if self . verbose {
631+ self . write_test_command_line ( test_instance, writer) ?;
632+ }
626633 }
627634 TestEventKind :: TestSlow {
628635 stress_index,
@@ -1312,6 +1319,28 @@ impl<'a> DisplayReporterImpl<'a> {
13121319 Ok ( ( ) )
13131320 }
13141321
1322+ fn write_test_command_line (
1323+ & self ,
1324+ test_instance : & TestInstance < ' a > ,
1325+ writer : & mut dyn WriteStr ,
1326+ ) -> io:: Result < ( ) > {
1327+ // Display the command line that will be used to run this test.
1328+ // Format: binary_path --exact test_name --nocapture [--ignored]
1329+ write ! (
1330+ writer,
1331+ "{:>12} {} --exact {} --nocapture" ,
1332+ "COMMAND" . style( self . styles. count) ,
1333+ test_instance. suite_info. binary_path,
1334+ test_instance. name,
1335+ ) ?;
1336+ if test_instance. test_info . ignored {
1337+ write ! ( writer, " --ignored" ) ?;
1338+ }
1339+ writeln ! ( writer) ?;
1340+
1341+ Ok ( ( ) )
1342+ }
1343+
13151344 fn write_setup_script_status_line (
13161345 & self ,
13171346 stress_index : Option < StressIndex > ,
@@ -2360,10 +2389,29 @@ mod tests {
23602389 use smol_str:: SmolStr ;
23612390 use std:: { num:: NonZero , sync:: Arc } ;
23622391
2392+ fn default_builder ( ) -> DisplayReporterBuilder {
2393+ DisplayReporterBuilder {
2394+ default_filter : CompiledDefaultFilter :: for_default_config ( ) ,
2395+ status_levels : StatusLevels {
2396+ status_level : StatusLevel :: Fail ,
2397+ final_status_level : FinalStatusLevel :: Fail ,
2398+ } ,
2399+ test_count : 5000 ,
2400+ success_output : Some ( TestOutputDisplay :: Immediate ) ,
2401+ failure_output : Some ( TestOutputDisplay :: Immediate ) ,
2402+ should_colorize : false ,
2403+ no_capture : true ,
2404+ verbose : false ,
2405+ show_progress : ShowProgress :: Counter ,
2406+ no_output_indent : false ,
2407+ max_progress_running : MaxProgressRunning :: default ( ) ,
2408+ }
2409+ }
2410+
23632411 /// Creates a test reporter with default settings and calls the given function with it.
23642412 ///
23652413 /// Returns the output written to the reporter.
2366- fn with_reporter < ' a , F > ( f : F , out : & ' a mut String )
2414+ fn with_reporter < ' a , F > ( builder : DisplayReporterBuilder , f : F , out : & ' a mut String )
23672415 where
23682416 F : FnOnce ( DisplayReporter < ' a > ) ,
23692417 {
@@ -2379,21 +2427,6 @@ mod tests {
23792427 )
23802428 . unwrap ( ) ;
23812429
2382- let builder = DisplayReporterBuilder {
2383- default_filter : CompiledDefaultFilter :: for_default_config ( ) ,
2384- status_levels : StatusLevels {
2385- status_level : StatusLevel :: Fail ,
2386- final_status_level : FinalStatusLevel :: Fail ,
2387- } ,
2388- test_count : 5000 ,
2389- success_output : Some ( TestOutputDisplay :: Immediate ) ,
2390- failure_output : Some ( TestOutputDisplay :: Immediate ) ,
2391- should_colorize : false ,
2392- no_capture : true ,
2393- show_progress : ShowProgress :: Counter ,
2394- no_output_indent : false ,
2395- max_progress_running : MaxProgressRunning :: default ( ) ,
2396- } ;
23972430 let output = ReporterStderr :: Buffer ( out) ;
23982431 let reporter = builder. build ( & configs, output) ;
23992432 f ( reporter) ;
@@ -2452,6 +2485,7 @@ mod tests {
24522485 let mut out = String :: new ( ) ;
24532486
24542487 with_reporter (
2488+ default_builder ( ) ,
24552489 |mut reporter| {
24562490 // TODO: write a bunch more outputs here.
24572491 reporter
@@ -2508,6 +2542,7 @@ mod tests {
25082542 let mut out = String :: new ( ) ;
25092543
25102544 with_reporter (
2545+ default_builder ( ) ,
25112546 |mut reporter| {
25122547 // Test single run with all passing tests
25132548 let run_stats_success = RunStats {
@@ -2685,6 +2720,7 @@ mod tests {
26852720 let mut out = String :: new ( ) ;
26862721
26872722 with_reporter (
2723+ default_builder ( ) ,
26882724 |mut reporter| {
26892725 // Info started event.
26902726 reporter
@@ -3130,6 +3166,7 @@ mod tests {
31303166 let mut out = String :: new ( ) ;
31313167
31323168 with_reporter (
3169+ default_builder ( ) ,
31333170 |reporter| {
31343171 assert ! ( reporter. inner. no_capture, "no_capture is true" ) ;
31353172 assert_eq ! (
@@ -3151,6 +3188,35 @@ mod tests {
31513188 & mut out,
31523189 ) ;
31533190 }
3191+
3192+ #[ test]
3193+ fn test_verbose_flag ( ) {
3194+ // Test with verbose = false
3195+ let mut out_non_verbose = String :: new ( ) ;
3196+ let builder = default_builder ( ) ;
3197+ with_reporter (
3198+ builder,
3199+ |reporter| {
3200+ assert ! (
3201+ !reporter. inner. verbose,
3202+ "verbose should be false when not set"
3203+ ) ;
3204+ } ,
3205+ & mut out_non_verbose,
3206+ ) ;
3207+
3208+ // Test with verbose = true
3209+ let mut out_verbose = String :: new ( ) ;
3210+ let mut builder_verbose = default_builder ( ) ;
3211+ builder_verbose. verbose = true ;
3212+ with_reporter (
3213+ builder_verbose,
3214+ |reporter| {
3215+ assert ! ( reporter. inner. verbose, "verbose should be true when set" ) ;
3216+ } ,
3217+ & mut out_verbose,
3218+ ) ;
3219+ }
31543220}
31553221
31563222#[ cfg( all( windows, test) ) ]
0 commit comments