Mercurial > vim
comparison src/testdir/test_timers.vim @ 32521:f7596eb0bc0c v9.0.1592
patch 9.0.1592: not all timer tests are marked as flaky
Commit: https://github.com/vim/vim/commit/29b4c513b11deb37f0e0538df53d195f602fa42c
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 30 15:34:50 2023 +0100
patch 9.0.1592: not all timer tests are marked as flaky
Problem: Not all timer tests are marked as flaky.
Solution: Set the flaky flag for all timer tests. (closes https://github.com/vim/vim/issues/12355)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 30 May 2023 16:45:06 +0200 |
parents | dbec60b8c253 |
children | 448aef880252 |
comparison
equal
deleted
inserted
replaced
32520:e37e69174865 | 32521:f7596eb0bc0c |
---|---|
5 | 5 |
6 source screendump.vim | 6 source screendump.vim |
7 source shared.vim | 7 source shared.vim |
8 source term_util.vim | 8 source term_util.vim |
9 | 9 |
10 func SetUp() | |
11 " The tests here use timers, thus are sensitive to timing. | |
12 let g:test_is_flaky = 1 | |
13 endfunc | |
14 | |
10 func MyHandler(timer) | 15 func MyHandler(timer) |
11 let g:val += 1 | 16 let g:val += 1 |
12 endfunc | 17 endfunc |
13 | 18 |
14 func MyHandlerWithLists(lists, timer) | 19 func MyHandlerWithLists(lists, timer) |
15 let x = string(a:lists) | 20 let x = string(a:lists) |
16 endfunc | 21 endfunc |
17 | 22 |
18 func Test_timer_oneshot() | 23 func Test_timer_oneshot() |
19 let g:test_is_flaky = 1 | |
20 let g:val = 0 | 24 let g:val = 0 |
21 let timer = timer_start(50, 'MyHandler') | 25 let timer = timer_start(50, 'MyHandler') |
22 let slept = WaitFor('g:val == 1') | 26 let slept = WaitFor('g:val == 1') |
23 call assert_equal(1, g:val) | 27 call assert_equal(1, g:val) |
24 if has('mac') | 28 if has('mac') |
33 call assert_inrange(20, limit, slept) | 37 call assert_inrange(20, limit, slept) |
34 endif | 38 endif |
35 endfunc | 39 endfunc |
36 | 40 |
37 func Test_timer_repeat_three() | 41 func Test_timer_repeat_three() |
38 let g:test_is_flaky = 1 | |
39 let g:val = 0 | 42 let g:val = 0 |
40 let timer = timer_start(50, 'MyHandler', {'repeat': 3}) | 43 let timer = timer_start(50, 'MyHandler', {'repeat': 3}) |
41 let slept = WaitFor('g:val == 3') | 44 let slept = WaitFor('g:val == 3') |
42 call assert_equal(3, g:val) | 45 call assert_equal(3, g:val) |
43 if has('reltime') | 46 if has('reltime') |
51 call assert_inrange(80, 200, slept) | 54 call assert_inrange(80, 200, slept) |
52 endif | 55 endif |
53 endfunc | 56 endfunc |
54 | 57 |
55 func Test_timer_repeat_many() | 58 func Test_timer_repeat_many() |
56 let g:test_is_flaky = 1 | |
57 let g:val = 0 | 59 let g:val = 0 |
58 let timer = timer_start(50, 'MyHandler', {'repeat': -1}) | 60 let timer = timer_start(50, 'MyHandler', {'repeat': -1}) |
59 sleep 200m | 61 sleep 200m |
60 call timer_stop(timer) | 62 call timer_stop(timer) |
61 " Mac on Travis can be slow. | 63 " Mac on Travis can be slow. |
65 call assert_inrange(2, 5, g:val) | 67 call assert_inrange(2, 5, g:val) |
66 endif | 68 endif |
67 endfunc | 69 endfunc |
68 | 70 |
69 func Test_timer_with_partial_callback() | 71 func Test_timer_with_partial_callback() |
70 let g:test_is_flaky = 1 | |
71 let g:val = 0 | 72 let g:val = 0 |
72 let meow = {'one': 1} | 73 let meow = {'one': 1} |
73 function meow.bite(...) | 74 function meow.bite(...) |
74 let g:val += self.one | 75 let g:val += self.one |
75 endfunction | 76 endfunction |
150 assert_equal([], timer_info(tmr)) | 151 assert_equal([], timer_info(tmr)) |
151 assert_equal([], popup_list()) | 152 assert_equal([], popup_list()) |
152 enddef | 153 enddef |
153 | 154 |
154 func Test_timer_paused() | 155 func Test_timer_paused() |
155 let g:test_is_flaky = 1 | |
156 let g:val = 0 | 156 let g:val = 0 |
157 | 157 |
158 let id = timer_start(50, 'MyHandler') | 158 let id = timer_start(50, 'MyHandler') |
159 let info = timer_info(id) | 159 let info = timer_info(id) |
160 call assert_equal(0, info[0]['paused']) | 160 call assert_equal(0, info[0]['paused']) |
210 func StopTimer2(timer) | 210 func StopTimer2(timer) |
211 call timer_stop(g:timer1) | 211 call timer_stop(g:timer1) |
212 endfunc | 212 endfunc |
213 | 213 |
214 func Test_timer_stop_in_callback() | 214 func Test_timer_stop_in_callback() |
215 let g:test_is_flaky = 1 | |
216 call assert_equal(1, len(timer_info())) | 215 call assert_equal(1, len(timer_info())) |
217 let g:timer1 = timer_start(10, 'StopTimer1') | 216 let g:timer1 = timer_start(10, 'StopTimer1') |
218 let slept = 0 | 217 let slept = 0 |
219 for i in range(10) | 218 for i in range(10) |
220 if len(timer_info()) == 1 | 219 if len(timer_info()) == 1 |
234 func StopTimerAll(timer) | 233 func StopTimerAll(timer) |
235 call timer_stopall() | 234 call timer_stopall() |
236 endfunc | 235 endfunc |
237 | 236 |
238 func Test_timer_stop_all_in_callback() | 237 func Test_timer_stop_all_in_callback() |
239 let g:test_is_flaky = 1 | |
240 " One timer is for TestTimeout() | 238 " One timer is for TestTimeout() |
241 call assert_equal(1, len(timer_info())) | 239 call assert_equal(1, len(timer_info())) |
242 call timer_start(10, 'StopTimerAll') | 240 call timer_start(10, 'StopTimerAll') |
243 call assert_equal(2, len(timer_info())) | 241 call assert_equal(2, len(timer_info())) |
244 let slept = 0 | 242 let slept = 0 |