vfmt: verify

pull/5856/head
Alexander Medvednikov 2020-07-16 19:46:03 +02:00
parent a989e017fe
commit 9b2cbdacc6
3 changed files with 17 additions and 1 deletions

View File

@ -51,6 +51,9 @@ jobs:
./v vet vlib/v/gen/cgen.v
./v vet vlib/v/checker
./v vet vlib/sqlite
- name: v fmt
run: |
./v fmt -verify vlib/v/checker/checker.v
# - name: Test v binaries
# run: ./v -silent build-vbinaries

View File

@ -23,6 +23,7 @@ struct FormatOptions {
is_worker bool
is_debug bool
is_noerror bool
is_verify bool // exit(1) if the file is not vfmt'ed
}
const (
@ -51,6 +52,7 @@ fn main() {
is_worker: '-worker' in args
is_debug: '-debug' in args
is_noerror: '-noerror' in args
is_verify: '-verify' in args
}
if foptions.is_verbose {
eprintln('vfmt foptions: $foptions')
@ -185,6 +187,17 @@ fn (foptions &FormatOptions) post_process_file(file, formatted_file_path string)
println(util.color_compare_files(diff_cmd, file, formatted_file_path))
return
}
if foptions.is_verify {
diff_cmd := util.find_working_diff_command() or {
eprintln('No working "diff" CLI command found.')
return
}
x := util.color_compare_files(diff_cmd, file, formatted_file_path)
if x.len != 0 {
exit(1)
}
return
}
fc := os.read_file(file) or {
eprintln('File $file could not be read')
return

View File

@ -19,7 +19,7 @@ const (
pub struct Checker {
pub mut:
table &table.Table
table &table.Table
file ast.File
nr_errors int
nr_warnings int