1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

testing: fix count of succeeded tests

This commit is contained in:
Kris Cherven
2020-04-17 22:49:03 -04:00
committed by GitHub
parent 5374899f29
commit eb923b4995
2 changed files with 58 additions and 12 deletions

View File

@@ -65,6 +65,7 @@ pub mut:
verbose bool
nexpected_steps int
cstep int
no_cstep bool
bok string
bfail string
}
@@ -76,6 +77,14 @@ pub fn new_benchmark() Benchmark {
}
}
pub fn new_benchmark_no_cstep() Benchmark {
return Benchmark{
bench_start_time: benchmark.now()
verbose: true
no_cstep: true
}
}
pub fn new_benchmark_pointer() &Benchmark {
return &Benchmark{
bench_start_time: benchmark.now()
@@ -93,7 +102,9 @@ pub fn (b mut Benchmark) stop() {
pub fn (b mut Benchmark) step() {
b.step_start_time = benchmark.now()
b.cstep++
if !b.no_cstep {
b.cstep++
}
}
pub fn (b mut Benchmark) fail() {
@@ -149,13 +160,19 @@ pub fn (b &Benchmark) step_message_with_label(label string, msg string) string {
if b.nexpected_steps > 0 {
mut sprogress := ''
if b.nexpected_steps < 10 {
sprogress = '${b.cstep:1d}/${b.nexpected_steps:1d}'
sprogress = if b.no_cstep { 'TMP1/${b.nexpected_steps:1d}' } else {
'${b.cstep:1d}/${b.nexpected_steps:1d}'
}
}
if b.nexpected_steps >= 10 && b.nexpected_steps < 100 {
sprogress = '${b.cstep:2d}/${b.nexpected_steps:2d}'
sprogress = if b.no_cstep { 'TMP2/${b.nexpected_steps:2d}' } else {
'${b.cstep:2d}/${b.nexpected_steps:2d}'
}
}
if b.nexpected_steps >= 100 && b.nexpected_steps < 1000 {
sprogress = '${b.cstep:3d}/${b.nexpected_steps:3d}'
sprogress = if b.no_cstep { 'TMP3/${b.nexpected_steps:3d}' } else {
'${b.cstep:3d}/${b.nexpected_steps:3d}'
}
}
timed_line = b.tdiff_in_ms('[${sprogress}] $msg', b.step_start_time, b.step_end_time)
}