diff options
author | Daniel Hahler <git@thequod.de> | 2019-07-24 19:47:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 19:47:41 +0200 |
commit | 3566267e753996c441c220c8a109bb4f4b25225c (patch) | |
tree | f7194acb65b054628a6d9c0d36500ed99b930342 | |
parent | 8404e8df20bd093057206b5e7c6a363a24533150 (diff) | |
download | rneovim-3566267e753996c441c220c8a109bb4f4b25225c.tar.gz rneovim-3566267e753996c441c220c8a109bb4f4b25225c.tar.bz2 rneovim-3566267e753996c441c220c8a109bb4f4b25225c.zip |
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)
https://github.com/vim/vim/commit/9bc4dde45d45df732953491d0f2c3fd3b10a627e
-rw-r--r-- | src/nvim/testdir/runtest.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_lambda.vim | 38 |
2 files changed, 22 insertions, 17 deletions
diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 009908ec09..c8161b1f9b 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -278,7 +278,6 @@ let s:flaky_tests = [ \ 'Test_terminal_redir_file()', \ 'Test_terminal_tmap()', \ 'Test_with_partial_callback()', - \ 'Test_lambda_with_timer()', \ ] " Pattern indicating a common flaky test failure. diff --git a/src/nvim/testdir/test_lambda.vim b/src/nvim/testdir/test_lambda.vim index bc7817cef8..bfbb3e5c5b 100644 --- a/src/nvim/testdir/test_lambda.vim +++ b/src/nvim/testdir/test_lambda.vim @@ -23,30 +23,36 @@ function! Test_lambda_with_timer() return endif - source load.vim - let s:n = 0 let s:timer_id = 0 - function! s:Foo() - "let n = 0 - let s:timer_id = timer_start(50, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1}) - endfunction + func! s:Foo() + let s:timer_id = timer_start(10, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1}) + endfunc 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 call test_garbagecollect_now() - let m = LoadAdjust(s:n) - sleep 230m - call timer_stop(s:timer_id) - let n = LoadAdjust(s:n) - let nine = LoadAdjust(9) + " check timer still works + let m = s:n + for i in range(0, 10) + if s:n > m + break + endif + sleep 10m + endfor - call assert_true(m > 1) - call assert_true(n > m + 1) - call assert_true(n < nine) -endfunction + call timer_stop(s:timer_id) + call assert_true(s:n > m) +endfunc function! Test_lambda_with_partial() let l:Cb = function({... -> ['zero', a:1, a:2, a:3]}, ['one', 'two']) |