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

checker: check for mut val in immutable obj (#8285)

This commit is contained in:
yuyi
2021-01-23 17:40:17 +08:00
committed by GitHub
parent d4f6f5eec4
commit 5ee3fecf60
4 changed files with 115 additions and 34 deletions

View File

@ -4,17 +4,38 @@ import os
import term
import time
const vexe = os.getenv('VEXE')
const vroot = os.dir(vexe)
const args_string = os.args[1..].join(' ')
const vargs = args_string.all_before('test-all')
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
args_string = os.args[1..].join(' ')
vargs = args_string.all_before('test-all')
)
fn main() {
commands := get_all_commands()
commands.summary()
mut commands := get_all_commands()
// summary
sw := time.new_stopwatch({})
for mut cmd in commands {
cmd.run()
}
spent := sw.elapsed().milliseconds()
oks := commands.filter(it.ecode == 0)
fails := commands.filter(it.ecode != 0)
println('')
println(term.header(term.colorize(term.yellow, term.colorize(term.bold, 'Summary of `v test-all`:')),
'-'))
println(term.colorize(term.yellow, 'Total runtime: $spent ms'))
for ocmd in oks {
msg := if ocmd.okmsg != '' { ocmd.okmsg } else { ocmd.line }
println(term.colorize(term.green, '> OK: $msg '))
}
for fcmd in fails {
msg := if fcmd.errmsg != '' { fcmd.errmsg } else { fcmd.line }
println(term.colorize(term.red, '> Failed: $msg '))
}
if fails.len > 0 {
exit(1)
}
}
struct Command {
@ -80,28 +101,3 @@ fn (mut cmd Command) run() {
println(term.colorize(term.yellow, '> Running: "$cmd.line" took: $spent ms.'))
println('')
}
fn (commands []Command) summary() {
sw := time.new_stopwatch({})
for mut cmd in commands {
cmd.run()
}
spent := sw.elapsed().milliseconds()
oks := commands.filter(it.ecode == 0)
fails := commands.filter(it.ecode != 0)
println('')
println(term.header(term.colorize(term.yellow, term.colorize(term.bold, 'Summary of `v test-all`:')),
'-'))
println(term.colorize(term.yellow, 'Total runtime: $spent ms'))
for ocmd in oks {
msg := if ocmd.okmsg != '' { ocmd.okmsg } else { ocmd.line }
println(term.colorize(term.green, '> OK: $msg '))
}
for fcmd in fails {
msg := if fcmd.errmsg != '' { fcmd.errmsg } else { fcmd.line }
println(term.colorize(term.red, '> Failed: $msg '))
}
if fails.len > 0 {
exit(1)
}
}