Skip to content

Commit 10281be

Browse files
Adds a summary for tests (#2745)
``` Test Summary: 100 passed, 2 failed !!! WARNING The following tests failed: ... ```` --------- Signed-off-by: Sarthak Aggarwal <[email protected]>
1 parent f3b2dee commit 10281be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_helper.tcl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ proc test_server_main {} {
375375
array set ::clients_start_time {}
376376
set ::clients_time_history {}
377377
set ::failed_tests {}
378+
set ::ok_count 0
379+
set ::err_count 0
378380

379381
# Enter the event loop to handle clients I/O
380382
after 100 test_server_cron
@@ -404,6 +406,7 @@ proc test_server_cron {} {
404406
set file $::active_clients_file($fd)
405407
}
406408
lappend ::failed_tests "\[[colorstr red TIMEOUT]\]: $test_name in $file"
409+
incr ::err_count
407410
}
408411
}
409412
}
@@ -461,6 +464,7 @@ proc read_from_test_client fd {
461464
if {!$::quiet} {
462465
puts "\[[colorstr green $status]\]: $data ($elapsed ms)"
463466
}
467+
incr ::ok_count
464468
set ::active_clients_task($fd) "(OK) $data"
465469
} elseif {$status eq {skip}} {
466470
if {!$::quiet} {
@@ -474,6 +478,7 @@ proc read_from_test_client fd {
474478
set err "\[[colorstr red $status]\]: $data"
475479
puts $err
476480
lappend ::failed_tests $err
481+
incr ::err_count
477482
set ::active_clients_task($fd) "(ERR) $data"
478483
if {$::exit_on_failure} {
479484
puts "(Fast fail: test will exit now)"
@@ -593,13 +598,18 @@ proc signal_idle_client fd {
593598

594599
# The the_end function gets called when all the test units were already
595600
# executed, so the test finished.
601+
proc print_test_summary {} {
602+
puts "\nTest Summary: [colorstr bold-green $::ok_count] passed, [colorstr bold-red $::err_count] failed"
603+
}
604+
596605
proc the_end {} {
597606
# TODO: print the status, exit with the right exit code.
598607
puts "\n The End\n"
599608
puts "Execution time of different units:"
600609
foreach {time name} $::clients_time_history {
601610
puts " $time seconds - $name"
602611
}
612+
print_test_summary
603613
if {[llength $::failed_tests]} {
604614
puts "\n[colorstr bold-red {!!! WARNING}] The following tests failed:\n"
605615
foreach failed $::failed_tests {

0 commit comments

Comments
 (0)