v test-fmt: add 1 sec sleep before rebuilding vfmt, to avoid its parallel recompilation afterwards
parent
87f659a0dc
commit
9322e91d1b
|
@ -1,6 +1,7 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
import testing
|
import testing
|
||||||
import v.util
|
import v.util
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ fn prepare_vfmt_when_needed() {
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
vfmtv := os.join_path(vroot, 'cmd', 'tools', 'vfmt.v')
|
vfmtv := os.join_path(vroot, 'cmd', 'tools', 'vfmt.v')
|
||||||
if util.should_recompile_tool(vexe, vfmtv) {
|
if util.should_recompile_tool(vexe, vfmtv) {
|
||||||
|
time.sleep_ms(1001) // TODO: remove this when we can get mtime with a better resolution
|
||||||
recompile_file(vexe, vfmtv)
|
recompile_file(vexe, vfmtv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,6 +166,9 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) {
|
||||||
exit(os.system(tool_command))
|
exit(os.system(tool_command))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NB: should_recompile_tool/2 compares unix timestamps that have 1 second resolution
|
||||||
|
// That means that a tool can get recompiled twice, if called in short succession.
|
||||||
|
// TODO: use a nanosecond mtime timestamp, if available.
|
||||||
pub fn should_recompile_tool(vexe string, tool_source string) bool {
|
pub fn should_recompile_tool(vexe string, tool_source string) bool {
|
||||||
sfolder := os.dir(tool_source)
|
sfolder := os.dir(tool_source)
|
||||||
tool_name := os.base(tool_source).replace('.v', '')
|
tool_name := os.base(tool_source).replace('.v', '')
|
||||||
|
|
Loading…
Reference in New Issue