@@ -72,6 +72,24 @@ function GetAllocId(name)
7272 return lnum - top - 1
7373endfunc
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.
92110 endtry
93111endif
94112
113+ " Names of flaky tests.
114+ let s: flaky = [' Test_reltime()' ]
115+
95116" Locate Test_ functions and execute them.
96117set nomore
97118redir @q
@@ -106,18 +127,13 @@ endif
106127
107128" Execute the tests in alphabetical order.
108129for 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
132145endfor
133146
134147if s: fail == 0
0 commit comments