diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-08-11 09:27:48 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-09-21 16:04:09 +0100 |
commit | e5c174421df3872df0dd3a676609d1e74dfef6a9 (patch) | |
tree | 39354b9db7b9f3ccb9145f52d11574baa4508951 /test/functional/lua/system_spec.lua | |
parent | a19e89022d8b72ee92bb974100b497f1c79b7765 (diff) | |
download | rneovim-e5c174421df3872df0dd3a676609d1e74dfef6a9.tar.gz rneovim-e5c174421df3872df0dd3a676609d1e74dfef6a9.tar.bz2 rneovim-e5c174421df3872df0dd3a676609d1e74dfef6a9.zip |
test: support upvalues in exec_lua
Diffstat (limited to 'test/functional/lua/system_spec.lua')
-rw-r--r-- | test/functional/lua/system_spec.lua | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua index e72a009d2e..482bfcf1a9 100644 --- a/test/functional/lua/system_spec.lua +++ b/test/functional/lua/system_spec.lua @@ -6,10 +6,8 @@ local exec_lua = n.exec_lua local eq = t.eq local function system_sync(cmd, opts) - return exec_lua( - [[ - local cmd, opts = ... - local obj = vim.system(...) + return exec_lua(function() + local obj = vim.system(cmd, opts) if opts.timeout then -- Minor delay before calling wait() so the timeout uv timer can have a headstart over the @@ -24,16 +22,11 @@ local function system_sync(cmd, opts) assert(not proc, 'process still exists') return res - ]], - cmd, - opts - ) + end) end local function system_async(cmd, opts) - return exec_lua( - [[ - local cmd, opts = ... + return exec_lua(function() _G.done = false local obj = vim.system(cmd, opts, function(obj) _G.done = true @@ -51,10 +44,7 @@ local function system_async(cmd, opts) assert(not proc, 'process still exists') return _G.ret - ]], - cmd, - opts - ) + end) end describe('vim.system', function() @@ -84,7 +74,7 @@ describe('vim.system', function() end it('kill processes', function() - exec_lua([[ + exec_lua(function() local signal local cmd = vim.system({ 'cat', '-' }, { stdin = true }, function(r) signal = r.signal @@ -104,19 +94,21 @@ describe('vim.system', function() assert(not proc, 'process still exists') assert(signal == 2) - ]]) + end) end) it('SystemObj:wait() does not process non-fast events #27292', function() eq( false, - exec_lua([[ + exec_lua(function() _G.processed = false local cmd = vim.system({ 'sleep', '1' }) - vim.schedule(function() _G.processed = true end) + vim.schedule(function() + _G.processed = true + end) cmd:wait() return _G.processed - ]]) + end) ) eq(true, exec_lua([[return _G.processed]])) end) |