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