tools: change v test to allow for // vtest hide_retries so that retry_test.v can hide its own (deliberate) retries

This commit is contained in:
Delyan Angelov 2024-10-31 20:23:19 +02:00
parent d48cb18c3a
commit 2ad5d0cd15
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 14 additions and 4 deletions

View File

@ -586,8 +586,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
details := get_test_details(file) details := get_test_details(file)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true) os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry := 1; retry <= details.retry; retry++ { for retry := 1; retry <= details.retry; retry++ {
if !details.hide_retries {
ts.append_message(.info, ' [stats] retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...', ts.append_message(.info, ' [stats] retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc) mtc)
}
os.setenv('VTEST_RETRY', '${retry}', true) os.setenv('VTEST_RETRY', '${retry}', true)
ts.append_message(.cmd_begin, cmd, mtc) ts.append_message(.cmd_begin, cmd, mtc)
@ -679,8 +681,10 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
failure_output.writeln(trimmed_output) failure_output.writeln(trimmed_output)
os.setenv('VTEST_RETRY_MAX', '${details.retry}', true) os.setenv('VTEST_RETRY_MAX', '${details.retry}', true)
for retry = 1; retry <= details.retry; retry++ { for retry = 1; retry <= details.retry; retry++ {
if !details.hide_retries {
ts.append_message(.info, ' retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...', ts.append_message(.info, ' retrying ${retry}/${details.retry} of ${relative_file} ; known flaky: ${details.flaky} ...',
mtc) mtc)
}
os.setenv('VTEST_RETRY', '${retry}', true) os.setenv('VTEST_RETRY', '${retry}', true)
ts.append_message(.cmd_begin, run_cmd, mtc) ts.append_message(.cmd_begin, run_cmd, mtc)
@ -866,6 +870,8 @@ pub struct TestDetails {
pub mut: pub mut:
retry int retry int
flaky bool // when flaky tests fail, the whole run is still considered successful, unless VTEST_FAIL_FLAKY is 1 flaky bool // when flaky tests fail, the whole run is still considered successful, unless VTEST_FAIL_FLAKY is 1
//
hide_retries bool // when true, all retry tries are silent; used by `vlib/v/tests/retry_test.v`
} }
pub fn get_test_details(file string) TestDetails { pub fn get_test_details(file string) TestDetails {
@ -878,6 +884,9 @@ pub fn get_test_details(file string) TestDetails {
if line.starts_with('// vtest flaky:') { if line.starts_with('// vtest flaky:') {
res.flaky = line.all_after(':').trim_space().bool() res.flaky = line.all_after(':').trim_space().bool()
} }
if line.starts_with('// vtest hide_retries') {
res.hide_retries = true
}
} }
return res return res
} }

View File

@ -1,6 +1,7 @@
import os import os
// vtest retry: 2 // vtest retry: 2
// vtest hide_retries
// This tests whether the V test runner, can handle retries. // This tests whether the V test runner, can handle retries.
// //