Skip to content

Commit

Permalink
vet: allow to overwrite excluded dirs (#21142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Mar 30, 2024
1 parent 5c06175 commit a4ff389
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 1 addition & 2 deletions cmd/tools/vvet/vet_test.v
Expand Up @@ -34,8 +34,7 @@ fn check_path(vexe string, dir string, tests []string) int {
for path in paths {
program := path
print(path + ' ')
// -force is needed so that `v vet` would not skip the regression files
res := os.execute('${os.quoted_path(vexe)} vet -force -nocolor ${os.quoted_path(program)}')
res := os.execute('${os.quoted_path(vexe)} vet -nocolor ${os.quoted_path(program)}')
if res.exit_code < 0 {
panic(res.output)
}
Expand Down
20 changes: 10 additions & 10 deletions cmd/tools/vvet/vvet.v
Expand Up @@ -32,12 +32,12 @@ struct Options {

const term_colors = term.can_show_color_on_stderr()
const clean_seq = ['[', '', ']', '', ' ', '']
const exclude_dirs = ['test', 'slow_test', 'testdata']

fn main() {
vet_options := cmdline.options_after(os.args, ['vet'])
mut vt := Vet{
opt: Options{
is_force: '-force' in vet_options
is_werror: '-W' in vet_options
is_verbose: '-verbose' in vet_options || '-v' in vet_options
show_warnings: '-hide-warnings' !in vet_options && '-w' !in vet_options
Expand All @@ -64,8 +64,16 @@ fn main() {
}
if os.is_dir(path) {
vt.vprintln("vetting folder: '${path}' ...")
os.walk(path, fn [mut vt] (p string) {
overwrite_exclude := exclude_dirs.any(path.contains(it))
os.walk(path, fn [mut vt, overwrite_exclude] (p string) {
if p.ends_with('.v') || p.ends_with('.vv') {
if !overwrite_exclude {
for d in exclude_dirs {
if p.contains(d) {
return
}
}
}
vt.vet_file(p)
}
})
Expand Down Expand Up @@ -93,14 +101,6 @@ fn main() {

// vet_file vets the file read from `path`.
fn (mut vt Vet) vet_file(path string) {
if !vt.opt.is_force && (path.contains('/tests/') || path.contains('/slow_tests/')
|| path.contains('/testdata/')) {
// skip all /tests/ files, since usually their content is not
// important enough to be documented/vetted, and they may even
// contain intentionally invalid code.
vt.vprintln("skipping test file: '${path}' ...")
return
}
vt.file = path
mut prefs := pref.new_preferences()
prefs.is_vet = true
Expand Down
3 changes: 0 additions & 3 deletions vlib/v/help/common/vet.txt
Expand Up @@ -14,6 +14,3 @@ Options:

-p Report private functions with missing documentation too
(by default, only the `pub fn` functions will be reported).

-force (NB: vet development only!)
Do not skip the vet regression tests.

0 comments on commit a4ff389

Please sign in to comment.