diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 21:52:58 +0000 |
commit | 931bffbda3668ddc609fc1da8f9eb576b170aa52 (patch) | |
tree | d8c1843a95da5ea0bb4acc09f7e37843d9995c86 /test/functional/core/remote_spec.lua | |
parent | 142d9041391780ac15b89886a54015fdc5c73995 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-userreg.tar.gz rneovim-userreg.tar.bz2 rneovim-userreg.zip |
Merge remote-tracking branch 'upstream/master' into userreguserreg
Diffstat (limited to 'test/functional/core/remote_spec.lua')
-rw-r--r-- | test/functional/core/remote_spec.lua | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 846d79abf3..a0ec748446 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -3,11 +3,12 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local command = helpers.command local eq = helpers.eq +local exec_capture = helpers.exec_capture local exec_lua = helpers.exec_lua local expect = helpers.expect local funcs = helpers.funcs local insert = helpers.insert -local meths = helpers.meths +local nvim_prog = helpers.nvim_prog local new_argv = helpers.new_argv local neq = helpers.neq local set_session = helpers.set_session @@ -38,10 +39,10 @@ describe('Remote', function() server:close() end) + -- Run a `nvim --remote*` command and return { stdout, stderr } of the process local function run_remote(...) set_session(server) local addr = funcs.serverlist()[1] - local client_argv = new_argv({args={'--server', addr, ...}}) -- Create an nvim instance just to run the remote-invoking nvim. We want -- to wait for the remote instance to exit and calling jobwait blocks @@ -50,32 +51,43 @@ describe('Remote', function() local client_starter = spawn(new_argv(), false, nil, true) set_session(client_starter) -- Call jobstart() and jobwait() in the same RPC request to reduce flakiness. - eq({ 0 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart(...) })]], client_argv)) + eq({ 0 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart({...}, { + stdout_buffered = true, + stderr_buffered = true, + on_stdout = function(_, data, _) + _G.Remote_stdout = table.concat(data, '\n') + end, + on_stderr = function(_, data, _) + _G.Remote_stderr = table.concat(data, '\n') + end, + }) })]], nvim_prog, '--clean', '--headless', '--server', addr, ...)) + local res = exec_lua([[return { _G.Remote_stdout, _G.Remote_stderr }]]) client_starter:close() set_session(server) + return res end it('edit a single file', function() - run_remote('--remote', fname) + eq({ '', '' }, run_remote('--remote', fname)) expect(contents) eq(2, #funcs.getbufinfo()) end) it('tab edit a single file with a non-changed buffer', function() - run_remote('--remote-tab', fname) + eq({ '', '' }, run_remote('--remote-tab', fname)) expect(contents) eq(1, #funcs.gettabinfo()) end) it('tab edit a single file with a changed buffer', function() insert('hello') - run_remote('--remote-tab', fname) + eq({ '', '' }, run_remote('--remote-tab', fname)) expect(contents) eq(2, #funcs.gettabinfo()) end) it('edit multiple files', function() - run_remote('--remote', fname, other_fname) + eq({ '', '' }, run_remote('--remote', fname, other_fname)) expect(contents) command('next') expect(other_contents) @@ -83,7 +95,7 @@ describe('Remote', function() end) it('send keys', function() - run_remote('--remote-send', ':edit '..fname..'<CR><C-W>v') + eq({ '', '' }, run_remote('--remote-send', ':edit '..fname..'<CR><C-W>v')) expect(contents) eq(2, #funcs.getwininfo()) -- Only a single buffer as we're using edit and not drop like --remote does @@ -91,8 +103,13 @@ describe('Remote', function() end) it('evaluate expressions', function() - run_remote('--remote-expr', 'setline(1, "Yo")') + eq({ '0', '' }, run_remote('--remote-expr', 'setline(1, "Yo")')) + eq({ 'Yo', '' }, run_remote('--remote-expr', 'getline(1)')) expect('Yo') + eq({ ('k'):rep(1234), '' }, run_remote('--remote-expr', 'repeat("k", 1234)')) + eq({ '1.25', '' }, run_remote('--remote-expr', '1.25')) + eq({ 'no', '' }, run_remote('--remote-expr', '0z6E6F')) + eq({ '\t', '' }, run_remote('--remote-expr', '"\t"')) end) end) @@ -101,7 +118,7 @@ describe('Remote', function() expect(contents) eq(1, #funcs.getbufinfo()) -- Since we didn't pass silent, we should get a complaint - neq(nil, string.find(meths.exec('messages', true), 'E247')) + neq(nil, string.find(exec_capture('messages'), 'E247:')) end) it('creates server if not found with tabs', function() @@ -110,10 +127,10 @@ describe('Remote', function() eq(2, #funcs.gettabinfo()) eq(2, #funcs.getbufinfo()) -- We passed silent, so no message should be issued about the server not being found - eq(nil, string.find(meths.exec('messages', true), 'E247')) + eq(nil, string.find(exec_capture('messages'), 'E247:')) end) - pending('exits with error on', function() + describe('exits with error on', function() local function run_and_check_exit_code(...) local bogus_argv = new_argv(...) |