Skip to content

Commit b5760a1

Browse files
committed
patch 7.4.1477
Problem: Test_reltime is flaky, it depends on timing. Solution: When it fails run it a second time.
1 parent f1d2501 commit b5760a1

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

src/testdir/runtest.vim

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ function GetAllocId(name)
7272
return lnum - top - 1
7373
endfunc
7474

75+
function RunTheTest(test)
76+
echo 'Executing ' . a:test
77+
if exists("*SetUp")
78+
call SetUp()
79+
endif
80+
81+
call add(s:messages, 'Executing ' . a:test)
82+
let s:done += 1
83+
try
84+
exe 'call ' . a:test
85+
catch
86+
call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
87+
endtry
88+
89+
if exists("*TearDown")
90+
call TearDown()
91+
endif
92+
endfunc
7593

7694
" Source the test script. First grab the file name, in case the script
7795
" navigates away. g:testname can be used by the tests.
@@ -92,6 +110,9 @@ else
92110
endtry
93111
endif
94112

113+
" Names of flaky tests.
114+
let s:flaky = ['Test_reltime()']
115+
95116
" Locate Test_ functions and execute them.
96117
set nomore
97118
redir @q
@@ -106,18 +127,13 @@ endif
106127

107128
" Execute the tests in alphabetical order.
108129
for s:test in sort(s:tests)
109-
echo 'Executing ' . s:test
110-
if exists("*SetUp")
111-
call SetUp()
112-
endif
130+
call RunTheTest(s:test)
113131

114-
call add(s:messages, 'Executing ' . s:test)
115-
let s:done += 1
116-
try
117-
exe 'call ' . s:test
118-
catch
119-
call add(v:errors, 'Caught exception in ' . s:test . ': ' . v:exception . ' @ ' . v:throwpoint)
120-
endtry
132+
if len(v:errors) > 0 && index(s:flaky, s:test) >= 0
133+
call add(s:messages, 'Flaky test failed, running it again')
134+
let v:errors = []
135+
call RunTheTest(s:test)
136+
endif
121137

122138
if len(v:errors) > 0
123139
let s:fail += 1
@@ -126,9 +142,6 @@ for s:test in sort(s:tests)
126142
let v:errors = []
127143
endif
128144

129-
if exists("*TearDown")
130-
call TearDown()
131-
endif
132145
endfor
133146

134147
if s:fail == 0

src/version.c

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

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1477,
746748
/**/
747749
1476,
748750
/**/

0 commit comments

Comments
 (0)