@@ -516,18 +516,6 @@ t_entry_point(CmdLine *cmdline)
516516 {
517517 radsort (g_torture_tests , g_torture_test_count , t_test_is_before );
518518
519- U64 max_label_size = 0 ;
520- U64 max_group_size = 0 ;
521- for EachIndex (i , g_torture_test_count ) {
522- max_label_size = Max (max_label_size , cstring8_length ((U8 * )g_torture_tests [i ].label ));
523- max_group_size = Max (max_group_size , cstring8_length ((U8 * )g_torture_tests [i ].group ));
524- }
525-
526- U64 dots_min = 10 ;
527- U64 dots_size = max_label_size + dots_min ;
528- U8 * dots = push_array (scratch .arena , U8 , dots_size );
529- MemorySet (dots , '.' , dots_size );
530-
531519 U64 target_indices_count ;
532520 U64 * target_indices ;
533521 if (target .node_count == 0 ) {
@@ -553,16 +541,33 @@ t_entry_point(CmdLine *cmdline)
553541 }
554542 }
555543
544+ U64 max_label_size = 0 ;
545+ U64 max_group_size = 0 ;
546+ for EachIndex (i , target_indices_count ) {
547+ U64 test_idx = target_indices [i ];
548+ max_label_size = Max (max_label_size , cstring8_length ((U8 * )g_torture_tests [test_idx ].label ));
549+ max_group_size = Max (max_group_size , cstring8_length ((U8 * )g_torture_tests [test_idx ].group ));
550+ }
551+
552+ U64 dots_min = 15 ;
553+ U64 dots_size = max_label_size + dots_min ;
554+ U8 * dots = push_array (scratch .arena , U8 , dots_size );
555+ MemorySet (dots , '.' , dots_size );
556+
556557 U64 pass_count = 0 ;
557558 U64 fail_count = 0 ;
558559 U64 crash_count = 0 ;
560+ U64 max_digit_count = count_digits_u64 (target_indices_count , 10 );
561+ U64 total_time_start = os_now_microseconds ();
559562 for EachIndex (i , target_indices_count ) {
560563 U64 target_idx = target_indices [i ];
561564
562565 // print run progress
563566 U64 dots_count = (max_label_size - cstring8_length ((U8 * )g_torture_tests [target_idx ].label )) + dots_min ;
564567 char * spaces = " " ;
565- fprintf (stdout , "[%2I64u/%2I64u] " , i + 1 , target_indices_count );
568+ U64 curr_digit_count = count_digits_u64 (i + 1 , 10 );
569+ int idx_align_space_count = (int )(max_digit_count - curr_digit_count );
570+ fprintf (stdout , "[%.*s%I64u/%I64u] " , idx_align_space_count , spaces , i + 1 , target_indices_count );
566571 fprintf (stdout , "(%s) %.*s%s" , g_torture_tests [target_idx ].group , (int )(max_group_size - cstring8_length ((U8 * )g_torture_tests [target_idx ].group )), spaces , g_torture_tests [target_idx ].label );
567572 fprintf (stdout , "%.*s" , (int )dots_count , dots );
568573
@@ -582,20 +587,30 @@ t_entry_point(CmdLine *cmdline)
582587 }
583588
584589 // run test
590+ U64 run_start_time = os_now_microseconds ();
585591 T_RunResult result = t_run (g_torture_tests [target_idx ].r );
592+ U64 run_end_time = os_now_microseconds ();
586593
587594 // print result
588595 if (result .status == T_RunStatus_Pass ) {
589- fprintf (stdout , "\x1b[32m" "%s" "\x1b[0m" "\n" , t_string_from_result (result .status ));
596+ fprintf (stdout , "\x1b[32m" "%s" "\x1b[0m" , t_string_from_result (result .status ));
590597 pass_count += 1 ;
591598 } else if (result .status == T_RunStatus_Fail ) {
592- fprintf (stdout , "\x1b[31m" "%s" "\x1b[0m" "\n" , t_string_from_result (result .status ));
599+ fprintf (stdout , "\x1b[31m" "%s" "\x1b[0m" , t_string_from_result (result .status ));
593600 fail_count += 1 ;
594601 } else if (result .status == T_RunStatus_Crash ) {
595- fprintf (stdout , "\x1b[33m" "%s" "\x1b[0m" "\n" , t_string_from_result (result .status ));
602+ fprintf (stdout , "\x1b[33m" "%s" "\x1b[0m" , t_string_from_result (result .status ));
596603 crash_count += 1 ;
597604 }
598605
606+ if (result .status == T_RunStatus_Pass ) {
607+ U64 d = run_end_time - run_start_time ;
608+ DateTime t = date_time_from_micro_seconds (d );
609+ String8 s = string_from_elapsed_time (scratch .arena , t );
610+ fprintf (stdout , " | %.*s" , str8_varg (s ));
611+ }
612+ fprintf (stdout , "\n" );
613+
599614 if (result .status == T_RunStatus_Fail ) {
600615 fprintf (stdout , " ERROR: %s:%d: condition: \"%s\"\n" , result .fail_file , result .fail_line , result .fail_cond );
601616 }
@@ -604,8 +619,11 @@ t_entry_point(CmdLine *cmdline)
604619 if (g_stop_on_first_fail_or_crash ) { goto exit ; }
605620 }
606621 }
622+ U64 total_time_end = os_now_microseconds ();
607623
608- fprintf (stdout , "*** Passed: %I64u, Failed: %I64u, Crashed: %I64u ***\n" , pass_count , fail_count , crash_count );
624+ U64 total_time_dt = total_time_end - total_time_start ;
625+ String8 total_time_str = string_from_elapsed_time (scratch .arena , date_time_from_micro_seconds (total_time_dt ));
626+ fprintf (stdout , "*** Passed: %I64u, Failed: %I64u, Crashed: %I64u, Time: %.*s***\n" , pass_count , fail_count , crash_count , str8_varg (total_time_str ));
609627
610628 exit :;
611629 if (fail_count + crash_count != 0 ) {
0 commit comments