comparison src/testdir/test_channel.vim @ 15404:440e5071f3f8 v8.1.0710

patch 8.1.0710: when using timers may wait for job exit quite long commit https://github.com/vim/vim/commit/c46af534102c65b43912311d67f55f5049e5ef7a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 9 22:24:49 2019 +0100 patch 8.1.0710: when using timers may wait for job exit quite long 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)
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Jan 2019 22:30:06 +0100
parents cda564e7c111
children 1d2b5c016f17
comparison
equal deleted inserted replaced
15403:62e66e6b2c79 15404:440e5071f3f8
1891 let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', {'out_io': 'null', 'err_io': 'null', 'pty': 1}) 1891 let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', {'out_io': 'null', 'err_io': 'null', 'pty': 1})
1892 let elapsed = WaitFor({-> job_status(job) ==# 'dead'}) 1892 let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
1893 call assert_inrange(200, 1000, elapsed) 1893 call assert_inrange(200, 1000, elapsed)
1894 call job_stop(job) 1894 call job_stop(job)
1895 endfunc 1895 endfunc
1896
1897 func Test_job_start_in_timer()
1898 if !has('job') || !has('timers')
1899 return
1900 endif
1901
1902 func OutCb(chan, msg)
1903 endfunc
1904
1905 func ExitCb(job, status)
1906 let g:val = 1
1907 call Resume()
1908 endfunc
1909
1910 func TimerCb(timer)
1911 if has('win32')
1912 let cmd = ['cmd', '/c', 'echo.']
1913 else
1914 let cmd = ['echo']
1915 endif
1916 let g:job = job_start(cmd, {'out_cb': 'OutCb', 'exit_cb': 'ExitCb'})
1917 call substitute(repeat('a', 100000), '.', '', 'g')
1918 endfunc
1919
1920 " We should be interrupted before 'updatetime' elapsed.
1921 let g:val = 0
1922 call timer_start(1, 'TimerCb')
1923 let elapsed = Standby(&ut)
1924 call assert_inrange(1, &ut / 2, elapsed)
1925 call job_stop(g:job)
1926
1927 delfunc OutCb
1928 delfunc ExitCb
1929 delfunc TimerCb
1930 unlet! g:val
1931 unlet! g:job
1932 endfunc