Skip to content

Commit

Permalink
Stop the completion tests from failing randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Nov 21, 2017
1 parent cf599f4 commit 5556fcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions autoload/ale/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ function! s:TimerHandler(...) abort
endif
endfunction

" Stop any completion timer that is queued. This is useful for tests.
function! ale#completion#StopTimer() abort
if s:timer_id != -1
call timer_stop(s:timer_id)
endif

let s:timer_id = -1
endfunction

function! ale#completion#Queue() abort
let l:time = get(b:, 'ale_complete_done_time', 0)

Expand All @@ -298,9 +307,7 @@ function! ale#completion#Queue() abort
let b:ale_completion_info.request_id = 0
endif

if s:timer_id != -1
call timer_stop(s:timer_id)
endif
call ale#completion#StopTimer()

let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
endfunction
Expand Down
4 changes: 4 additions & 0 deletions test/test_completion.vader
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ After:

delfunction CheckCompletionCalled

" Stop any timers we left behind.
" This stops the tests from failing randomly.
call ale#completion#StopTimer()

runtime autoload/ale/completion.vim
runtime autoload/ale/lsp.vim

Expand Down

0 comments on commit 5556fcb

Please sign in to comment.