Patch 7.4.1515
Problem: Channel test is a bit flaky.
Solution: Instead of a fixed sleep time wait until an expression evaluates
to true.
Files: src/testdir/test_channel.vim
*** ../vim-7.4.1514/src/testdir/test_channel.vim 2016-03-08
15:37:36.734963213 +0100
--- src/testdir/test_channel.vim 2016-03-08 16:05:39.697475475 +0100
***************
*** 53,61 ****
endif
" Wait for up to 2 seconds for the port number to be there.
- let cnt = 20
let l = []
! while cnt > 0
try
let l = readfile("Xportnr")
catch
--- 53,60 ----
endif
" Wait for up to 2 seconds for the port number to be there.
let l = []
! for i in range(200)
try
let l = readfile("Xportnr")
catch
***************
*** 63,71 ****
if len(l) >= 1
break
endif
! sleep 100m
! let cnt -= 1
! endwhile
call delete("Xportnr")
if len(l) == 0
--- 62,69 ----
if len(l) >= 1
break
endif
! sleep 10m
! endfor
call delete("Xportnr")
if len(l) == 0
***************
*** 102,107 ****
--- 100,115 ----
let s:responseMsg = a:msg
endfunc
+ " Wait for up to a second for "expr" to become true.
+ func s:waitFor(expr)
+ for i in range(100)
+ if eval(a:expr)
+ return
+ endif
+ sleep 10m
+ endfor
+ endfunc
+
func s:communicate(port)
let handle = ch_open('localhost:' . a:port, s:chopt)
if ch_status(handle) == "fail"
***************
*** 120,136 ****
" handled before getting the response, but it's not guaranteed, thus wait a
" tiny bit for the commands to get executed.
call assert_equal('ok', ch_evalexpr(handle, 'make change'))
! sleep 10m
call assert_equal('added1', getline(line('$') - 1))
call assert_equal('added2', getline('$'))
call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100}))
! sleep 10m
call assert_equal('added more', getline('$'))
" Send a request with a specific handler.
call ch_sendexpr(handle, 'hello!', {'callback': 's:RequestHandler'})
! sleep 10m
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
else
--- 128,144 ----
" handled before getting the response, but it's not guaranteed, thus wait a
" tiny bit for the commands to get executed.
call assert_equal('ok', ch_evalexpr(handle, 'make change'))
! call s:waitFor('"added2" == getline("$")')
call assert_equal('added1', getline(line('$') - 1))
call assert_equal('added2', getline('$'))
call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100}))
! call s:waitFor('"added more" == getline("$")')
call assert_equal('added more', getline('$'))
" Send a request with a specific handler.
call ch_sendexpr(handle, 'hello!', {'callback': 's:RequestHandler'})
! call s:waitFor('exists("s:responseHandle")')
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
else
***************
*** 141,147 ****
let s:responseMsg = ''
call ch_sendexpr(handle, 'hello!', {'callback':
function('s:RequestHandler')})
! sleep 10m
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
else
--- 149,155 ----
let s:responseMsg = ''
call ch_sendexpr(handle, 'hello!', {'callback':
function('s:RequestHandler')})
! call s:waitFor('exists("s:responseHandle")')
if !exists('s:responseHandle')
call assert_false(1, 's:responseHandle was not set')
else
***************
*** 182,188 ****
" Send an expr request
call assert_equal('ok', ch_evalexpr(handle, 'an expr'))
! sleep 10m
call assert_equal('one', getline(line('$') - 2))
call assert_equal('two', getline(line('$') - 1))
call assert_equal('three', getline('$'))
--- 190,196 ----
" Send an expr request
call assert_equal('ok', ch_evalexpr(handle, 'an expr'))
! call s:waitFor('"three" == getline("$")')
call assert_equal('one', getline(line('$') - 2))
call assert_equal('two', getline(line('$') - 1))
call assert_equal('three', getline('$'))
***************
*** 281,292 ****
" Test that it works while waiting on a numbered message.
call assert_equal('ok', ch_evalexpr(handle, 'call me'))
! sleep 10m
call assert_equal('we called you', s:reply)
" Test that it works while not waiting on a numbered message.
call ch_sendexpr(handle, 'call me again')
! sleep 10m
call assert_equal('we did call you', s:reply)
endfunc
--- 289,300 ----
" Test that it works while waiting on a numbered message.
call assert_equal('ok', ch_evalexpr(handle, 'call me'))
! call s:waitFor('"we called you" == s:reply')
call assert_equal('we called you', s:reply)
" Test that it works while not waiting on a numbered message.
call ch_sendexpr(handle, 'call me again')
! call s:waitFor('"we did call you" == s:reply')
call assert_equal('we did call you', s:reply)
endfunc
***************
*** 326,335 ****
" Check that eval works if a zero id message is sent back.
let s:ch_reply = ''
call assert_equal('sent zero', ch_evalexpr(handle, 'send zero'))
- sleep 10m
if s:has_handler
call assert_equal('zero index', s:ch_reply)
else
call assert_equal('', s:ch_reply)
endif
--- 334,344 ----
" Check that eval works if a zero id message is sent back.
let s:ch_reply = ''
call assert_equal('sent zero', ch_evalexpr(handle, 'send zero'))
if s:has_handler
+ call s:waitFor('"zero index" == s:ch_reply')
call assert_equal('zero index', s:ch_reply)
else
+ sleep 20m
call assert_equal('', s:ch_reply)
endif
***************
*** 337,349 ****
let s:ch_reply = ''
let s:zero_reply = ''
call ch_sendexpr(handle, 'send zero', {'callback': 's:OneHandler'})
! " Somehow the second message takes a bit of time.
! for i in range(50)
! if s:zero_reply == 'sent zero'
! break
! endif
! sleep 10m
! endfor
if s:has_handler
call assert_equal('zero index', s:ch_reply)
else
--- 346,352 ----
let s:ch_reply = ''
let s:zero_reply = ''
call ch_sendexpr(handle, 'send zero', {'callback': 's:OneHandler'})
! call s:waitFor('"sent zero" == s:zero_reply')
if s:has_handler
call assert_equal('zero index', s:ch_reply)
else
***************
*** 395,423 ****
" The message are sent raw, we do our own JSON strings here.
call ch_sendraw(handle, "[1, \"hello!\"]", {'callback': 's:HandleRaw1'})
! for i in range(50)
! sleep 10m
! if s:reply1 != ''
! break
! endif
! endfor
call assert_equal("[1, \"got it\"]", s:reply1)
call ch_sendraw(handle, "[2, \"echo something\"]", {'callback':
's:HandleRaw2'})
call ch_sendraw(handle, "[3, \"wait a bit\"]", {'callback': 's:HandleRaw3'})
! for i in range(50)
! sleep 10m
! if s:reply2 != ''
! break
! endif
! endfor
call assert_equal("[2, \"something\"]", s:reply2)
! " wait for up to 500 msec for the 200 msec delayed reply
! for i in range(50)
! sleep 10m
! if s:reply3 != ''
! break
! endif
! endfor
call assert_equal("[3, \"waited\"]", s:reply3)
endfunc
--- 398,411 ----
" The message are sent raw, we do our own JSON strings here.
call ch_sendraw(handle, "[1, \"hello!\"]", {'callback': 's:HandleRaw1'})
! call s:waitFor('s:reply1 != ""')
call assert_equal("[1, \"got it\"]", s:reply1)
call ch_sendraw(handle, "[2, \"echo something\"]", {'callback':
's:HandleRaw2'})
call ch_sendraw(handle, "[3, \"wait a bit\"]", {'callback': 's:HandleRaw3'})
! call s:waitFor('s:reply2 != ""')
call assert_equal("[2, \"something\"]", s:reply2)
! " wait for the 200 msec delayed reply
! call s:waitFor('s:reply3 != ""')
call assert_equal("[3, \"waited\"]", s:reply3)
endfunc
***************
*** 572,583 ****
call ch_sendraw(handle, "echo line one\n")
call ch_sendraw(handle, "echo line two\n")
call ch_sendraw(handle, "double this\n")
! for i in range(50)
! sleep 10m
! if len(readfile('Xoutput')) > 2
! break
! endif
! endfor
call assert_equal(['line one', 'line two', 'this', 'AND this'],
readfile('Xoutput'))
finally
call job_stop(job)
--- 560,566 ----
call ch_sendraw(handle, "echo line one\n")
call ch_sendraw(handle, "echo line two\n")
call ch_sendraw(handle, "double this\n")
! call s:waitFor('len(readfile("Xoutput")) > 2')
call assert_equal(['line one', 'line two', 'this', 'AND this'],
readfile('Xoutput'))
finally
call job_stop(job)
***************
*** 602,613 ****
call ch_sendraw(handle, "echoerr line one\n")
call ch_sendraw(handle, "echoerr line two\n")
call ch_sendraw(handle, "doubleerr this\n")
! for i in range(50)
! sleep 10m
! if len(readfile('Xoutput')) > 2
! break
! endif
! endfor
call assert_equal(['line one', 'line two', 'this', 'AND this'],
readfile('Xoutput'))
finally
call job_stop(job)
--- 585,591 ----
call ch_sendraw(handle, "echoerr line one\n")
call ch_sendraw(handle, "echoerr line two\n")
call ch_sendraw(handle, "doubleerr this\n")
! call s:waitFor('len(readfile("Xoutput")) > 2')
call assert_equal(['line one', 'line two', 'this', 'AND this'],
readfile('Xoutput'))
finally
call job_stop(job)
***************
*** 633,644 ****
call ch_sendraw(handle, "echo line two\n")
call ch_sendraw(handle, "double this\n")
call ch_sendraw(handle, "doubleerr that\n")
! for i in range(50)
! sleep 10m
! if len(readfile('Xoutput')) > 5
! break
! endif
! endfor
call assert_equal(['line one', 'line two', 'this', 'AND this', 'that',
'AND that'], readfile('Xoutput'))
finally
call job_stop(job)
--- 611,617 ----
call ch_sendraw(handle, "echo line two\n")
call ch_sendraw(handle, "double this\n")
call ch_sendraw(handle, "doubleerr that\n")
! call s:waitFor('len(readfile("Xoutput")) > 5')
call assert_equal(['line one', 'line two', 'this', 'AND this', 'that',
'AND that'], readfile('Xoutput'))
finally
call job_stop(job)
***************
*** 661,672 ****
call ch_sendraw(handle, "double this\n")
call ch_sendraw(handle, "quit\n")
sp pipe-output
! for i in range(100)
! sleep 10m
! if line('$') >= 6
! break
! endif
! endfor
call assert_equal(['Reading from channel output...', 'line one', 'line
two', 'this', 'AND this', 'Goodbye!'], getline(1, '$'))
bwipe!
finally
--- 634,640 ----
call ch_sendraw(handle, "double this\n")
call ch_sendraw(handle, "quit\n")
sp pipe-output
! call s:waitFor('line("$") >= 6')
call assert_equal(['Reading from channel output...', 'line one', 'line
two', 'this', 'AND this', 'Goodbye!'], getline(1, '$'))
bwipe!
finally
***************
*** 710,721 ****
call ch_sendraw(handle, "echo line one\n")
call ch_sendraw(handle, "echo line two\n")
exe ch_getbufnr(handle, "out") . 'sbuf'
! for i in range(100)
! sleep 10m
! if line('$') >= 3
! break
! endif
! endfor
call assert_equal(['Reading from channel output...', 'line one', 'line
two'], getline(1, '$'))
bwipe!
finally
--- 678,684 ----
call ch_sendraw(handle, "echo line one\n")
call ch_sendraw(handle, "echo line two\n")
exe ch_getbufnr(handle, "out") . 'sbuf'
! call s:waitFor('line("$") >= 3')
call assert_equal(['Reading from channel output...', 'line one', 'line
two'], getline(1, '$'))
bwipe!
finally
***************
*** 736,747 ****
call ch_sendraw(handle, "echo [0, \"hello\"]\n")
call ch_sendraw(handle, "echo [-2, 12.34]\n")
exe ch_getbufnr(handle, "out") . 'sbuf'
! for i in range(100)
! sleep 10m
! if line('$') >= 3
! break
! endif
! endfor
call assert_equal(['Reading from channel output...', '[0,"hello"]',
'[-2,12.34]'], getline(1, '$'))
bwipe!
finally
--- 699,705 ----
call ch_sendraw(handle, "echo [0, \"hello\"]\n")
call ch_sendraw(handle, "echo [-2, 12.34]\n")
exe ch_getbufnr(handle, "out") . 'sbuf'
! call s:waitFor('line("$") >= 3')
call assert_equal(['Reading from channel output...', '[0,"hello"]',
'[-2,12.34]'], getline(1, '$'))
bwipe!
finally
***************
*** 750,761 ****
endfunc
" Wait a little while for the last line, minus "offset", to equal "line".
! func Wait_for_last_line(line, offset)
for i in range(100)
- sleep 10m
if getline(line('$') - a:offset) == a:line
break
endif
endfor
endfunc
--- 708,719 ----
endfunc
" Wait a little while for the last line, minus "offset", to equal "line".
! func s:wait_for_last_line(line, offset)
for i in range(100)
if getline(line('$') - a:offset) == a:line
break
endif
+ sleep 10m
endfor
endfunc
***************
*** 778,790 ****
try
exe "normal Gaecho hello\<CR>"
exe bufwinnr('pipe-output') . "wincmd w"
! call Wait_for_last_line('hello', 0)
call assert_equal('hello', getline('$'))
exe bufwinnr('pipe-input') . "wincmd w"
exe "normal Gadouble this\<CR>"
exe bufwinnr('pipe-output') . "wincmd w"
! call Wait_for_last_line('AND this', 0)
call assert_equal('this', getline(line('$') - 1))
call assert_equal('AND this', getline('$'))
--- 736,748 ----
try
exe "normal Gaecho hello\<CR>"
exe bufwinnr('pipe-output') . "wincmd w"
! call s:wait_for_last_line('hello', 0)
call assert_equal('hello', getline('$'))
exe bufwinnr('pipe-input') . "wincmd w"
exe "normal Gadouble this\<CR>"
exe bufwinnr('pipe-output') . "wincmd w"
! call s:wait_for_last_line('AND this', 0)
call assert_equal('this', getline(line('$') - 1))
call assert_equal('AND this', getline('$'))
***************
*** 812,822 ****
call assert_equal("run", job_status(job))
try
exe "normal Goecho hello\<CR>"
! call Wait_for_last_line('hello', 1)
call assert_equal('hello', getline(line('$') - 1))
exe "normal Gadouble this\<CR>"
! call Wait_for_last_line('AND this', 1)
call assert_equal('this', getline(line('$') - 2))
call assert_equal('AND this', getline(line('$') - 1))
--- 770,780 ----
call assert_equal("run", job_status(job))
try
exe "normal Goecho hello\<CR>"
! call s:wait_for_last_line('hello', 1)
call assert_equal('hello', getline(line('$') - 1))
exe "normal Gadouble this\<CR>"
! call s:wait_for_last_line('AND this', 1)
call assert_equal('this', getline(line('$') - 2))
call assert_equal('AND this', getline(line('$') - 1))
***************
*** 838,844 ****
func s:unlet_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
call ch_sendexpr(s:channelfd, "test", {'callback':
function('s:UnletHandler')})
! sleep 10m
call assert_equal('what?', s:unletResponse)
endfunc
--- 796,802 ----
func s:unlet_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
call ch_sendexpr(s:channelfd, "test", {'callback':
function('s:UnletHandler')})
! call s:waitFor('"what?" == s:unletResponse')
call assert_equal('what?', s:unletResponse)
endfunc
***************
*** 859,865 ****
func s:close_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
call ch_sendexpr(s:channelfd, "test", {'callback':
function('s:CloseHandler')})
! sleep 10m
call assert_equal('what?', s:unletResponse)
endfunc
--- 817,823 ----
func s:close_handle(port)
let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
call ch_sendexpr(s:channelfd, "test", {'callback':
function('s:CloseHandler')})
! call s:waitFor('"what?" == s:unletResponse')
call assert_equal('what?', s:unletResponse)
endfunc
***************
*** 911,918 ****
return
endif
call assert_equal('ok', ch_evalexpr(handle, 'call-func'))
! sleep 20m
call assert_equal([1, 2, 3], s:call_ret)
endfunc
--- 869,877 ----
return
endif
+ let s:call_ret = []
call assert_equal('ok', ch_evalexpr(handle, 'call-func'))
! call s:waitFor('len(s:call_ret) > 0')
call assert_equal([1, 2, 3], s:call_ret)
endfunc
***************
*** 969,975 ****
call ch_setoptions(handle, {'close-cb': 'MyCloseCb'})
call assert_equal('', ch_evalexpr(handle, 'close me'))
! sleep 20m
call assert_equal('closed', s:ch_close_ret)
endfunc
--- 928,934 ----
call ch_setoptions(handle, {'close-cb': 'MyCloseCb'})
call assert_equal('', ch_evalexpr(handle, 'close me'))
! call s:waitFor('"closed" == s:ch_close_ret')
call assert_equal('closed', s:ch_close_ret)
endfunc
*** ../vim-7.4.1514/src/version.c 2016-03-08 15:37:36.734963213 +0100
--- src/version.c 2016-03-08 16:05:57.473290606 +0100
***************
*** 745,746 ****
--- 745,748 ----
{ /* Add new patch number below this line */
+ /**/
+ 1515,
/**/
--
"How is your new girlfriend?"
"90-60-90 man!"
"What, pale purple?"
/// 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.