@@ -2,23 +2,59 @@ module testing
22
33import time
44import term
5+ import os
56
67pub const empty = term.header (' ' , ' ' )
78
9+ // TODO: AGAIN --- this !!!*reliably*!!! fails compilation of `v cmd/tools/vbuild-examples.v` with a cgen error, without `-no-parallel`:
10+ // pub const report_running_period_ms = os.getenv_opt('VTEST_REPORT_RUNNING_PERIOD_MS') or { '60000' }.int() * time.millisecond
11+
12+ pub const report_running_period_ms = get_report_running_period_ms ()
13+
14+ fn get_report_running_period_ms () time.Duration {
15+ return os.getenv_opt ('VTEST_REPORT_RUNNING_PERIOD_MS' ) or { '60000' }.int () * time.millisecond
16+ }
17+
818// NormalReporter implements the interface testing.Reporter.
919// It is used by default by `v test .`
1020// It was extracted by the original non customiseable output implementation directly in cmd/tools/modules/testing/common.v
1121pub struct NormalReporter {
1222mut :
1323 runtime time.Duration
1424 comptime time.Duration
25+ running shared map [string ]LogMessage
26+ nfiles int
1527}
1628
17- pub fn (r NormalReporter) session_start (message string , mut ts TestSession) {
29+ pub fn (mut r NormalReporter) session_start (message string , mut ts TestSession) {
1830 header (message)
31+ r.nfiles = ts.files.len
32+ spawn r.report_current_running_status_periodically ()
1933}
2034
21- pub fn (r NormalReporter) session_stop (message string , mut ts TestSession) {
35+ fn (r &NormalReporter) report_current_running_status_periodically () {
36+ if report_running_period_ms == 0 {
37+ return
38+ }
39+ mut start_t := time.now ()
40+ mut pi := 0
41+ mut crunning := map [string ]LogMessage{}
42+ for {
43+ pi++
44+ time.sleep (report_running_period_ms)
45+ t := time.now ()
46+ rlock r.running {
47+ crunning = r.running.clone ()
48+ }
49+ keys := crunning.keys ()
50+ eprintln (' >>>>> ${t .format_ss_micro ()} | period ${pi :2 } | started: ${t - start_t :10 } ago | total files: ${r .nfiles :5 } | vjobs: ${' | running ${keys .len } _test.v files' }')
51+ for ik, k in keys {
52+ eprintln(' >>>> > ${ik + 1 :4 }/ ${keys.len:- 4 }, T: ${crunning[k].flow_id:3 }, started: ${t - crunning[k].when:10 } ago, `${k }` ')
53+ }
54+ }
55+ }
56+
57+ pub fn (r &NormalReporter) session_stop(message string, mut ts TestSession) {
2258 println(' ${ts.benchmark.total_message (message)} Comptime: ${r.comptime.microseconds () / 1000 } ms. Runtime: ${r.runtime.microseconds () / 1000 } ms.')
2359}
2460
@@ -32,6 +68,16 @@ pub fn (mut r NormalReporter) report(index int, message LogMessage) {
3268 if message.kind == .cmd_end {
3369 r.runtime += message.took
3470 }
71+ if message.kind == .cmd_begin {
72+ lock r.running {
73+ r.running[message.file] = message
74+ }
75+ }
76+ if message.kind == .cmd_end {
77+ lock r.running {
78+ r.running.delete(message.file)
79+ }
80+ }
3581}
3682
3783pub fn (r NormalReporter) report_stop() {
0 commit comments