test-cleancode: add `benchmark` and `bitfield` (#7613)

pull/7650/head
Lukas Neubert 2020-12-27 14:51:55 +01:00 committed by GitHub
parent e8b5fa2134
commit 6f194f2fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 23 deletions

View File

@ -20,7 +20,9 @@ const (
vfmt_verify_list = [
'cmd/tools/vdoc/vdoc.v',
'cmd/v/v.v',
'vlib/arrays',
'vlib/arrays/',
'vlib/benchmark/',
'vlib/bitfield/',
'vlib/builtin/array.v',
'vlib/builtin/array_test.v',
'vlib/builtin/map.v',

View File

@ -133,25 +133,33 @@ pub fn (b &Benchmark) step_message_with_label_and_duration(label string, msg str
if b.nexpected_steps > 1 {
mut sprogress := ''
if b.nexpected_steps < 10 {
sprogress = if b.no_cstep { 'TMP1/${b.nexpected_steps:1d}' } else {
sprogress = if b.no_cstep {
'TMP1/${b.nexpected_steps:1d}'
} else {
'${b.cstep:1d}/${b.nexpected_steps:1d}'
}
} else if b.nexpected_steps >= 10 && b.nexpected_steps < 100 {
sprogress = if b.no_cstep { 'TMP2/${b.nexpected_steps:2d}' } else {
sprogress = if b.no_cstep {
'TMP2/${b.nexpected_steps:2d}'
} else {
'${b.cstep:2d}/${b.nexpected_steps:2d}'
}
} else if b.nexpected_steps >= 100 && b.nexpected_steps < 1000 {
sprogress = if b.no_cstep { 'TMP3/${b.nexpected_steps:3d}' } else {
sprogress = if b.no_cstep {
'TMP3/${b.nexpected_steps:3d}'
} else {
'${b.cstep:3d}/${b.nexpected_steps:3d}'
}
} else {
sprogress = if b.no_cstep { 'TMP4/${b.nexpected_steps:4d}' } else {
sprogress = if b.no_cstep {
'TMP4/${b.nexpected_steps:4d}'
} else {
'${b.cstep:4d}/${b.nexpected_steps:4d}'
}
}
return '${label:-5s} [${sprogress}] ${timed_line}'
return '${label:-5s} [$sprogress] $timed_line'
}
return '${label:-5s}${timed_line}'
return '${label:-5s}$timed_line'
}
// step_message_with_label returns a string describing the current step using current time as duration.
@ -181,7 +189,9 @@ pub fn (b &Benchmark) step_message_skip(msg string) string {
// total_message returns a string with total summary of the benchmark run.
pub fn (b &Benchmark) total_message(msg string) string {
mut tmsg := '${msg}\n ok, fail, skip, total = ' + term.ok_message('${b.nok:5d}') + ', ' + if b.nfail > 0 { term.red('${b.nfail:5d}') } else { '${b.nfail:5d}' } + ', ' + if b.nskip > 0 { term.bright_yellow('${b.nskip:5d}') } else { '${b.nskip:5d}' } + ', ' + '${b.ntotal:5d}'
mut tmsg := '$msg\n ok, fail, skip, total = ' + term.ok_message('${b.nok:5d}') +
', ' + if b.nfail > 0 { term.red('${b.nfail:5d}') } else { '${b.nfail:5d}' } + ', ' + if b.nskip >
0 { term.bright_yellow('${b.nskip:5d}') } else { '${b.nskip:5d}' } + ', ' + '${b.ntotal:5d}'
if b.verbose {
tmsg = '<=== total time spent $tmsg'
}