mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 21:20:45 +00:00
shell: Use job_write_cb for closing stdin
Commit @45525853d352 removed usage of the `job_write_cb` for closing stdin due to a memory error, but that doesn't work anymore because `job_close_in` closes stdin immediately, possibly trimming input data before it is fully written. Since most memory issues with jobs have been fixed, re-add the `job_write_cb` call to ensure stdin is only closed when it should. Also add tests for scenarios where using the callback makes a difference.
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
-- - `systemlist()`
|
||||
|
||||
local helpers = require('test.functional.helpers')
|
||||
local eq, clear, eval, feed =
|
||||
helpers.eq, helpers.clear, helpers.eval, helpers.feed
|
||||
local eq, clear, eval, feed, nvim =
|
||||
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim
|
||||
|
||||
|
||||
local function create_file_with_nuls(name)
|
||||
@@ -55,6 +55,21 @@ describe('system()', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('passing a lot of input', function()
|
||||
it('returns the program output', function()
|
||||
local input = {}
|
||||
-- write more than 1mb of data, which should be enough to overcome
|
||||
-- the os buffer limit and force multiple event loop iterations to write
|
||||
-- everything
|
||||
for i = 1, 0xffff do
|
||||
input[#input + 1] = '01234567890ABCDEFabcdef'
|
||||
end
|
||||
input = table.concat(input, '\n')
|
||||
nvim('set_var', 'input', input)
|
||||
eq(input, eval('system("cat -", g:input)'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('passing number as input', function()
|
||||
it('stringifies the input', function()
|
||||
eq('1', eval('system("cat", 1)'))
|
||||
@@ -129,6 +144,17 @@ describe('systemlist()', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('passing a lot of input', function()
|
||||
it('returns the program output', function()
|
||||
local input = {}
|
||||
for i = 1, 0xffff do
|
||||
input[#input + 1] = '01234567890ABCDEFabcdef'
|
||||
end
|
||||
nvim('set_var', 'input', input)
|
||||
eq(input, eval('systemlist("cat -", g:input)'))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('with output containing NULs', function()
|
||||
local fname = 'Xtest'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user