mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
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)
This commit is contained in:
parent
abcebfed68
commit
99a587af95
4 changed files with 55 additions and 6 deletions
|
@ -2,9 +2,19 @@ module testing
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import term
|
import term
|
||||||
|
import os
|
||||||
|
|
||||||
pub const empty = term.header(' ', ' ')
|
pub const empty = term.header(' ', ' ')
|
||||||
|
|
||||||
|
// TODO: AGAIN --- this !!!*reliably*!!! fails compilation of `v cmd/tools/vbuild-examples.v` with a cgen error, without `-no-parallel`:
|
||||||
|
// pub const report_running_period_ms = os.getenv_opt('VTEST_REPORT_RUNNING_PERIOD_MS') or { '60000' }.int() * time.millisecond
|
||||||
|
|
||||||
|
pub const report_running_period_ms = get_report_running_period_ms()
|
||||||
|
|
||||||
|
fn get_report_running_period_ms() time.Duration {
|
||||||
|
return os.getenv_opt('VTEST_REPORT_RUNNING_PERIOD_MS') or { '60000' }.int() * time.millisecond
|
||||||
|
}
|
||||||
|
|
||||||
// NormalReporter implements the interface testing.Reporter.
|
// NormalReporter implements the interface testing.Reporter.
|
||||||
// It is used by default by `v test .`
|
// It is used by default by `v test .`
|
||||||
// It was extracted by the original non customiseable output implementation directly in cmd/tools/modules/testing/common.v
|
// It was extracted by the original non customiseable output implementation directly in cmd/tools/modules/testing/common.v
|
||||||
|
@ -12,13 +22,39 @@ pub struct NormalReporter {
|
||||||
mut:
|
mut:
|
||||||
runtime time.Duration
|
runtime time.Duration
|
||||||
comptime time.Duration
|
comptime time.Duration
|
||||||
|
running shared map[string]LogMessage
|
||||||
|
nfiles int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (r NormalReporter) session_start(message string, mut ts TestSession) {
|
pub fn (mut r NormalReporter) session_start(message string, mut ts TestSession) {
|
||||||
header(message)
|
header(message)
|
||||||
|
r.nfiles = ts.files.len
|
||||||
|
spawn r.report_current_running_status_periodically()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (r NormalReporter) session_stop(message string, mut ts TestSession) {
|
fn (r &NormalReporter) report_current_running_status_periodically() {
|
||||||
|
if report_running_period_ms == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mut start_t := time.now()
|
||||||
|
mut pi := 0
|
||||||
|
mut crunning := map[string]LogMessage{}
|
||||||
|
for {
|
||||||
|
pi++
|
||||||
|
time.sleep(report_running_period_ms)
|
||||||
|
t := time.now()
|
||||||
|
rlock r.running {
|
||||||
|
crunning = r.running.clone()
|
||||||
|
}
|
||||||
|
keys := crunning.keys()
|
||||||
|
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'}')
|
||||||
|
for ik, k in keys {
|
||||||
|
eprintln(' >>>>> ${ik + 1:4}/${keys.len:-4}, T: ${crunning[k].flow_id:3}, started: ${t - crunning[k].when:10} ago, `${k}`')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (r &NormalReporter) session_stop(message string, mut ts TestSession) {
|
||||||
println('${ts.benchmark.total_message(message)} Comptime: ${r.comptime.microseconds() / 1000} ms. Runtime: ${r.runtime.microseconds() / 1000} ms.')
|
println('${ts.benchmark.total_message(message)} Comptime: ${r.comptime.microseconds() / 1000} ms. Runtime: ${r.runtime.microseconds() / 1000} ms.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +68,16 @@ pub fn (mut r NormalReporter) report(index int, message LogMessage) {
|
||||||
if message.kind == .cmd_end {
|
if message.kind == .cmd_end {
|
||||||
r.runtime += message.took
|
r.runtime += message.took
|
||||||
}
|
}
|
||||||
|
if message.kind == .cmd_begin {
|
||||||
|
lock r.running {
|
||||||
|
r.running[message.file] = message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if message.kind == .cmd_end {
|
||||||
|
lock r.running {
|
||||||
|
r.running.delete(message.file)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (r NormalReporter) report_stop() {
|
pub fn (r NormalReporter) report_stop() {
|
||||||
|
|
|
@ -429,7 +429,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
// dump(cfg)
|
// dump(cfg)
|
||||||
title := 'testing: ${cfg.test_dirs.join(', ')}'
|
title := 'testing: ${cfg.test_dirs.join(', ')}'
|
||||||
testing.eheader(title)
|
|
||||||
mut tpaths := map[string]bool{}
|
mut tpaths := map[string]bool{}
|
||||||
mut tpaths_ref := &tpaths
|
mut tpaths_ref := &tpaths
|
||||||
for dir in cfg.test_dirs {
|
for dir in cfg.test_dirs {
|
||||||
|
@ -541,10 +540,11 @@ fn main() {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
tsession.skip_files = tsession.skip_files.map(os.abs_path)
|
tsession.skip_files = tsession.skip_files.map(os.abs_path)
|
||||||
|
tsession.session_start(title)
|
||||||
tsession.test()
|
tsession.test()
|
||||||
eprintln(tsession.benchmark.total_message(title))
|
tsession.session_stop(title)
|
||||||
if tsession.benchmark.nfail > 0 {
|
if tsession.benchmark.nfail > 0 {
|
||||||
eprintln('\nWARNING: failed ${tsession.benchmark.nfail} times.\n')
|
eprintln('\nError: failed ${tsession.benchmark.nfail} times.\n')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ const c_verror_message_marker = 'VERROR_MESSAGE '
|
||||||
|
|
||||||
const current_os = os.user_os()
|
const current_os = os.user_os()
|
||||||
|
|
||||||
|
const c_compilation_error_title = 'C compilation error'
|
||||||
|
|
||||||
fn (mut v Builder) show_c_compiler_output(ccompiler string, res os.Result) {
|
fn (mut v Builder) show_c_compiler_output(ccompiler string, res os.Result) {
|
||||||
header := '======== Output of the C Compiler (${ccompiler}) ========'
|
header := '======== Output of the C Compiler (${ccompiler}) ========'
|
||||||
println(header)
|
println(header)
|
||||||
|
@ -58,7 +60,7 @@ fn (mut v Builder) post_process_c_compiler_output(ccompiler string, res os.Resul
|
||||||
trimmed_output := res.output.trim_space()
|
trimmed_output := res.output.trim_space()
|
||||||
original_elines := trimmed_output.split_into_lines()
|
original_elines := trimmed_output.split_into_lines()
|
||||||
elines := error_context_lines(trimmed_output, 'error:', 1, 12)
|
elines := error_context_lines(trimmed_output, 'error:', 1, 12)
|
||||||
header := '================== C compilation error (from ${ccompiler}): =============='
|
header := '================== ${c_compilation_error_title} (from ${ccompiler}): =============='
|
||||||
println(header)
|
println(header)
|
||||||
for eline in elines {
|
for eline in elines {
|
||||||
println('cc: ${eline}')
|
println('cc: ${eline}')
|
||||||
|
|
|
@ -373,6 +373,7 @@ pub fn (mut v Builder) cc_msvc() {
|
||||||
util.timing_start('C msvc')
|
util.timing_start('C msvc')
|
||||||
res := os.execute(cmd)
|
res := os.execute(cmd)
|
||||||
if res.exit_code != 0 {
|
if res.exit_code != 0 {
|
||||||
|
eprintln('================== ${c_compilation_error_title} (from msvc): ==============')
|
||||||
eprintln(res.output)
|
eprintln(res.output)
|
||||||
verror('msvc error')
|
verror('msvc error')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue