From fe9cbcb3a5c82932ecfb8f49d07e98a1fc2b31e5 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sat, 25 Mar 2023 18:58:48 +0200 Subject: feat(api): nvim_exec2(), deprecate nvim_exec() #19032 Problem: The signature of nvim_exec() is not extensible per ":help api-contract". Solution: Introduce nvim_exec2() and deprecate nvim_exec(). --- test/functional/core/remote_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 846d79abf3..b2a1679023 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -101,7 +101,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(meths.exec2('messages', { output = true }).output, 'E247')) end) it('creates server if not found with tabs', function() @@ -110,7 +110,7 @@ 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(meths.exec2('messages', { output = true }).output, 'E247')) end) pending('exits with error on', function() -- cgit From 4863ca6b8902c5b0aab95f2af640118cd417d379 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Mar 2023 10:49:32 +0800 Subject: test: use exec_capture() in more places (#22787) Problem: Using `meths.exec2("code", { output = true })` is too verbose. Solution: Use exec_capture() in more places. --- test/functional/core/remote_spec.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index b2a1679023..f74bb65553 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -3,11 +3,11 @@ 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 new_argv = helpers.new_argv local neq = helpers.neq local set_session = helpers.set_session @@ -101,7 +101,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.exec2('messages', { output = true }).output, 'E247')) + neq(nil, string.find(exec_capture('messages'), 'E247:')) end) it('creates server if not found with tabs', function() @@ -110,7 +110,7 @@ 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.exec2('messages', { output = true }).output, 'E247')) + eq(nil, string.find(exec_capture('messages'), 'E247:')) end) pending('exits with error on', function() -- cgit From cce9460524aa17bcd4daa095f4706220b81f8845 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 15:29:51 +0800 Subject: fix(remote): make --remote-expr print to stdout (#23980) --- test/functional/core/remote_spec.lua | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index f74bb65553..23aab400df 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -8,6 +8,8 @@ local exec_lua = helpers.exec_lua local expect = helpers.expect local funcs = helpers.funcs local insert = helpers.insert +local is_os = helpers.is_os +local nvim_prog = helpers.nvim_prog local new_argv = helpers.new_argv local neq = helpers.neq local set_session = helpers.set_session @@ -38,10 +40,11 @@ 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, ...}}) + local client_argv = { nvim_prog, '--clean', '--headless', '--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 +53,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, + }) })]], client_argv)) + 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 +97,7 @@ describe('Remote', function() end) it('send keys', function() - run_remote('--remote-send', ':edit '..fname..'v') + eq({ '', '' }, run_remote('--remote-send', ':edit '..fname..'v')) expect(contents) eq(2, #funcs.getwininfo()) -- Only a single buffer as we're using edit and not drop like --remote does @@ -91,7 +105,9 @@ describe('Remote', function() end) it('evaluate expressions', function() - run_remote('--remote-expr', 'setline(1, "Yo")') + local linesep = is_os('win') and '\r\n' or '\n' + eq({ "function('get')" .. linesep, '' }, run_remote('--remote-expr', 'function("get")')) + eq({ '0' .. linesep, '' }, run_remote('--remote-expr', 'setline(1, "Yo")')) expect('Yo') end) end) @@ -113,7 +129,7 @@ describe('Remote', function() 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(...) -- cgit From bde59e81473f29944ef80ff98f6b2c88010b2df6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 11 Jun 2023 22:12:32 +0800 Subject: fix(remote): restore previous --remote-expr output formatting (#23988) - Use tostring() as that's what print() uses internally. - Do not append trailing new line. --- test/functional/core/remote_spec.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 23aab400df..20650bef52 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -8,7 +8,6 @@ local exec_lua = helpers.exec_lua local expect = helpers.expect local funcs = helpers.funcs local insert = helpers.insert -local is_os = helpers.is_os local nvim_prog = helpers.nvim_prog local new_argv = helpers.new_argv local neq = helpers.neq @@ -105,10 +104,12 @@ describe('Remote', function() end) it('evaluate expressions', function() - local linesep = is_os('win') and '\r\n' or '\n' - eq({ "function('get')" .. linesep, '' }, run_remote('--remote-expr', 'function("get")')) - eq({ '0' .. linesep, '' }, 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({ '1.25', '' }, run_remote('--remote-expr', '1.25')) + eq({ 'no', '' }, run_remote('--remote-expr', '0z6E6F')) + eq({ '\t', '' }, run_remote('--remote-expr', '"\t"')) end) end) -- cgit From 628f6cce80dea9ef15e23a3ded77dc3f0c912b51 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 1 Jul 2023 08:16:34 +0800 Subject: fix(startup): don't truncate when printing with -l (#24216) --- test/functional/core/remote_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 20650bef52..39b1ee2f5f 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -107,6 +107,7 @@ describe('Remote', function() 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"')) -- cgit From c0fa721adeabf1d93ad71e598782b52c43d8e8f7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 25 Jul 2023 19:02:39 +0800 Subject: fix(startup): make recovery mode work without --headless (#24477) --- test/functional/core/remote_spec.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/functional/core/remote_spec.lua') diff --git a/test/functional/core/remote_spec.lua b/test/functional/core/remote_spec.lua index 39b1ee2f5f..a0ec748446 100644 --- a/test/functional/core/remote_spec.lua +++ b/test/functional/core/remote_spec.lua @@ -43,7 +43,6 @@ describe('Remote', function() local function run_remote(...) set_session(server) local addr = funcs.serverlist()[1] - local client_argv = { nvim_prog, '--clean', '--headless', '--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 @@ -52,7 +51,7 @@ 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(..., { + eq({ 0 }, exec_lua([[return vim.fn.jobwait({ vim.fn.jobstart({...}, { stdout_buffered = true, stderr_buffered = true, on_stdout = function(_, data, _) @@ -61,7 +60,7 @@ describe('Remote', function() on_stderr = function(_, data, _) _G.Remote_stderr = table.concat(data, '\n') end, - }) })]], client_argv)) + }) })]], nvim_prog, '--clean', '--headless', '--server', addr, ...)) local res = exec_lua([[return { _G.Remote_stdout, _G.Remote_stderr }]]) client_starter:close() set_session(server) -- cgit