Skip to content

Commit

Permalink
patch 9.0.0561: when a test gets stuck it just hangs forever
Browse files Browse the repository at this point in the history
Problem:    When a test gets stuck it just hangs forever.
Solution:   Set a timeout of 30 seconds.
  • Loading branch information
brammool committed Sep 23, 2022
1 parent b9093d5 commit 3bcd0dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/testdir/runtest.vim
Expand Up @@ -186,6 +186,17 @@ if has('reltime')
let g:func_start = reltime()
endif

" Invoked when a test takes too much time.
func TestTimeout(id)
split test.log
call append(line('$'), '')
call append(line('$'), 'Test timed out: ' .. g:testfunc)
write
call add(v:errors, 'Test timed out: ' . g:testfunc)

cquit! 42
endfunc

func RunTheTest(test)
let prefix = ''
if has('reltime')
Expand All @@ -194,6 +205,12 @@ func RunTheTest(test)
endif
echoconsole prefix .. 'Executing ' .. a:test

if has('timers')
" No test should take longer than 30 seconds. If it takes longer we
" assume we are stuck and need to break out.
let test_timeout_timer = timer_start(30000, 'TestTimeout')
endif

" Avoid stopping at the "hit enter" prompt
set nomore

Expand Down Expand Up @@ -259,6 +276,10 @@ func RunTheTest(test)
endtry
endif

if has('timers')
call timer_stop(test_timeout_timer)
endif

" Clear any autocommands and put back the catch-all for SwapExists.
au!
au SwapExists * call HandleSwapExists()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -699,6 +699,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
561,
/**/
560,
/**/
Expand Down

0 comments on commit 3bcd0dd

Please sign in to comment.