comparison src/testdir/runtest.vim @ 30451:c9d72c379cec v9.0.0561

patch 9.0.0561: when a test gets stuck it just hangs forever Commit: https://github.com/vim/vim/commit/3bcd0ddc2deb34794c735c6ea0b8f964b510c6db Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 23 20:25:55 2022 +0100 patch 9.0.0561: when a test gets stuck it just hangs forever Problem: When a test gets stuck it just hangs forever. Solution: Set a timeout of 30 seconds.
author Bram Moolenaar <Bram@vim.org>
date Fri, 23 Sep 2022 21:30:04 +0200
parents 55aa44dd59ef
children 56a2af8c0980
comparison
equal deleted inserted replaced
30450:800b2f95f159 30451:c9d72c379cec
184 184
185 if has('reltime') 185 if has('reltime')
186 let g:func_start = reltime() 186 let g:func_start = reltime()
187 endif 187 endif
188 188
189 " Invoked when a test takes too much time.
190 func TestTimeout(id)
191 split test.log
192 call append(line('$'), '')
193 call append(line('$'), 'Test timed out: ' .. g:testfunc)
194 write
195 call add(v:errors, 'Test timed out: ' . g:testfunc)
196
197 cquit! 42
198 endfunc
199
189 func RunTheTest(test) 200 func RunTheTest(test)
190 let prefix = '' 201 let prefix = ''
191 if has('reltime') 202 if has('reltime')
192 let prefix = strftime('%M:%S', localtime() - s:test_start_time) .. ' ' 203 let prefix = strftime('%M:%S', localtime() - s:test_start_time) .. ' '
193 let g:func_start = reltime() 204 let g:func_start = reltime()
194 endif 205 endif
195 echoconsole prefix .. 'Executing ' .. a:test 206 echoconsole prefix .. 'Executing ' .. a:test
207
208 if has('timers')
209 " No test should take longer than 30 seconds. If it takes longer we
210 " assume we are stuck and need to break out.
211 let test_timeout_timer = timer_start(30000, 'TestTimeout')
212 endif
196 213
197 " Avoid stopping at the "hit enter" prompt 214 " Avoid stopping at the "hit enter" prompt
198 set nomore 215 set nomore
199 216
200 " Avoid a three second wait when a message is about to be overwritten by the 217 " Avoid a three second wait when a message is about to be overwritten by the
255 try 272 try
256 call TearDown() 273 call TearDown()
257 catch 274 catch
258 call add(v:errors, 'Caught exception in TearDown() after ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) 275 call add(v:errors, 'Caught exception in TearDown() after ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
259 endtry 276 endtry
277 endif
278
279 if has('timers')
280 call timer_stop(test_timeout_timer)
260 endif 281 endif
261 282
262 " Clear any autocommands and put back the catch-all for SwapExists. 283 " Clear any autocommands and put back the catch-all for SwapExists.
263 au! 284 au!
264 au SwapExists * call HandleSwapExists() 285 au SwapExists * call HandleSwapExists()