aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/helpers.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-07 07:15:37 +0800
committerGitHub <noreply@github.com>2023-12-07 07:15:37 +0800
commit6b00b8a369480a6535e7d286dd6ea27a6b0c94a5 (patch)
tree320c5d780b43764edd7bb53709c68e89289706b2 /test/functional/terminal/helpers.lua
parent8bb5089974e14f043a0b0c17e4d38dbd0b9a9ab2 (diff)
downloadrneovim-6b00b8a369480a6535e7d286dd6ea27a6b0c94a5.tar.gz
rneovim-6b00b8a369480a6535e7d286dd6ea27a6b0c94a5.tar.bz2
rneovim-6b00b8a369480a6535e7d286dd6ea27a6b0c94a5.zip
test(terminal): remove unnecessary string operations (#26434)
Diffstat (limited to 'test/functional/terminal/helpers.lua')
-rw-r--r--test/functional/terminal/helpers.lua27
1 files changed, 7 insertions, 20 deletions
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index 4ae054daa8..78c9218679 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -52,9 +52,9 @@ local function clear_attrs() feed_termcode('[0;10m') end
local function enable_mouse() feed_termcode('[?1002h') end
local function disable_mouse() feed_termcode('[?1002l') end
-local default_command = '["'..testprg('tty-test')..'"]'
+local default_command = { testprg('tty-test') }
-local function screen_setup(extra_rows, command, cols, opts)
+local function screen_setup(extra_rows, command, cols, env, screen_opts)
extra_rows = extra_rows and extra_rows or 0
command = command and command or default_command
cols = cols and cols or 50
@@ -81,9 +81,10 @@ local function screen_setup(extra_rows, command, cols, opts)
[15] = {underline = true, foreground = 12},
})
- screen:attach(opts or {rgb=false})
+ screen:attach(screen_opts or {rgb=false})
- nvim('command', 'enew | call termopen('..command..')')
+ nvim('command', 'enew')
+ nvim('call_function', 'termopen', {command, env and {env = env} or nil})
nvim('input', '<CR>')
local vim_errmsg = nvim('eval', 'v:errmsg')
if vim_errmsg and "" ~= vim_errmsg then
@@ -96,7 +97,7 @@ local function screen_setup(extra_rows, command, cols, opts)
-- tty-test puts the terminal into raw mode and echoes input. Tests work by
-- feeding termcodes to control the display and asserting by screen:expect.
- if command == default_command and opts == nil then
+ if command == default_command and screen_opts == nil then
-- Wait for "tty ready" to be printed before each test or the terminal may
-- still be in canonical mode (will echo characters for example).
local empty_line = (' '):rep(cols)
@@ -125,22 +126,8 @@ end
local function setup_child_nvim(args, opts)
opts = opts or {}
-
local argv = { nvim_prog, unpack(args) }
- local cmd = string.format('[%s]', vim.iter(argv):map(function(s)
- return string.format('\'%s\'', s)
- end):join(', '))
-
- if opts.env then
- local s = {}
- for k, v in pairs(opts.env) do
- table.insert(s, string.format('%s: \'%s\'', k, v))
- end
-
- cmd = string.format('%s, #{env: #{%s}}', cmd, table.concat(s, ', '))
- end
-
- return screen_setup(0, cmd, opts.cols)
+ return screen_setup(0, argv, opts.cols, opts.env)
end
return {