From 07db909eb5ae2a559771068be64439eba394cd61 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:50:30 +0100 Subject: docs: misc (#31138) Co-authored-by: zeertzjq --- test/functional/lua/system_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/lua/system_spec.lua') diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua index afbada007d..3f847ca3be 100644 --- a/test/functional/lua/system_spec.lua +++ b/test/functional/lua/system_spec.lua @@ -114,7 +114,7 @@ describe('vim.system', function() end) if t.is_os('win') then - it('can resolve windows command extentions.', function() + it('can resolve windows command extensions', function() t.write_file('test.bat', 'echo hello world') system_sync({ 'chmod', '+x', 'test.bat' }) system_sync({ './test' }) -- cgit From 734dba04d13bc7a6714134af322d49f333bfdc4c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 3 Dec 2024 18:06:58 +0000 Subject: fix(vim.system): close pipe handles after process handle Fixes #30846 --- test/functional/lua/system_spec.lua | 45 +++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'test/functional/lua/system_spec.lua') diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua index 3f847ca3be..79a70c9c72 100644 --- a/test/functional/lua/system_spec.lua +++ b/test/functional/lua/system_spec.lua @@ -18,8 +18,7 @@ local function system_sync(cmd, opts) local res = obj:wait() -- Check the process is no longer running - local proc = vim.api.nvim_get_proc(obj.pid) - assert(not proc, 'process still exists') + assert(not vim.api.nvim_get_proc(obj.pid), 'process still exists') return res end) @@ -27,23 +26,23 @@ end local function system_async(cmd, opts) return exec_lua(function() - _G.done = false + local done = false + local res --- @type vim.SystemCompleted? local obj = vim.system(cmd, opts, function(obj) - _G.done = true - _G.ret = obj + done = true + res = obj end) local ok = vim.wait(10000, function() - return _G.done + return done end) assert(ok, 'process did not exit') -- Check the process is no longer running - local proc = vim.api.nvim_get_proc(obj.pid) - assert(not proc, 'process still exists') + assert(not vim.api.nvim_get_proc(obj.pid), 'process still exists') - return _G.ret + return res end) end @@ -120,4 +119,32 @@ describe('vim.system', function() system_sync({ './test' }) end) end + + it('always captures all content of stdout/stderr #30846', function() + t.skip(n.fn.executable('git') == 0, 'missing "git" command') + eq( + 0, + exec_lua(function() + local done = 0 + local fail = 0 + for _ = 1, 200 do + vim.system( + { 'git', 'show', ':0:test/functional/plugin/lsp_spec.lua' }, + { text = true }, + function(o) + if o.code ~= 0 or #o.stdout == 0 then + fail = fail + 1 + end + done = done + 1 + end + ) + end + + local ok = vim.wait(10000, function() + return done == 200 + end, 200) + return fail + (ok and 0 or 1) + end) + ) + end) end) -- cgit From 540def7d2c1aa97d18b08bd7dc234442a7ab4757 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 5 Dec 2024 17:13:22 +0800 Subject: test(system_spec): check for .git dir before using git (#31458) --- test/functional/lua/system_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/lua/system_spec.lua') diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua index 79a70c9c72..6c320376c9 100644 --- a/test/functional/lua/system_spec.lua +++ b/test/functional/lua/system_spec.lua @@ -122,6 +122,7 @@ describe('vim.system', function() it('always captures all content of stdout/stderr #30846', function() t.skip(n.fn.executable('git') == 0, 'missing "git" command') + t.skip(n.fn.isdirectory('.git') == 0, 'missing ".git" directory') eq( 0, exec_lua(function() -- cgit