From dad5a5e774585ab2041c3f24f26beed42624073a Mon Sep 17 00:00:00 2001 From: zakuro Date: Fri, 19 Mar 2021 19:37:44 +0900 Subject: [PATCH] v test-cleancode: add -fix flag (#9364) --- cmd/tools/vtest-cleancode.v | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/tools/vtest-cleancode.v b/cmd/tools/vtest-cleancode.v index d2ecca4c44..90194192f1 100644 --- a/cmd/tools/vtest-cleancode.v +++ b/cmd/tools/vtest-cleancode.v @@ -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')