mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
tests,ci: add a retry loop for the tasks done by vlib/v/compiler_errors_test.v, to reduce false positives for alpine-docker-musl-gcc
This commit is contained in:
parent
e8ce02b50a
commit
43709e9c58
1 changed files with 32 additions and 7 deletions
|
@ -63,6 +63,8 @@ mut:
|
||||||
found___ string
|
found___ string
|
||||||
took time.Duration
|
took time.Duration
|
||||||
cli_cmd string
|
cli_cmd string
|
||||||
|
ntries int
|
||||||
|
max_ntries int = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Tasks {
|
struct Tasks {
|
||||||
|
@ -186,6 +188,7 @@ fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {
|
fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) {
|
||||||
|
max_ntries := get_max_ntries()
|
||||||
paths := vtest.filter_vtest_only(tests, basepath: dir)
|
paths := vtest.filter_vtest_only(tests, basepath: dir)
|
||||||
for path in paths {
|
for path in paths {
|
||||||
tasks.all << TaskDescription{
|
tasks.all << TaskDescription{
|
||||||
|
@ -196,6 +199,7 @@ fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, vop
|
||||||
result_extension: result_extension
|
result_extension: result_extension
|
||||||
path: path
|
path: path
|
||||||
is_module: is_module
|
is_module: is_module
|
||||||
|
max_ntries: max_ntries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -316,23 +320,40 @@ fn (mut tasks Tasks) run() {
|
||||||
fn work_processor(work chan TaskDescription, results chan TaskDescription) {
|
fn work_processor(work chan TaskDescription, results chan TaskDescription) {
|
||||||
for {
|
for {
|
||||||
mut task := <-work or { break }
|
mut task := <-work or { break }
|
||||||
sw := time.new_stopwatch()
|
mut i := 0
|
||||||
task.execute()
|
for i = 1; i <= task.max_ntries; i++ {
|
||||||
task.took = sw.elapsed()
|
sw := time.new_stopwatch()
|
||||||
|
task.execute()
|
||||||
|
task.took = sw.elapsed()
|
||||||
|
if !task.is_error {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
cli_cmd := task.get_cli_cmd()
|
||||||
|
eprintln('> failed ${i:3} times, doing `${cli_cmd}`\n')
|
||||||
|
if i <= task.max_ntries {
|
||||||
|
time.sleep(100 * time.millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task.ntries = i
|
||||||
results <- task
|
results <- task
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn (mut task TaskDescription) get_cli_cmd() string {
|
||||||
|
program := task.path
|
||||||
|
cmd_prefix := if task.evars.len > 0 { '${task.evars} ' } else { '' }
|
||||||
|
cli_cmd := '${cmd_prefix}${os.quoted_path(task.vexe)} ${task.voptions} ${os.quoted_path(program)}'
|
||||||
|
return cli_cmd
|
||||||
|
}
|
||||||
|
|
||||||
// actual processing; Note: no output is done here at all
|
// actual processing; Note: no output is done here at all
|
||||||
fn (mut task TaskDescription) execute() {
|
fn (mut task TaskDescription) execute() {
|
||||||
if task.is_skipped {
|
if task.is_skipped {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
program := task.path
|
cli_cmd := task.get_cli_cmd()
|
||||||
cmd_prefix := if task.evars.len > 0 { '${task.evars} ' } else { '' }
|
|
||||||
cli_cmd := '${cmd_prefix}${os.quoted_path(task.vexe)} ${task.voptions} ${os.quoted_path(program)}'
|
|
||||||
res := os.execute(cli_cmd)
|
res := os.execute(cli_cmd)
|
||||||
expected_out_path := program.replace('.vv', '') + task.result_extension
|
expected_out_path := task.path.replace('.vv', '') + task.result_extension
|
||||||
task.expected_out_path = expected_out_path
|
task.expected_out_path = expected_out_path
|
||||||
task.cli_cmd = cli_cmd
|
task.cli_cmd = cli_cmd
|
||||||
if should_autofix && !os.exists(expected_out_path) {
|
if should_autofix && !os.exists(expected_out_path) {
|
||||||
|
@ -381,3 +402,7 @@ fn get_tests_in_dir(dir string, is_module bool) []string {
|
||||||
tests.sort()
|
tests.sort()
|
||||||
return tests
|
return tests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_max_ntries() int {
|
||||||
|
return if v_ci_musl { 3 } else { 1 }
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue