Skip to content

Commit 99a587a

Browse files
authored
tools: let v test . show the running _test.v files each minute (set by VTEST_REPORT_RUNNING_PERIOD_MS); diagnose stuck windows gcc CI jobs (#23649)
1 parent abcebfe commit 99a587a

4 files changed

Lines changed: 55 additions & 6 deletions

File tree

‎cmd/tools/modules/testing/output_normal.v‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,59 @@ module testing
22

33
import time
44
import term
5+
import os
56

67
pub 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
1121
pub struct NormalReporter {
1222
mut:
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
3783
pub fn (r NormalReporter) report_stop() {

‎cmd/tools/vtest-self.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ fn main() {
429429
}
430430
// dump(cfg)
431431
title := 'testing: ${cfg.test_dirs.join(', ')}'
432-
testing.eheader(title)
433432
mut tpaths := map[string]bool{}
434433
mut tpaths_ref := &tpaths
435434
for dir in cfg.test_dirs {
@@ -541,10 +540,11 @@ fn main() {
541540
exit(1)
542541
}
543542
tsession.skip_files = tsession.skip_files.map(os.abs_path)
543+
tsession.session_start(title)
544544
tsession.test()
545-
eprintln(tsession.benchmark.total_message(title))
545+
tsession.session_stop(title)
546546
if tsession.benchmark.nfail > 0 {
547-
eprintln('\nWARNING: failed ${tsession.benchmark.nfail} times.\n')
547+
eprintln('\nError: failed ${tsession.benchmark.nfail} times.\n')
548548
exit(1)
549549
}
550550
}

‎vlib/v/builder/cc.v‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const c_verror_message_marker = 'VERROR_MESSAGE '
1919

2020
const current_os = os.user_os()
2121

22+
const c_compilation_error_title = 'C compilation error'
23+
2224
fn (mut v Builder) show_c_compiler_output(ccompiler string, res os.Result) {
2325
header := '======== Output of the C Compiler (${ccompiler}) ========'
2426
println(header)
@@ -58,7 +60,7 @@ fn (mut v Builder) post_process_c_compiler_output(ccompiler string, res os.Resul
5860
trimmed_output := res.output.trim_space()
5961
original_elines := trimmed_output.split_into_lines()
6062
elines := error_context_lines(trimmed_output, 'error:', 1, 12)
61-
header := '================== C compilation error (from ${ccompiler}): =============='
63+
header := '================== ${c_compilation_error_title} (from ${ccompiler}): =============='
6264
println(header)
6365
for eline in elines {
6466
println('cc: ${eline}')

‎vlib/v/builder/msvc_windows.v‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ pub fn (mut v Builder) cc_msvc() {
373373
util.timing_start('C msvc')
374374
res := os.execute(cmd)
375375
if res.exit_code != 0 {
376+
eprintln('================== ${c_compilation_error_title} (from msvc): ==============')
376377
eprintln(res.output)
377378
verror('msvc error')
378379
}

0 commit comments

Comments
 (0)