mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1738: testing lambda with timer is slow (#10590)
Problem: Testing lambda with timer is slow.
Solution: Do not test timer accuracy, only that it works. (Daniel Hahler,
closes vim/vim#4723)
9bc4dde45d
This commit is contained in:
parent
8404e8df20
commit
3566267e75
@ -278,7 +278,6 @@ let s:flaky_tests = [
|
|||||||
\ 'Test_terminal_redir_file()',
|
\ 'Test_terminal_redir_file()',
|
||||||
\ 'Test_terminal_tmap()',
|
\ 'Test_terminal_tmap()',
|
||||||
\ 'Test_with_partial_callback()',
|
\ 'Test_with_partial_callback()',
|
||||||
\ 'Test_lambda_with_timer()',
|
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
" Pattern indicating a common flaky test failure.
|
" Pattern indicating a common flaky test failure.
|
||||||
|
@ -23,30 +23,36 @@ function! Test_lambda_with_timer()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
source load.vim
|
|
||||||
|
|
||||||
let s:n = 0
|
let s:n = 0
|
||||||
let s:timer_id = 0
|
let s:timer_id = 0
|
||||||
function! s:Foo()
|
func! s:Foo()
|
||||||
"let n = 0
|
let s:timer_id = timer_start(10, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1})
|
||||||
let s:timer_id = timer_start(50, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1})
|
endfunc
|
||||||
endfunction
|
|
||||||
|
|
||||||
call s:Foo()
|
call s:Foo()
|
||||||
sleep 210m
|
" check timer works
|
||||||
|
for i in range(0, 10)
|
||||||
|
if s:n > 0
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
sleep 10m
|
||||||
|
endfor
|
||||||
|
|
||||||
" do not collect lambda
|
" do not collect lambda
|
||||||
call test_garbagecollect_now()
|
call test_garbagecollect_now()
|
||||||
let m = LoadAdjust(s:n)
|
|
||||||
sleep 230m
|
" check timer still works
|
||||||
|
let m = s:n
|
||||||
|
for i in range(0, 10)
|
||||||
|
if s:n > m
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
sleep 10m
|
||||||
|
endfor
|
||||||
|
|
||||||
call timer_stop(s:timer_id)
|
call timer_stop(s:timer_id)
|
||||||
|
call assert_true(s:n > m)
|
||||||
let n = LoadAdjust(s:n)
|
endfunc
|
||||||
let nine = LoadAdjust(9)
|
|
||||||
|
|
||||||
call assert_true(m > 1)
|
|
||||||
call assert_true(n > m + 1)
|
|
||||||
call assert_true(n < nine)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! Test_lambda_with_partial()
|
function! Test_lambda_with_partial()
|
||||||
let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two'])
|
let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two'])
|
||||||
|
Loading…
Reference in New Issue
Block a user