comparison src/testdir/test_channel.vim @ 10309:88331ee68367 v8.0.0050

commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 27 20:00:07 2016 +0200 patch 8.0.0050 Problem: An exiting job is detected with a large latency. Solution: Check for pending job more often. (Ozaki Kiichi) Change the double loop in mch_inchar() into one.
author Christian Brabandt <cb@256bit.org>
date Thu, 27 Oct 2016 20:15:04 +0200
parents c90f4cc9c3fe
children d3f0946b4a80
comparison
equal deleted inserted replaced
10308:c6e8a776a1ed 10309:88331ee68367
1360 call assert_equal('dead', job_info(g:Ch_exit_job).status) 1360 call assert_equal('dead', job_info(g:Ch_exit_job).status)
1361 unlet g:Ch_exit_job 1361 unlet g:Ch_exit_job
1362 endif 1362 endif
1363 endfunc 1363 endfunc
1364 1364
1365 let g:exit_cb_time = {'start': 0, 'end': 0}
1366 function MyExitTimeCb(job, status) 1365 function MyExitTimeCb(job, status)
1367 let g:exit_cb_time.end = reltime(g:exit_cb_time.start) 1366 if job_info(a:job).process == g:exit_cb_val.process
1367 let g:exit_cb_val.end = reltime(g:exit_cb_val.start)
1368 endif
1369 call Resume()
1368 endfunction 1370 endfunction
1369 1371
1370 func Test_exit_callback_interval() 1372 func Test_exit_callback_interval()
1371 if !has('job') 1373 if !has('job')
1372 return 1374 return
1373 endif 1375 endif
1374 1376
1375 let g:exit_cb_time.start = reltime() 1377 let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0}
1376 let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'}) 1378 let job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'})
1377 call WaitFor('g:exit_cb_time.end != 0') 1379 let g:exit_cb_val.process = job_info(job).process
1378 let elapsed = reltimefloat(g:exit_cb_time.end) 1380 call WaitFor('type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0')
1379 call assert_true(elapsed > 0.3) 1381 let elapsed = reltimefloat(g:exit_cb_val.end)
1382 call assert_true(elapsed > 0.5)
1383 call assert_true(elapsed < 1.0)
1384
1385 " case: unreferenced job, using timer
1386 if !has('timers')
1387 return
1388 endif
1389
1390 let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0}
1391 let g:job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'})
1392 let g:exit_cb_val.process = job_info(g:job).process
1393 unlet g:job
1394 call Standby(1000)
1395 if type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0
1396 let elapsed = reltimefloat(g:exit_cb_val.end)
1397 else
1398 let elapsed = 1.0
1399 endif
1400 call assert_true(elapsed > 0.5)
1380 call assert_true(elapsed < 1.0) 1401 call assert_true(elapsed < 1.0)
1381 endfunc 1402 endfunc
1382 1403
1383 """"""""" 1404 """""""""
1384 1405