tests: add cmd/tools/vdoc/tests/vdoc_file_test.v, extract a v.util.diff module, cleanup

This commit is contained in:
Delyan Angelov 2021-06-22 18:52:34 +03:00
parent 0aef92b613
commit b6bd6d1d35
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
17 changed files with 212 additions and 128 deletions

View file

@ -11,6 +11,7 @@ import v.ast
import v.pref
import v.fmt
import v.util
import v.util.diff
import v.parser
import vhelp
@ -203,25 +204,25 @@ fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path
return
}
if foptions.is_diff {
diff_cmd := util.find_working_diff_command() or {
diff_cmd := diff.find_working_diff_command() or {
eprintln(err)
return
}
if foptions.is_verbose {
eprintln('Using diff command: $diff_cmd')
}
diff := util.color_compare_files(diff_cmd, file, formatted_file_path)
diff := diff.color_compare_files(diff_cmd, file, formatted_file_path)
if diff.len > 0 {
println(diff)
}
return
}
if foptions.is_verify {
diff_cmd := util.find_working_diff_command() or {
diff_cmd := diff.find_working_diff_command() or {
eprintln(err)
return
}
x := util.color_compare_files(diff_cmd, file, formatted_file_path)
x := diff.color_compare_files(diff_cmd, file, formatted_file_path)
if x.len != 0 {
println("$file is not vfmt'ed")
return error('')