tests: show the number of parallel jobs used while testing

pull/12153/head
Delyan Angelov 2021-10-11 13:10:55 +03:00
parent 1831eccd5e
commit ceb24bc32e
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 13 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import benchmark
import sync.pool
import v.pref
import v.util.vtest
import runtime
const github_job = os.getenv('GITHUB_JOB')
@ -233,6 +234,7 @@ pub fn (mut ts TestSession) test() {
remaining_files = vtest.filter_vtest_only(remaining_files, fix_slashes: false)
ts.files = remaining_files
ts.benchmark.set_total_expected_steps(remaining_files.len)
ts.benchmark.njobs = runtime.nr_jobs()
mut pool_of_test_runners := pool.new_pool_processor(callback: worker_trunner)
// for handling messages across threads
ts.nmessages = chan LogMessage{cap: 10000}
@ -266,6 +268,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
p.set_thread_context(idx, tls_bench)
}
tls_bench.no_cstep = true
tls_bench.njobs = ts.benchmark.njobs
mut relative_file := os.real_path(p.get_item<string>(idx))
mut cmd_options := [ts.vargs]
mut run_js := false

View File

@ -21,6 +21,7 @@ pub mut:
nfail int
nskip int
nexpected_steps int
njobs int
cstep int
bok string
bfail string
@ -200,7 +201,15 @@ pub fn (b &Benchmark) total_message(msg string) string {
if b.nskip > 0 {
tmsg += term.colorize(term.bold, term.colorize(term.yellow, '$b.nskip skipped')) + ', '
}
tmsg += '$b.ntotal total. ${term.colorize(term.bold, 'Runtime:')} ${b.bench_timer.elapsed().microseconds() / 1000} ms.\n'
mut njobs_label := ''
if b.njobs > 0 {
if b.njobs == 1 {
njobs_label = ', on ${term.colorize(term.bold, 1.str())} job'
} else {
njobs_label = ', on ${term.colorize(term.bold, b.njobs.str())} parallel jobs'
}
}
tmsg += '$b.ntotal total. ${term.colorize(term.bold, 'Runtime:')} ${b.bench_timer.elapsed().microseconds() / 1000} ms${njobs_label}.\n'
return tmsg
}