| 1 | module main |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | const vexe = @VEXE |
| 6 | |
| 7 | const known_skip_patterns_env = os.getenv('VKNOWN_SKIP_PATTERNS') |
| 8 | |
| 9 | const known_folder_patterns_that_are_not_module_ones = [ |
| 10 | 'vlib/sync/bench', |
| 11 | '/tests', |
| 12 | '/testdata', |
| 13 | '/preludes_js', |
| 14 | 'vlib/builtin/js', // TODO: fix compiler panic |
| 15 | 'vlib/fontstash', // used by `gg` |
| 16 | 'vlib/sokol/sfons', // used by `gg`, and by examples/sokol/fonts.v |
| 17 | 'vlib/sokol/sapp', // used by `gg`, and many examples/ |
| 18 | 'vlib/sokol/gfx', // used by `gg`, `x.ttf` |
| 19 | 'vlib/sokol/sgl', // used by `gg` |
| 20 | 'vlib/toml', // toml is well tested, even if the top level folder does not have _test.v files, the ones below do |
| 21 | 'vlib/v/', // the compiler itself is well tested |
| 22 | ] |
| 23 | |
| 24 | fn main() { |
| 25 | mut places := if os.args.len > 1 { |
| 26 | os.args#[1..] |
| 27 | } else { |
| 28 | eprintln('> check the current folder only by default ...') |
| 29 | ['.'] |
| 30 | } |
| 31 | mut known_skip_patterns := known_folder_patterns_that_are_not_module_ones.clone() |
| 32 | if known_skip_patterns_env != '' { |
| 33 | known_skip_patterns = known_skip_patterns_env.split(',').filter(it != '') |
| 34 | } |
| 35 | for path in places { |
| 36 | eprintln('> Checking folder: `${path}` ...') |
| 37 | mut found := 0 |
| 38 | files := os.walk_ext(path, '.v') |
| 39 | mut v_files := map[string]int{} |
| 40 | mut v_test_files := map[string]int{} |
| 41 | for f in files { |
| 42 | folder := os.to_slash(os.dir(f)) |
| 43 | if known_skip_patterns.any(f.contains(it)) { |
| 44 | continue |
| 45 | } |
| 46 | if f.ends_with('.v') { |
| 47 | v_files[folder]++ |
| 48 | } |
| 49 | if f.ends_with('_test.v') { |
| 50 | v_test_files[folder]++ |
| 51 | } |
| 52 | } |
| 53 | eprintln('> Found ${v_files.len:5} potential V module folders (containing .v files).') |
| 54 | for folder, n_v_files in v_files { |
| 55 | n_test_v_files := v_test_files[folder] |
| 56 | if n_v_files > 1 && n_test_v_files == 0 { |
| 57 | println('> ${n_test_v_files:5} _test.v files, with ${n_v_files:5} .v files, in folder: ${folder}') |
| 58 | compilation := |
| 59 | os.execute('${os.quoted_path(vexe)} -shared -W -Wfatal-errors -check ${os.quoted_path(folder)}') |
| 60 | if compilation.exit_code != 0 { |
| 61 | eprintln('> ${folder} has parser/checker errors!') |
| 62 | eprintln(compilation.output) |
| 63 | } |
| 64 | found++ |
| 65 | } |
| 66 | } |
| 67 | eprintln('> Found ${found} module folders without _test.v files in `${path}` .') |
| 68 | } |
| 69 | } |
| 70 | |