Patch 8.0.1259
Problem: Search test can be flaky.
Solution: Use WaitFor() instead of a delay. Make it possible to pass a
funcref to WaitFor() to avoid the need for global variables.
(James McCoy, closes #2282)
Files: src/testdir/shared.vim, src/testdir/test_search.vim
*** ../vim-8.0.1258/src/testdir/shared.vim 2017-11-02 18:19:14.474895412
+0100
--- src/testdir/shared.vim 2017-11-04 18:38:56.873702248 +0100
***************
*** 113,119 ****
endif
endfunc
! " Wait for up to a second for "expr" to become true.
" Return time slept in milliseconds. With the +reltime feature this can be
" more than the actual waiting time. Without +reltime it can also be less.
func WaitFor(expr, ...)
--- 113,121 ----
endif
endfunc
! " Wait for up to a second for "expr" to become true. "expr" can be a
! " stringified expression to evaluate, or a funcref without arguments.
! "
" Return time slept in milliseconds. With the +reltime feature this can be
" more than the actual waiting time. Without +reltime it can also be less.
func WaitFor(expr, ...)
***************
*** 124,131 ****
else
let slept = 0
endif
for i in range(timeout / 10)
! if eval(a:expr)
if has('reltime')
return float2nr(reltimefloat(reltime(start)) * 1000)
endif
--- 126,138 ----
else
let slept = 0
endif
+ if type(a:expr) == v:t_func
+ let Test = a:expr
+ else
+ let Test = {-> eval(a:expr) }
+ endif
for i in range(timeout / 10)
! if Test()
if has('reltime')
return float2nr(reltimefloat(reltime(start)) * 1000)
endif
*** ../vim-8.0.1258/src/testdir/test_search.vim 2017-11-02 23:11:17.953118267
+0100
--- src/testdir/test_search.vim 2017-11-04 18:43:55.435949109 +0100
***************
*** 482,500 ****
" Prepare buffer text
let lines = ['abb vim vim vi', 'vimvivim']
call writefile(lines, 'Xsearch.txt')
! let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile',
'Xsearch.txt'], {'term_rows': 3})
! call term_wait(g:buf, 200)
! call assert_equal(lines[0], term_getline(g:buf, 1))
! call assert_equal(lines[1], term_getline(g:buf, 2))
!
! call term_sendkeys(g:buf, ":set incsearch hlsearch\<cr>")
! call term_sendkeys(g:buf, ":14vsp\<cr>")
! call term_sendkeys(g:buf, "/vim\<cr>")
! call term_sendkeys(g:buf, "/b\<esc>")
! call term_sendkeys(g:buf, "gg0")
! call term_wait(g:buf, 500)
! let screen_line = term_scrape(g:buf, 1)
let [a0,a1,a2,a3] = [screen_line[3].attr, screen_line[4].attr,
\ screen_line[18].attr, screen_line[19].attr]
call assert_notequal(a0, a1)
--- 482,498 ----
" Prepare buffer text
let lines = ['abb vim vim vi', 'vimvivim']
call writefile(lines, 'Xsearch.txt')
! let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile',
'Xsearch.txt'], {'term_rows': 3})
! call WaitFor({-> lines == [term_getline(buf, 1), term_getline(buf, 2)] })
!
! call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
! call term_sendkeys(buf, ":14vsp\<cr>")
! call term_sendkeys(buf, "/vim\<cr>")
! call term_sendkeys(buf, "/b\<esc>")
! call term_sendkeys(buf, "gg0")
! call term_wait(buf, 500)
! let screen_line = term_scrape(buf, 1)
let [a0,a1,a2,a3] = [screen_line[3].attr, screen_line[4].attr,
\ screen_line[18].attr, screen_line[19].attr]
call assert_notequal(a0, a1)
***************
*** 607,625 ****
endif
" Prepare buffer text
! let g:lines = ['abb vim vim vi', 'vimvivim']
! call writefile(g:lines, 'Xsearch.txt')
! let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile',
'Xsearch.txt'], {'term_rows': 3})
! call WaitFor('g:lines[0] == term_getline(g:buf, 1)')
! call assert_equal(g:lines[0], term_getline(g:buf, 1))
! call assert_equal(g:lines[1], term_getline(g:buf, 2))
! unlet g:lines
" Get attr of normal(a0), incsearch(a1), hlsearch(a2) highlight
! call term_sendkeys(g:buf, ":set incsearch hlsearch\<cr>")
! call term_sendkeys(g:buf, '/b')
! call term_wait(g:buf, 200)
! let screen_line1 = term_scrape(g:buf, 1)
call assert_true(len(screen_line1) > 2)
" a0: attr_normal
let a0 = screen_line1[0].attr
--- 605,621 ----
endif
" Prepare buffer text
! let lines = ['abb vim vim vi', 'vimvivim']
! call writefile(lines, 'Xsearch.txt')
! let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile',
'Xsearch.txt'], {'term_rows': 3})
!
! call WaitFor({-> lines == [term_getline(buf, 1), term_getline(buf, 2)] })
" Get attr of normal(a0), incsearch(a1), hlsearch(a2) highlight
! call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
! call term_sendkeys(buf, '/b')
! call term_wait(buf, 200)
! let screen_line1 = term_scrape(buf, 1)
call assert_true(len(screen_line1) > 2)
" a0: attr_normal
let a0 = screen_line1[0].attr
***************
*** 630,682 ****
call assert_notequal(a0, a1)
call assert_notequal(a0, a2)
call assert_notequal(a1, a2)
! call term_sendkeys(g:buf, "\<cr>gg0")
" Test incremental highlight search
! call term_sendkeys(g:buf, "/vim")
! call term_wait(g:buf, 200)
" Buffer:
" abb vim vim vi
" vimvivim
" Search: /vim
let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(g:buf,
1)[:len(attr_line1)-1], 'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(g:buf,
2)[:len(attr_line2)-1], 'v:val.attr'))
" Test <C-g>
! call term_sendkeys(g:buf, "\<C-g>\<C-g>")
! call term_wait(g:buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a1,a1,a1,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(g:buf,
1)[:len(attr_line1)-1], 'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(g:buf,
2)[:len(attr_line2)-1], 'v:val.attr'))
" Test <C-t>
! call term_sendkeys(g:buf, "\<C-t>")
! call term_wait(g:buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a1,a1,a1,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(g:buf,
1)[:len(attr_line1)-1], 'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(g:buf,
2)[:len(attr_line2)-1], 'v:val.attr'))
" Type Enter and a1(incsearch highlight) should become a2(hlsearch
highlight)
! call term_sendkeys(g:buf, "\<cr>")
! call term_wait(g:buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(g:buf,
1)[:len(attr_line1)-1], 'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(g:buf,
2)[:len(attr_line2)-1], 'v:val.attr'))
" Test nohlsearch. a2(hlsearch highlight) should become a0(normal highlight)
! call term_sendkeys(g:buf, ":1\<cr>")
! call term_sendkeys(g:buf, ":set nohlsearch\<cr>")
! call term_sendkeys(g:buf, "/vim")
! call term_wait(g:buf, 200)
let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0]
let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0]
! call assert_equal(attr_line1, map(term_scrape(g:buf,
1)[:len(attr_line1)-1], 'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(g:buf,
2)[:len(attr_line2)-1], 'v:val.attr'))
call delete('Xsearch.txt')
call delete('Xsearch.txt')
--- 626,678 ----
call assert_notequal(a0, a1)
call assert_notequal(a0, a2)
call assert_notequal(a1, a2)
! call term_sendkeys(buf, "\<cr>gg0")
" Test incremental highlight search
! call term_sendkeys(buf, "/vim")
! call term_wait(buf, 200)
" Buffer:
" abb vim vim vi
" vimvivim
" Search: /vim
let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1],
'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1],
'v:val.attr'))
" Test <C-g>
! call term_sendkeys(buf, "\<C-g>\<C-g>")
! call term_wait(buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a1,a1,a1,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1],
'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1],
'v:val.attr'))
" Test <C-t>
! call term_sendkeys(buf, "\<C-t>")
! call term_wait(buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a1,a1,a1,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1],
'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1],
'v:val.attr'))
" Type Enter and a1(incsearch highlight) should become a2(hlsearch
highlight)
! call term_sendkeys(buf, "\<cr>")
! call term_wait(buf, 200)
let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0]
let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2]
! call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1],
'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1],
'v:val.attr'))
" Test nohlsearch. a2(hlsearch highlight) should become a0(normal highlight)
! call term_sendkeys(buf, ":1\<cr>")
! call term_sendkeys(buf, ":set nohlsearch\<cr>")
! call term_sendkeys(buf, "/vim")
! call term_wait(buf, 200)
let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0]
let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0]
! call assert_equal(attr_line1, map(term_scrape(buf, 1)[:len(attr_line1)-1],
'v:val.attr'))
! call assert_equal(attr_line2, map(term_scrape(buf, 2)[:len(attr_line2)-1],
'v:val.attr'))
call delete('Xsearch.txt')
call delete('Xsearch.txt')
*** ../vim-8.0.1258/src/version.c 2017-11-04 15:16:52.211407386 +0100
--- src/version.c 2017-11-04 18:47:50.698594149 +0100
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 1259,
/**/
--
A special cleaning ordinance bans housewives from hiding dirt and dust under a
rug in a dwelling.
[real standing law in Pennsylvania, United States of America]
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.