live_test.v: wait 5 times more on macos
parent
c747ba1c3f
commit
70c87137a9
|
@ -72,7 +72,13 @@ fn pmessage() string {
|
|||
const (
|
||||
delay = 5
|
||||
)
|
||||
|
||||
fn edefault(name string, default string) string {
|
||||
res := os.getenv(name)
|
||||
if res == '' {
|
||||
return default
|
||||
}
|
||||
return res
|
||||
}
|
||||
fn main() {
|
||||
mut info := live.info()
|
||||
info.recheck_period_ms = 5
|
||||
|
@ -80,8 +86,9 @@ fn main() {
|
|||
myprintln('DATE: ' + time.now().str())
|
||||
pmessage()
|
||||
pmessage()
|
||||
max_cycles := edefault('LIVE_CYCLES', '1').int()
|
||||
// NB: 1000 * 5 = maximum of ~5s runtime
|
||||
for i:=0; i<1000; i++ {
|
||||
for i:=0; i<max_cycles; i++ {
|
||||
s := pmessage()
|
||||
append_to_file(os.resource_abs_path(s + '.txt'), s)
|
||||
time.sleep_ms(delay)
|
||||
|
@ -97,6 +104,14 @@ fn main() {
|
|||
"
|
||||
)
|
||||
|
||||
fn edefault(name string, default string) string {
|
||||
res := os.getenv(name)
|
||||
if res == '' {
|
||||
return default
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
fn atomic_write_source(source string) {
|
||||
// NB: here wrtiting is done in 2 steps, since os.write_file can take some time,
|
||||
// during which the file will be modified, but it will still be not completely written.
|
||||
|
@ -158,7 +173,8 @@ fn wait_for_file(new string) {
|
|||
time.sleep_ms(100)
|
||||
expected_file := os.join_path(os.temp_dir(), new + '.txt')
|
||||
eprintln('waiting for $expected_file ...')
|
||||
for i := 0; i <= 400; i++ {
|
||||
max_wait_cycles := edefault('WAIT_CYCLES', '1').int()
|
||||
for i := 0; i <= max_wait_cycles; i++ {
|
||||
if i % 25 == 0 {
|
||||
vprintln(' checking ${i:-10d} for $expected_file ...')
|
||||
}
|
||||
|
@ -172,8 +188,20 @@ fn wait_for_file(new string) {
|
|||
}
|
||||
}
|
||||
|
||||
fn setup_cycles_environment() {
|
||||
mut max_live_cycles := 1000
|
||||
mut max_wait_cycles := 400
|
||||
if os.user_os() == 'macos' {
|
||||
max_live_cycles *= 5
|
||||
max_wait_cycles *= 5
|
||||
}
|
||||
os.setenv('LIVE_CYCLES', '$max_live_cycles', true)
|
||||
os.setenv('WAIT_CYCLES', '$max_wait_cycles', true)
|
||||
}
|
||||
|
||||
//
|
||||
fn test_live_program_can_be_compiled() {
|
||||
setup_cycles_environment()
|
||||
eprintln('Compiling...')
|
||||
os.system('$vexe -live -o $genexe_file $source_file')
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue