diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/helpers.lua | 13 | ||||
-rw-r--r-- | test/functional/ui/embed_spec.lua | 48 |
2 files changed, 56 insertions, 5 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 173fc54af5..b0b2dac9fd 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -361,14 +361,15 @@ local function remove_args(args, args_rm) return new_args end -function module.spawn(argv, merge, env, keep) +--- @param io_extra used for stdin_fd, see :help ui-option +function module.spawn(argv, merge, env, keep, io_extra) if session and not keep then session:close() end local child_stream = ChildProcessStream.spawn( merge and module.merge_args(prepend_argv, argv) or argv, - env) + env, io_extra) return Session.new(child_stream) end @@ -415,8 +416,8 @@ end -- clear('-e') -- clear{args={'-e'}, args_rm={'-i'}, env={TERM=term}} function module.clear(...) - local argv, env = module.new_argv(...) - module.set_session(module.spawn(argv, nil, env)) + local argv, env, io_extra = module.new_argv(...) + module.set_session(module.spawn(argv, nil, env, nil, io_extra)) end -- Builds an argument list for use in clear(). @@ -426,6 +427,7 @@ function module.new_argv(...) local args = {unpack(module.nvim_argv)} table.insert(args, '--headless') local new_args + local io_extra local env = nil local opts = select(1, ...) if type(opts) == 'table' then @@ -461,13 +463,14 @@ function module.new_argv(...) end end new_args = opts.args or {} + io_extra = opts.io_extra else new_args = {...} end for _, arg in ipairs(new_args) do table.insert(args, arg) end - return args, env + return args, env, io_extra end function module.insert(...) diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index 8218c8e12d..92f5beebf5 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -1,3 +1,5 @@ +local uv = require'luv' + local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') @@ -98,3 +100,49 @@ end describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end) describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end) + +describe('--embed UI', function() + it('can pass stdin', function() + local pipe = assert(uv.pipe()) + + local writer = assert(uv.new_pipe(false)) + writer:open(pipe.write) + + clear {args_rm={'--headless'}, io_extra=pipe.read} + + -- attach immediately after startup, for early UI + local screen = Screen.new(40, 8) + screen:attach {stdin_fd=3} + screen:set_default_attr_ids { + [1] = {bold = true, foreground = Screen.colors.Blue1}; + [2] = {bold = true}; + } + + writer:write "hello nvim\nfrom external input\n" + writer:shutdown(function() writer:close() end) + + screen:expect{grid=[[ + ^hello nvim | + from external input | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + -- stdin (rpc input) still works + feed 'o' + screen:expect{grid=[[ + hello nvim | + ^ | + from external input | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- INSERT --} | + ]]} + end) +end) |