diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-01-09 22:24:49 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-01-09 22:24:49 +0100 |
commit | c46af534102c65b43912311d67f55f5049e5ef7a (patch) | |
tree | fe6c4a5e5a9bec3d2760a47534ef3f4427184e63 /src/testdir/test_channel.vim | |
parent | 27a472c32ed5b5298bca50864570a4a71ec1d204 (diff) |
patch 8.1.0710: when using timers may wait for job exit quite longv8.1.0710
Problem: When using timers may wait for job exit quite long.
Solution: Return from ui_wait_for_chars_or_timer() when a job or channel
needs to be handled. (Ozaki Kiichi, closes #3783)
Diffstat (limited to 'src/testdir/test_channel.vim')
-rw-r--r-- | src/testdir/test_channel.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index f5ee7c086c..8f4fb0fdcd 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1893,3 +1893,40 @@ func Test_keep_pty_open() call assert_inrange(200, 1000, elapsed) call job_stop(job) endfunc + +func Test_job_start_in_timer() + if !has('job') || !has('timers') + return + endif + + func OutCb(chan, msg) + endfunc + + func ExitCb(job, status) + let g:val = 1 + call Resume() + endfunc + + func TimerCb(timer) + if has('win32') + let cmd = ['cmd', '/c', 'echo.'] + else + let cmd = ['echo'] + endif + let g:job = job_start(cmd, {'out_cb': 'OutCb', 'exit_cb': 'ExitCb'}) + call substitute(repeat('a', 100000), '.', '', 'g') + endfunc + + " We should be interrupted before 'updatetime' elapsed. + let g:val = 0 + call timer_start(1, 'TimerCb') + let elapsed = Standby(&ut) + call assert_inrange(1, &ut / 2, elapsed) + call job_stop(g:job) + + delfunc OutCb + delfunc ExitCb + delfunc TimerCb + unlet! g:val + unlet! g:job +endfunc |