v / cmd / tools / vtest-fmt.v
42 lines · 37 sloc · 1.12 KB · eeaaff218bbe695c655a6380963e2f82deadcb94
Raw
1module main
2
3import os
4import testing
5import v.util
6
7const known_failing_exceptions = []string{}
8
9fn main() {
10 args_string := os.args[1..].join(' ')
11 v_test_formatting(args_string.all_before('test-fmt'))
12}
13
14fn v_test_formatting(vargs string) {
15 all_v_files := v_files()
16 util.prepare_tool_when_needed('vfmt.v')
17 testing.eheader('Run "v fmt" over all .v files')
18 mut vfmt_test_session := testing.new_test_session('${vargs} fmt -worker', false)
19 vfmt_test_session.files << all_v_files
20 vfmt_test_session.skip_files << known_failing_exceptions
21 vfmt_test_session.test()
22 eprintln(vfmt_test_session.benchmark.total_message('running vfmt over V files'))
23 if vfmt_test_session.benchmark.nfail > 0 {
24 eprintln('\nWARNING: v fmt failed ${vfmt_test_session.benchmark.nfail} times.\n')
25 exit(1)
26 }
27}
28
29fn v_files() []string {
30 mut files_that_can_be_formatted := []string{}
31 all_test_files := os.walk_ext('.', '.v')
32 for tfile in all_test_files {
33 if tfile.starts_with('./vlib/v/cgen/tests') {
34 continue
35 }
36 if tfile.ends_with('graceful_shutdown_test.v') {
37 continue
38 }
39 files_that_can_be_formatted << tfile
40 }
41 return files_that_can_be_formatted
42}
43