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:
parent
09128accff
commit
0e56b96bda
@ -30,13 +30,7 @@ fn main() {
|
|||||||
|
|
||||||
fn v_test_formatting(vargs string) {
|
fn v_test_formatting(vargs string) {
|
||||||
all_v_files := v_files()
|
all_v_files := v_files()
|
||||||
vexe := os.getenv('VEXE')
|
prepare_vfmt_when_needed()
|
||||||
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)
|
|
||||||
}
|
|
||||||
testing.eheader('Run "v fmt" over all .v files')
|
testing.eheader('Run "v fmt" over all .v files')
|
||||||
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
|
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
|
||||||
vfmt_test_session.files << all_v_files
|
vfmt_test_session.files << all_v_files
|
||||||
@ -60,3 +54,16 @@ fn v_files() []string {
|
|||||||
}
|
}
|
||||||
return files_that_can_be_formatted
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user