Skip to content

Commit bd52a94

Browse files
committed
tests: add a small delay too between the test retries, in the non -stats branch, handling flaky test failures
1 parent 35558df commit bd52a94

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cmd/tools/modules/testing/common.v

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,21 @@ pub const test_only = os.getenv('VTEST_ONLY').split_any(',')
2929

3030
pub const test_only_fn = os.getenv('VTEST_ONLY_FN').split_any(',')
3131

32+
// TODO: this !!!*reliably*!!! fails compilation of `v cmd/tools/vbuild-examples.v` with a cgen error, without `-no-parallel`:
33+
// pub const fail_retry_delay_ms = os.getenv_opt('VTEST_FAIL_RETRY_DELAY_MS') or { '500' }.int() * time.millisecond
34+
// Note, it works with `-no-parallel`, and it works when that whole expr is inside a function, like below:
35+
pub const fail_retry_delay_ms = get_fail_retry_delay_ms()
36+
3237
pub const is_node_present = os.execute('node --version').exit_code == 0
3338

3439
pub const all_processes = get_all_processes()
3540

41+
pub const header_bytes_to_search_for_module_main = 500
42+
43+
fn get_fail_retry_delay_ms() time.Duration {
44+
return os.getenv_opt('VTEST_FAIL_RETRY_DELAY_MS') or { '500' }.int() * time.millisecond
45+
}
46+
3647
fn get_all_processes() []string {
3748
$if windows {
3849
// TODO
@@ -504,7 +515,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
504515
goto test_passed_system
505516
}
506517
}
507-
time.sleep(500 * time.millisecond)
518+
time.sleep(testing.fail_retry_delay_ms)
508519
}
509520
if details.flaky && !testing.fail_flaky {
510521
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .',
@@ -566,6 +577,7 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
566577
goto test_passed_execute
567578
}
568579
}
580+
time.sleep(testing.fail_retry_delay_ms)
569581
}
570582
if details.flaky && !testing.fail_flaky {
571583
ts.append_message(.info, ' *FAILURE* of the known flaky test file ${relative_file} is ignored, since VTEST_FAIL_FLAKY is 0 . Retry count: ${details.retry} .',
@@ -628,14 +640,13 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
628640
continue
629641
}
630642
$if windows {
631-
// skip process/command examples on windows
643+
// skip process/command examples on windows. TODO: remove the need for this, fix os.Command
632644
if fnormalised.ends_with('examples/process/command.v') {
633645
continue
634646
}
635647
}
636648
c := os.read_file(f) or { panic(err) }
637-
maxc := if c.len > 500 { 500 } else { c.len }
638-
start := c[0..maxc]
649+
start := c#[0..testing.header_bytes_to_search_for_module_main]
639650
if start.contains('module ') && !start.contains('module main') {
640651
skipped_f := f.replace(os.join_path_single(parent_dir, ''), '')
641652
skipped << skipped_f

0 commit comments

Comments
 (0)