| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | import testing |
| 5 | import v.util |
| 6 | |
| 7 | const known_failing_exceptions = []string{} |
| 8 | |
| 9 | fn main() { |
| 10 | args_string := os.args[1..].join(' ') |
| 11 | v_test_formatting(args_string.all_before('test-fmt')) |
| 12 | } |
| 13 | |
| 14 | fn 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 | |
| 29 | fn 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 | |