forked from aniani/vim
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Problem: When WaitFor() has a wrong expression it just waits a second, which goes unnoticed. (James McCoy) Solution: When WaitFor() times out throw an exception. Fix places where the expression was wrong.
This commit is contained in:
@@ -139,7 +139,7 @@ func WaitFor(expr, ...)
|
|||||||
endif
|
endif
|
||||||
sleep 10m
|
sleep 10m
|
||||||
endfor
|
endfor
|
||||||
return timeout
|
throw 'WaitFor() timed out after ' . timeout . ' msec'
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Wait for up to a given milliseconds.
|
" Wait for up to a given milliseconds.
|
||||||
|
@@ -709,7 +709,7 @@ func Run_test_pipe_to_buffer(use_name, nomod, do_msg)
|
|||||||
call ch_sendraw(handle, "double this\n")
|
call ch_sendraw(handle, "double this\n")
|
||||||
call ch_sendraw(handle, "quit\n")
|
call ch_sendraw(handle, "quit\n")
|
||||||
sp pipe-output
|
sp pipe-output
|
||||||
call WaitFor('line("$") >= 6 && g:Ch_bufClosed == "yes"')
|
call WaitFor('line("$") == ' . len(expected) . ' && g:Ch_bufClosed == "yes"')
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
if a:nomod
|
if a:nomod
|
||||||
call assert_equal(0, &modifiable)
|
call assert_equal(0, &modifiable)
|
||||||
@@ -804,7 +804,7 @@ func Run_test_pipe_err_to_buffer(use_name, nomod, do_msg)
|
|||||||
call ch_sendraw(handle, "doubleerr this\n")
|
call ch_sendraw(handle, "doubleerr this\n")
|
||||||
call ch_sendraw(handle, "quit\n")
|
call ch_sendraw(handle, "quit\n")
|
||||||
sp pipe-err
|
sp pipe-err
|
||||||
call WaitFor('line("$") >= 5')
|
call WaitFor('line("$") == ' . len(expected))
|
||||||
call assert_equal(expected, getline(1, '$'))
|
call assert_equal(expected, getline(1, '$'))
|
||||||
if a:nomod
|
if a:nomod
|
||||||
call assert_equal(0, &modifiable)
|
call assert_equal(0, &modifiable)
|
||||||
@@ -1130,12 +1130,14 @@ func Test_pipe_to_buffer_raw()
|
|||||||
let job = job_start([s:python, '-c',
|
let job = job_start([s:python, '-c',
|
||||||
\ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
|
\ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
|
||||||
call assert_equal("run", job_status(job))
|
call assert_equal("run", job_status(job))
|
||||||
call WaitFor('len(join(getline(2,line("$")),"") >= 10000')
|
call WaitFor('len(join(getline(1, "$"), "")) >= 10000', 3000)
|
||||||
try
|
try
|
||||||
for line in getline(2, '$')
|
let totlen = 0
|
||||||
let line = substitute(line, '^\.*', '', '')
|
for line in getline(1, '$')
|
||||||
call assert_equal('', line)
|
call assert_equal('', substitute(line, '^\.*', '', ''))
|
||||||
|
let totlen += len(line)
|
||||||
endfor
|
endfor
|
||||||
|
call assert_equal(10000, totlen)
|
||||||
finally
|
finally
|
||||||
call job_stop(job)
|
call job_stop(job)
|
||||||
bwipe!
|
bwipe!
|
||||||
@@ -1300,24 +1302,25 @@ func Test_close_and_exit_cb()
|
|||||||
endif
|
endif
|
||||||
call ch_log('Test_close_and_exit_cb')
|
call ch_log('Test_close_and_exit_cb')
|
||||||
|
|
||||||
let dict = {'ret': {}}
|
let g:retdict = {'ret': {}}
|
||||||
func dict.close_cb(ch) dict
|
func g:retdict.close_cb(ch) dict
|
||||||
let self.ret['close_cb'] = job_status(ch_getjob(a:ch))
|
let self.ret['close_cb'] = job_status(ch_getjob(a:ch))
|
||||||
endfunc
|
endfunc
|
||||||
func dict.exit_cb(job, status) dict
|
func g:retdict.exit_cb(job, status) dict
|
||||||
let self.ret['exit_cb'] = job_status(a:job)
|
let self.ret['exit_cb'] = job_status(a:job)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
let g:job = job_start('echo', {
|
let g:job = job_start('echo', {
|
||||||
\ 'close_cb': dict.close_cb,
|
\ 'close_cb': g:retdict.close_cb,
|
||||||
\ 'exit_cb': dict.exit_cb,
|
\ 'exit_cb': g:retdict.exit_cb,
|
||||||
\ })
|
\ })
|
||||||
call assert_equal('run', job_status(g:job))
|
call assert_equal('run', job_status(g:job))
|
||||||
unlet g:job
|
unlet g:job
|
||||||
call WaitFor('len(dict.ret) >= 2')
|
call WaitFor('len(g:retdict.ret) >= 2')
|
||||||
call assert_equal(2, len(dict.ret))
|
call assert_equal(2, len(g:retdict.ret))
|
||||||
call assert_match('^\%(dead\|run\)', dict.ret['close_cb'])
|
call assert_match('^\%(dead\|run\)', g:retdict.ret['close_cb'])
|
||||||
call assert_equal('dead', dict.ret['exit_cb'])
|
call assert_equal('dead', g:retdict.ret['exit_cb'])
|
||||||
|
unlet g:retdict
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
""""""""""
|
""""""""""
|
||||||
@@ -1547,13 +1550,14 @@ func Test_job_stop_immediately()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
|
let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)'])
|
||||||
try
|
try
|
||||||
call job_stop(job)
|
call job_stop(g:job)
|
||||||
call WaitFor('"dead" == job_status(job)')
|
call WaitFor('"dead" == job_status(g:job)')
|
||||||
call assert_equal('dead', job_status(job))
|
call assert_equal('dead', job_status(g:job))
|
||||||
finally
|
finally
|
||||||
call job_stop(job, 'kill')
|
call job_stop(g:job, 'kill')
|
||||||
|
unlet g:job
|
||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -1585,7 +1589,7 @@ func Test_collapse_buffers()
|
|||||||
split testout
|
split testout
|
||||||
1,$delete
|
1,$delete
|
||||||
call job_start('cat test_channel.vim', {'out_io': 'buffer', 'out_name': 'testout'})
|
call job_start('cat test_channel.vim', {'out_io': 'buffer', 'out_name': 'testout'})
|
||||||
call WaitFor('line("$") > g:linecount')
|
call WaitFor('line("$") >= g:linecount')
|
||||||
call assert_inrange(g:linecount, g:linecount + 1, line('$'))
|
call assert_inrange(g:linecount, g:linecount + 1, line('$'))
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -27,7 +27,7 @@ func Nb_basic(port)
|
|||||||
|
|
||||||
" Opening README.txt will result in a setDot command
|
" Opening README.txt will result in a setDot command
|
||||||
call WaitFor('len(readfile("Xnetbeans")) > 4')
|
call WaitFor('len(readfile("Xnetbeans")) > 4')
|
||||||
call WaitFor('getcurpos()[1] == 2')
|
call WaitFor('getcurpos()[1] == 3')
|
||||||
let pos = getcurpos()
|
let pos = getcurpos()
|
||||||
call assert_equal(3, pos[1])
|
call assert_equal(3, pos[1])
|
||||||
call assert_equal(20, pos[2])
|
call assert_equal(20, pos[2])
|
||||||
|
@@ -705,7 +705,7 @@ func Test_terminal_composing_unicode()
|
|||||||
|
|
||||||
enew
|
enew
|
||||||
let buf = term_start(cmd, {'curwin': bufnr('')})
|
let buf = term_start(cmd, {'curwin': bufnr('')})
|
||||||
let job = term_getjob(buf)
|
let g:job = term_getjob(buf)
|
||||||
call term_wait(buf, 50)
|
call term_wait(buf, 50)
|
||||||
|
|
||||||
" ascii + composing
|
" ascii + composing
|
||||||
@@ -742,8 +742,9 @@ func Test_terminal_composing_unicode()
|
|||||||
call assert_equal("\u00a0\u0308", l[3].chars)
|
call assert_equal("\u00a0\u0308", l[3].chars)
|
||||||
|
|
||||||
call term_sendkeys(buf, "exit\r")
|
call term_sendkeys(buf, "exit\r")
|
||||||
call WaitFor('job_status(job) == "dead"')
|
call WaitFor('job_status(g:job) == "dead"')
|
||||||
call assert_equal('dead', job_status(job))
|
call assert_equal('dead', job_status(g:job))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
unlet g:job
|
||||||
let &encoding = save_enc
|
let &encoding = save_enc
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1245,
|
||||||
/**/
|
/**/
|
||||||
1244,
|
1244,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user