Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vet: allow to overwrite excluded dirs #21142

Merged
merged 3 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/tools/vvet/vet_test.v
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.