diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2016-05-12 22:25:15 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2016-08-20 12:55:35 +0200 |
commit | 2d60a15e25f487eda1ac00a9e6cdf9a6564fb416 (patch) | |
tree | 7844b2d185b27a0303183e90792a5ef807933e88 /test/functional/api/server_requests_spec.lua | |
parent | 215922120c43163f4e1cc00851bd1b86890d3a28 (diff) | |
download | rneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.tar.gz rneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.tar.bz2 rneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.zip |
job control: reuse common job code for rpc jobs
This makes stderr and exit callbacks work for rpc jobs
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index eb63834cb0..b76c3b9cd6 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -4,7 +4,9 @@ local helpers = require('test.functional.helpers')(after_each) local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop -local nvim_prog = helpers.nvim_prog +local nvim_prog, command, funcs = helpers.nvim_prog, helpers.command, helpers.funcs +local source, next_message = helpers.source, helpers.next_message +local meths = helpers.meths describe('server -> client', function() @@ -144,11 +146,11 @@ describe('server -> client', function() end before_each(function() - nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile', '--embed'])") + command("let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile', '--embed'])") neq(0, eval('vim')) end) - after_each(function() nvim('command', 'call rpcstop(vim)') end) + after_each(function() command('call rpcstop(vim)') end) it('can send/recieve notifications and make requests', function() nvim('command', "call rpcnotify(vim, 'vim_set_current_line', 'SOME TEXT')") @@ -181,4 +183,42 @@ describe('server -> client', function() eq(true, string.match(err, ': (.*)') == 'Failed to evaluate expression') end) end) + + describe('when using jobstart', function() + local jobid + before_each(function() + local channel = nvim('get_api_info')[1] + nvim('set_var', 'channel', channel) + source([[ + function! s:OnEvent(id, data, event) + call rpcnotify(g:channel, a:event, 0, a:data) + endfunction + let g:job_opts = { + \ 'on_stderr': function('s:OnEvent'), + \ 'on_exit': function('s:OnEvent'), + \ 'user': 0, + \ 'rpc': v:true + \ } + ]]) + local lua_prog = arg[-1] + meths.set_var("args", {lua_prog, 'test/functional/api/rpc_fixture.lua'}) + jobid = eval("jobstart(g:args, g:job_opts)") + neq(0, 'jobid') + end) + + after_each(function() + funcs.jobstop(jobid) + end) + + it('rpc and text stderr can be combined', function() + eq("ok",funcs.rpcrequest(jobid, "poll")) + funcs.rpcnotify(jobid, "ping") + eq({'notification', 'pong', {}}, next_message()) + eq("done!",funcs.rpcrequest(jobid, "write_stderr", "fluff\n")) + eq({'notification', 'stderr', {0, {'fluff', ''}}}, next_message()) + funcs.rpcrequest(jobid, "exit") + eq({'notification', 'exit', {0, 0}}, next_message()) + end) + end) + end) |