aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/tui_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/terminal/tui_spec.lua')
-rw-r--r--test/functional/terminal/tui_spec.lua62
1 files changed, 53 insertions, 9 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 777ef65d9e..d5f6a21d1d 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1,12 +1,16 @@
-- TUI acceptance tests.
-- Uses :terminal as a way to send keys and assert screen state.
local global_helpers = require('test.helpers')
+local uname = global_helpers.uname
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local feed_data = thelpers.feed_data
local feed_command = helpers.feed_command
+local clear = helpers.clear
local nvim_dir = helpers.nvim_dir
local retry = helpers.retry
+local nvim_prog = helpers.nvim_prog
+local nvim_set = helpers.nvim_set
if helpers.pending_win32(pending) then return end
@@ -14,9 +18,9 @@ describe('tui', function()
local screen
before_each(function()
- helpers.clear()
- screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
+ clear()
+ screen = thelpers.screen_setup(0, '["'..nvim_prog
+ ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler undodir=. directory=. viewdir=. backupdir=."]')
-- right now pasting can be really slow in the TUI, especially in ASAN.
-- this will be fixed later but for now we require a high timeout.
screen.timeout = 60000
@@ -372,19 +376,20 @@ end)
-- does not initialize the TUI.
describe("tui 't_Co' (terminal colors)", function()
local screen
- local is_freebsd = (string.lower(global_helpers.uname()) == 'freebsd')
+ local is_freebsd = (string.lower(uname()) == 'freebsd')
local function assert_term_colors(term, colorterm, maxcolors)
helpers.clear({env={TERM=term}, args={}})
-- This is ugly because :term/termopen() forces TERM=xterm-256color.
-- TODO: Revisit this after jobstart/termopen accept `env` dict.
screen = thelpers.screen_setup(0, string.format(
- [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile noshowcmd noruler"']]=],
+ [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "%s"']]=],
term or "",
(colorterm ~= nil and "COLORTERM="..colorterm or ""),
- helpers.nvim_prog))
+ nvim_prog,
+ nvim_set))
- thelpers.feed_data(":echo &t_Co\n")
+ feed_data(":echo &t_Co\n")
helpers.wait()
local tline
if maxcolors == 8 or maxcolors == 16 then
@@ -397,10 +402,10 @@ describe("tui 't_Co' (terminal colors)", function()
%s|
%s|
%s|
- {5:[No Name] }|
+ %s|
%-3s |
{3:-- TERMINAL --} |
- ]], tline, tline, tline, tostring(maxcolors and maxcolors or "")))
+ ]], tline, tline, tline, tline, tostring(maxcolors and maxcolors or "")))
end
-- ansi and no terminal type at all:
@@ -628,3 +633,42 @@ describe("tui 't_Co' (terminal colors)", function()
end)
end)
+
+-- These tests require `thelpers` because --headless/--embed
+-- does not initialize the TUI.
+describe("tui 'term' option", function()
+ local screen
+ local is_bsd = not not string.find(string.lower(uname()), 'bsd')
+
+ local function assert_term(term_envvar, term_expected)
+ clear()
+ -- This is ugly because :term/termopen() forces TERM=xterm-256color.
+ -- TODO: Revisit this after jobstart/termopen accept `env` dict.
+ local cmd = string.format(
+ [=[['sh', '-c', 'LANG=C TERM=%s %s -u NONE -i NONE --cmd "%s"']]=],
+ term_envvar or "",
+ nvim_prog,
+ nvim_set)
+ screen = thelpers.screen_setup(0, cmd)
+
+ local full_timeout = screen.timeout
+ screen.timeout = 250 -- We want screen:expect() to fail quickly.
+ retry(nil, 2 * full_timeout, function() -- Wait for TUI thread to set 'term'.
+ feed_data(":echo 'term='.(&term)\n")
+ screen:expect('term='..term_expected, nil, nil, nil, true)
+ end)
+ end
+
+ it('gets builtin term if $TERM is invalid', function()
+ assert_term("foo", "builtin_ansi")
+ end)
+
+ it('gets system-provided term if $TERM is valid', function()
+ if is_bsd then -- BSD lacks terminfo, we always use builtin there.
+ assert_term("xterm", "builtin_xterm")
+ else
+ assert_term("xterm", "xterm")
+ end
+ end)
+
+end)