v test-cleancode: add -fix flag (#9364)

pull/9375/head
zakuro 2021-03-19 19:37:44 +09:00 committed by GitHub
parent 29884fa2a9
commit dad5a5e774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -74,9 +74,11 @@ const (
]
)
const vexe = os.getenv('VEXE')
const vroot = os.dir(vexe)
const (
vexe = os.getenv('VEXE')
vroot = os.dir(vexe)
is_fix = '-fix' in os.args
)
fn main() {
args_string := os.args[1..].join(' ')
@ -101,8 +103,8 @@ fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string,
fn v_test_vetting(vargs string) {
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', vet_folders, vet_known_failing_exceptions)
verify_session := tsession(vargs, 'vfmt.v', 'v fmt -verify', 'fmt -verify', vfmt_verify_list,
verify_known_failing_exceptions)
fmt_cmd, fmt_args := if is_fix { 'v fmt -w', 'fmt -w' } else { 'v fmt -verify', 'fmt -verify' }
verify_session := tsession(vargs, 'vfmt.v', fmt_cmd, fmt_args, vfmt_verify_list, verify_known_failing_exceptions)
//
if vet_session.benchmark.nfail > 0 || verify_session.benchmark.nfail > 0 {
eprintln('\n')