comparison src/testdir/test_channel.vim @ 9003:072556995a8e v7.4.1787

commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 26 17:16:24 2016 +0200 patch 7.4.1787 Problem: When a job ends the close callback is invoked before other callbacks. On Windows the close callback is not called. Solution: First invoke out/err callbacks before the close callback. Make the close callback work on Windows.
author Christian Brabandt <cb@256bit.org>
date Tue, 26 Apr 2016 17:30:05 +0200
parents ed0b39dd7fd6
children d5c6f1c5cd28
comparison
equal deleted inserted replaced
9002:67438eefdbac 9003:072556995a8e
1046 finally 1046 finally
1047 call job_stop(job) 1047 call job_stop(job)
1048 endtry 1048 endtry
1049 endfunc 1049 endfunc
1050 1050
1051 func Test_out_close_cb()
1052 if !has('job')
1053 return
1054 endif
1055 call ch_log('Test_out_close_cb()')
1056
1057 let s:counter = 1
1058 let s:outmsg = 0
1059 let s:closemsg = 0
1060 func! OutHandler(chan, msg)
1061 let s:outmsg = s:counter
1062 let s:counter += 1
1063 endfunc
1064 func! CloseHandler(chan)
1065 let s:closemsg = s:counter
1066 let s:counter += 1
1067 endfunc
1068 let job = job_start(s:python . " test_channel_pipe.py quit now",
1069 \ {'out_cb': 'OutHandler',
1070 \ 'close_cb': 'CloseHandler'})
1071 call assert_equal("run", job_status(job))
1072 try
1073 call s:waitFor('s:closemsg != 0 && s:outmsg != 0')
1074 call assert_equal(1, s:outmsg)
1075 call assert_equal(2, s:closemsg)
1076 finally
1077 call job_stop(job)
1078 delfunc OutHandler
1079 delfunc CloseHandler
1080 endtry
1081 endfunc
1082
1051 """""""""" 1083 """"""""""
1052 1084
1053 let s:unletResponse = '' 1085 let s:unletResponse = ''
1054 func s:UnletHandler(handle, msg) 1086 func s:UnletHandler(handle, msg)
1055 let s:unletResponse = a:msg 1087 let s:unletResponse = a:msg