tests: show the number of parallel jobs used while testing
parent
1831eccd5e
commit
ceb24bc32e
|
@ -7,6 +7,7 @@ import benchmark
|
||||||
import sync.pool
|
import sync.pool
|
||||||
import v.pref
|
import v.pref
|
||||||
import v.util.vtest
|
import v.util.vtest
|
||||||
|
import runtime
|
||||||
|
|
||||||
const github_job = os.getenv('GITHUB_JOB')
|
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)
|
remaining_files = vtest.filter_vtest_only(remaining_files, fix_slashes: false)
|
||||||
ts.files = remaining_files
|
ts.files = remaining_files
|
||||||
ts.benchmark.set_total_expected_steps(remaining_files.len)
|
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)
|
mut pool_of_test_runners := pool.new_pool_processor(callback: worker_trunner)
|
||||||
// for handling messages across threads
|
// for handling messages across threads
|
||||||
ts.nmessages = chan LogMessage{cap: 10000}
|
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)
|
p.set_thread_context(idx, tls_bench)
|
||||||
}
|
}
|
||||||
tls_bench.no_cstep = true
|
tls_bench.no_cstep = true
|
||||||
|
tls_bench.njobs = ts.benchmark.njobs
|
||||||
mut relative_file := os.real_path(p.get_item<string>(idx))
|
mut relative_file := os.real_path(p.get_item<string>(idx))
|
||||||
mut cmd_options := [ts.vargs]
|
mut cmd_options := [ts.vargs]
|
||||||
mut run_js := false
|
mut run_js := false
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub mut:
|
||||||
nfail int
|
nfail int
|
||||||
nskip int
|
nskip int
|
||||||
nexpected_steps int
|
nexpected_steps int
|
||||||
|
njobs int
|
||||||
cstep int
|
cstep int
|
||||||
bok string
|
bok string
|
||||||
bfail string
|
bfail string
|
||||||
|
@ -200,7 +201,15 @@ pub fn (b &Benchmark) total_message(msg string) string {
|
||||||
if b.nskip > 0 {
|
if b.nskip > 0 {
|
||||||
tmsg += term.colorize(term.bold, term.colorize(term.yellow, '$b.nskip skipped')) + ', '
|
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
|
return tmsg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue