aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/helpers.lua
diff options
context:
space:
mode:
authorJakub Łuczyński <doubleloop@users.noreply.github.com>2022-11-19 13:46:04 +0100
committerGitHub <noreply@github.com>2022-11-19 20:46:04 +0800
commit4650af38f07defb87d13d9567c127b0070bfccb9 (patch)
treec077ab25696f8e268f7cec98449ece5c441c182b /test/functional/terminal/helpers.lua
parentcfdf5e6f372928c11a2b1459b14c4c2de5f69c51 (diff)
downloadrneovim-4650af38f07defb87d13d9567c127b0070bfccb9.tar.gz
rneovim-4650af38f07defb87d13d9567c127b0070bfccb9.tar.bz2
rneovim-4650af38f07defb87d13d9567c127b0070bfccb9.zip
test: fix failing tui_spec.lua tests (#21117)
* refactor(test): use exec_lua * fix(test): fix failing tui_spec tests test is failing when path of tty-test does not fit cmdline
Diffstat (limited to 'test/functional/terminal/helpers.lua')
-rw-r--r--test/functional/terminal/helpers.lua25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index d69f3207f1..841c92387f 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -4,19 +4,31 @@
local helpers = require('test.functional.helpers')(nil)
local Screen = require('test.functional.ui.screen')
local testprg = helpers.testprg
+local exec_lua = helpers.exec_lua
local feed_command, nvim = helpers.feed_command, helpers.nvim
local function feed_data(data)
- -- A string containing NUL bytes is not converted to a Blob when
- -- calling nvim_set_var() API, so convert it using Lua instead.
- nvim('exec_lua', 'vim.g.term_data = ...', {data})
- nvim('command', 'call jobsend(b:terminal_job_id, term_data)')
+ if type(data) == 'table' then
+ data = table.concat(data, '\n')
+ end
+ exec_lua('vim.api.nvim_chan_send(vim.b.terminal_job_id, ...)', data)
end
local function feed_termcode(data)
- -- feed with the job API
- nvim('command', 'call jobsend(b:terminal_job_id, "\\x1b'..data..'")')
+ feed_data('\027' .. data)
+end
+
+local function make_lua_executor(session)
+ return function(code, ...)
+ local status, rv = session:request('nvim_exec_lua', code, {...})
+ if not status then
+ session:stop()
+ error(rv[2])
+ end
+ return rv
+ end
end
+
-- some helpers for controlling the terminal. the codes were taken from
-- infocmp xterm-256color which is less what libvterm understands
-- civis/cnorm
@@ -109,6 +121,7 @@ end
return {
feed_data = feed_data,
feed_termcode = feed_termcode,
+ make_lua_executor = make_lua_executor,
hide_cursor = hide_cursor,
show_cursor = show_cursor,
enter_altscreen = enter_altscreen,