Skip to content

Commit baab7c0

Browse files
Millyk-takata
authored andcommitted
patch 9.1.0820: tests: Mac OS tests are too flaky
Problem: tests: Mac OS tests are too flaky Solution: Increase max test timeout to 25 minutes, allow up to 10 retries on Mac OS runners, refactor runtest.vim (Milly). closes: #15940 Co-authored-by: K.Takata <kentkt@csc.jp> Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 1e2007e commit baab7c0

5 files changed

Lines changed: 63 additions & 32 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ jobs:
389389
brew install diffutils
390390
391391
- name: Test
392-
timeout-minutes: 20
392+
timeout-minutes: 25
393393
run: |
394394
make ${TEST}
395395

src/testdir/runtest.vim

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ function GetAllocId(name)
190190
return lnum - top - 1
191191
endfunc
192192

193-
if has('reltime')
194-
let g:func_start = reltime()
195-
endif
196-
197193
" Get the list of swap files in the current directory.
198194
func s:GetSwapFileList()
199195
let save_dir = &directory
@@ -603,6 +599,16 @@ for g:testfunc in sort(s:tests)
603599
" A test can set g:test_is_flaky to retry running the test.
604600
let g:test_is_flaky = 0
605601

602+
" A test can set g:max_run_nr to change the max retry count.
603+
let g:max_run_nr = 5
604+
if has('mac')
605+
let g:max_run_nr = 10
606+
endif
607+
608+
" By default, give up if the same error occurs. A test can set
609+
" g:giveup_same_error to 0 to not give up on the same error and keep trying.
610+
let g:giveup_same_error = 1
611+
606612
let starttime = strftime("%H:%M:%S")
607613
call RunTheTest(g:testfunc)
608614

@@ -618,10 +624,15 @@ for g:testfunc in sort(s:tests)
618624
call extend(s:messages, v:errors)
619625

620626
let endtime = strftime("%H:%M:%S")
621-
call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}:')
627+
if has('reltime')
628+
let suffix = $' in{reltimestr(reltime(g:func_start))} seconds'
629+
else
630+
let suffix = ''
631+
endif
632+
call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}{suffix}:')
622633
call extend(total_errors, v:errors)
623634

624-
if g:run_nr >= 5 || prev_error == v:errors[0]
635+
if g:run_nr >= g:max_run_nr || g:giveup_same_error && prev_error == v:errors[0]
625636
call add(total_errors, 'Flaky test failed too often, giving up')
626637
let v:errors = total_errors
627638
break
@@ -632,7 +643,8 @@ for g:testfunc in sort(s:tests)
632643
" Flakiness is often caused by the system being very busy. Sleep a
633644
" couple of seconds to have a higher chance of succeeding the second
634645
" time.
635-
sleep 2
646+
let delay = g:run_nr * 2
647+
exe 'sleep' delay
636648

637649
let prev_error = v:errors[0]
638650
let v:errors = []

src/testdir/screendump.vim

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func VerifyScreenDump(buf, filename, options, ...)
5656

5757
" Starting a terminal to make a screendump is always considered flaky.
5858
let g:test_is_flaky = 1
59+
let g:giveup_same_error = 0
5960

6061
" wait for the pending updates to be handled.
6162
call TermWait(a:buf)
@@ -83,41 +84,55 @@ func VerifyScreenDump(buf, filename, options, ...)
8384
sleep 50m
8485
call delete(testfile)
8586
call term_dumpwrite(a:buf, testfile, a:options)
87+
88+
if refdump->empty()
89+
let msg = 'See new dump file: call term_dumpload("testdir/' .. testfile .. '")'
90+
call assert_report(msg)
91+
" no point in retrying
92+
let g:run_nr = 10
93+
return 1
94+
endif
95+
8696
let testdump = ReadAndFilter(testfile, filter)
8797
if refdump == testdump
8898
call delete(testfile)
8999
if did_mkdir
90100
call delete('failed', 'd')
91101
endif
102+
if i > 0
103+
call remove(v:errors, -1)
104+
endif
92105
break
93106
endif
94-
if i == max_loops
95-
" Leave the failed dump around for inspection.
96-
if filereadable(reference)
97-
let msg = 'See dump file difference: call term_dumpdiff("testdir/' .. testfile .. '", "testdir/' .. reference .. '")'
98-
if a:0 == 1
99-
let msg = a:1 . ': ' . msg
100-
endif
101-
if len(testdump) != len(refdump)
102-
let msg = msg . '; line count is ' . len(testdump) . ' instead of ' . len(refdump)
103-
endif
104-
else
105-
let msg = 'See new dump file: call term_dumpload("testdir/' .. testfile .. '")'
106-
" no point in retrying
107-
let g:run_nr = 10
107+
108+
" Leave the failed dump around for inspection.
109+
let msg = 'See dump file difference: call term_dumpdiff("testdir/' .. testfile .. '", "testdir/' .. reference .. '")'
110+
if a:0 == 1
111+
let msg = a:1 . ': ' . msg
112+
endif
113+
if len(testdump) != len(refdump)
114+
let msg = msg . '; line count is ' . len(testdump) . ' instead of ' . len(refdump)
115+
endif
116+
for j in range(len(refdump))
117+
if j >= len(testdump)
118+
break
108119
endif
109-
for i in range(len(refdump))
110-
if i >= len(testdump)
111-
break
112-
endif
113-
if testdump[i] != refdump[i]
114-
let msg = msg . '; difference in line ' . (i + 1) . ': "' . testdump[i] . '"'
115-
endif
116-
endfor
117-
call assert_report(msg)
118-
return 1
120+
if testdump[j] != refdump[j]
121+
let msg = msg . '; difference in line ' . (j + 1) . ': "' . testdump[j] . '"'
122+
endif
123+
endfor
124+
125+
" Always add the last error so that it is displayed on timeout.
126+
" See TestTimeout() in runtest.vim.
127+
if i > 0
128+
call remove(v:errors, -1)
119129
endif
130+
call assert_report(msg)
131+
120132
let i += 1
133+
if i >= max_loops
134+
return 1
135+
endif
121136
endwhile
122137
return 0
123138
endfunc

src/testdir/test_channel.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,8 @@ func LspTests(port)
27622762
endfunc
27632763

27642764
func Test_channel_lsp_mode()
2765+
" The channel lsp mode test is flaky and gives the same error.
2766+
let g:giveup_same_error = 0
27652767
call RunServer('test_channel_lsp.py', 'LspTests', [])
27662768
endfunc
27672769

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
820,
707709
/**/
708710
819,
709711
/**/

0 commit comments

Comments
 (0)