From 57b3b86e0a00720d58f55b3bccba83c57ec9ce35 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Sun, 19 Jul 2026 06:38:36 +1000 Subject: [PATCH] runtests: report total elapsed seconds in all report styles The '### runtests DONE at ' human line gains '(elapsed s)', the RUNTESTS_RESULT summary line gains a trailing elapsed_seconds= key=value, and the json report gains a top-level "elapsed_seconds" field - matching the name already used by the watch-mode run-end event, which now shares the same computed value. Additive only; the parity tool reads named keys and is unaffected (verified on all three report styles). Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.com --- src/tests/runtests.tcl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tests/runtests.tcl b/src/tests/runtests.tcl index 503b8d0b..e86b461c 100644 --- a/src/tests/runtests.tcl +++ b/src/tests/runtests.tcl @@ -81,12 +81,13 @@ proc runtests_dict_get_default {dictvalue key default} { return $default } -proc runtests_json_report {status tallydict file_summaries slowest_tests} { +proc runtests_json_report {status tallydict file_summaries slowest_tests elapsed_seconds} { set files_failed [dict get $tallydict files_with_fails] set files_warned [dict get $tallydict files_with_warnings] set fields [list] lappend fields "\"runner\":\"src/tests/runtests.tcl\"" lappend fields "\"status\":[runtests_json_string $status]" + lappend fields "\"elapsed_seconds\":$elapsed_seconds" lappend fields "\"total\":[dict get $tallydict total]" lappend fields "\"passed\":[dict get $tallydict passed]" lappend fields "\"skipped\":[dict get $tallydict skipped]" @@ -127,8 +128,8 @@ proc runtests_status {tallydict} { return pass } -proc runtests_emit_result_line {status tallydict file_summaries} { - puts stdout "RUNTESTS_RESULT status=$status total=[dict get $tallydict total] passed=[dict get $tallydict passed] skipped=[dict get $tallydict skipped] failed=[dict get $tallydict failed] warnings=[llength [dict get $tallydict files_with_warnings]] files=[llength $file_summaries] files_failed=[llength [dict get $tallydict files_with_fails]]" +proc runtests_emit_result_line {status tallydict file_summaries elapsed_seconds} { + puts stdout "RUNTESTS_RESULT status=$status total=[dict get $tallydict total] passed=[dict get $tallydict passed] skipped=[dict get $tallydict skipped] failed=[dict get $tallydict failed] warnings=[llength [dict get $tallydict files_with_warnings]] files=[llength $file_summaries] files_failed=[llength [dict get $tallydict files_with_fails]] elapsed_seconds=$elapsed_seconds" } proc runtests_warning_summary {code message summaryline_detected} { @@ -1255,18 +1256,19 @@ foreach testfile_relative $testfiles { } set status [runtests_status $tallydict] set slowest_tests [runtests_slowest_tests $all_passes $opt_slowest] +set elapsed_seconds [expr {[clock seconds] - $ts_start}] if {$jobs_mode} { dict set runtests_phase_times processing_s [format %.1f [expr {([clock milliseconds] - $_phase_t2) / 1000.0}]] if {!$report_json_only} { puts stdout "jobs phase times: parallel [dict get $runtests_phase_times parallel_s]s, serial tail [dict get $runtests_phase_times serial_s]s, processing [dict get $runtests_phase_times processing_s]s" } } -runtests_udptee_event run-end status $status total [dict get $tallydict total] passed [dict get $tallydict passed] skipped [dict get $tallydict skipped] failed [dict get $tallydict failed] files [llength $file_summaries] elapsed_seconds [expr {[clock seconds] - $ts_start}] {*}$runtests_phase_times +runtests_udptee_event run-end status $status total [dict get $tallydict total] passed [dict get $tallydict passed] skipped [dict get $tallydict skipped] failed [dict get $tallydict failed] files [llength $file_summaries] elapsed_seconds $elapsed_seconds {*}$runtests_phase_times if {!$report_json_only} { puts stdout "## runtests summary" puts stdout "" - runtests_emit_result_line $status $tallydict $file_summaries + runtests_emit_result_line $status $tallydict $file_summaries $elapsed_seconds puts stdout "" } @@ -1374,7 +1376,7 @@ if {$report_emit_json} { puts stdout "" puts stdout "```json" } - puts stdout [runtests_json_report $status $tallydict $file_summaries $slowest_tests] + puts stdout [runtests_json_report $status $tallydict $file_summaries $slowest_tests $elapsed_seconds] if {!$report_json_only} { puts stdout "```" puts stdout "" @@ -1382,7 +1384,7 @@ if {$report_emit_json} { } if {!$report_json_only} { - puts stdout "### runtests DONE at [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]" + puts stdout "### runtests DONE at [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"] (elapsed ${elapsed_seconds}s)" puts stdout "" }