1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v test-fmt: recompile vfmt only when needed

This commit is contained in:
Delyan Angelov 2020-10-21 11:06:15 +03:00
parent 09128accff
commit 0e56b96bda

View File

@ -30,13 +30,7 @@ fn main() {
fn v_test_formatting(vargs string) {
all_v_files := v_files()
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
recompile_result := os.system('$vexe ' + os.join_path(vroot, 'cmd', 'tools', 'vfmt.v'))
if recompile_result != 0 {
eprintln('could not recompile cmd/tools/vfmt.v')
exit(2)
}
prepare_vfmt_when_needed()
testing.eheader('Run "v fmt" over all .v files')
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
vfmt_test_session.files << all_v_files
@ -60,3 +54,16 @@ fn v_files() []string {
}
return files_that_can_be_formatted
}
fn prepare_vfmt_when_needed() {
vexe := os.getenv('VEXE')
vroot := os.dir(vexe)
vfmtv := os.join_path(vroot, 'cmd', 'tools', 'vfmt.v')
if os.file_last_mod_unix(vexe) <= os.file_last_mod_unix(vfmtv) {
recompile_result := os.system('$vexe ' + os.join_path(vroot, 'cmd', 'tools', 'vfmt.v'))
if recompile_result != 0 {
eprintln('could not recompile cmd/tools/vfmt.v')
exit(2)
}
}
}