63
63
found___ string
64
64
took time.Duration
65
65
cli_cmd string
66
+ ntries int
67
+ max_ntries int = 1
66
68
}
67
69
68
70
struct Tasks {
@@ -186,6 +188,7 @@ fn (mut tasks Tasks) add(custom_vexe string, dir string, voptions string, result
186
188
}
187
189
188
190
fn (mut tasks Tasks) add_evars (evars string , custom_vexe string , dir string , voptions string , result_extension string , tests []string , is_module bool ) {
191
+ max_ntries := get_max_ntries ()
189
192
paths := vtest.filter_vtest_only (tests, basepath: dir)
190
193
for path in paths {
191
194
tasks.all << TaskDescription{
@@ -196,6 +199,7 @@ fn (mut tasks Tasks) add_evars(evars string, custom_vexe string, dir string, vop
196
199
result_extension: result_extension
197
200
path: path
198
201
is_module: is_module
202
+ max_ntries: max_ntries
199
203
}
200
204
}
201
205
}
@@ -316,23 +320,40 @@ fn (mut tasks Tasks) run() {
316
320
fn work_processor (work chan TaskDescription, results chan TaskDescription) {
317
321
for {
318
322
mut task := < - work or { break }
319
- sw := time.new_stopwatch ()
320
- task.execute ()
321
- task.took = sw.elapsed ()
323
+ mut i := 0
324
+ for i = 1 ; i < = task.max_ntries; i++ {
325
+ sw := time.new_stopwatch ()
326
+ task.execute ()
327
+ task.took = sw.elapsed ()
328
+ if ! task.is_error {
329
+ break
330
+ }
331
+ cli_cmd := task.get_cli_cmd ()
332
+ eprintln ('> failed ${i:3} times, doing `${cli_cmd} `\n ' )
333
+ if i < = task.max_ntries {
334
+ time.sleep (100 * time.millisecond)
335
+ }
336
+ }
337
+ task.ntries = i
322
338
results < - task
323
339
}
324
340
}
325
341
342
+ fn (mut task TaskDescription) get_cli_cmd () string {
343
+ program := task.path
344
+ cmd_prefix := if task.evars.len > 0 { '${task.evars} ' } else { '' }
345
+ cli_cmd := '${cmd_prefix}${os.quoted_path(task.vexe)} ${task.voptions} ${os.quoted_path(program)} '
346
+ return cli_cmd
347
+ }
348
+
326
349
// actual processing; Note: no output is done here at all
327
350
fn (mut task TaskDescription) execute () {
328
351
if task.is_skipped {
329
352
return
330
353
}
331
- program := task.path
332
- cmd_prefix := if task.evars.len > 0 { '${task.evars} ' } else { '' }
333
- cli_cmd := '${cmd_prefix}${os.quoted_path(task.vexe)} ${task.voptions} ${os.quoted_path(program)} '
354
+ cli_cmd := task.get_cli_cmd ()
334
355
res := os.execute (cli_cmd)
335
- expected_out_path := program .replace ('.vv' , '' ) + task.result_extension
356
+ expected_out_path := task.path .replace ('.vv' , '' ) + task.result_extension
336
357
task.expected_out_path = expected_out_path
337
358
task.cli_cmd = cli_cmd
338
359
if should_autofix && ! os.exists (expected_out_path) {
@@ -381,3 +402,7 @@ fn get_tests_in_dir(dir string, is_module bool) []string {
381
402
tests.sort ()
382
403
return tests
383
404
}
405
+
406
+ fn get_max_ntries () int {
407
+ return if v_ci_musl { 3 } else { 1 }
408
+ }
0 commit comments