aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/helpers.lua10
-rw-r--r--test/functional/terminal/tui_spec.lua62
-rw-r--r--test/functional/ui/highlight_spec.lua4
3 files changed, 64 insertions, 12 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 272d2045c9..da334d4ac6 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -603,6 +603,15 @@ local function get_pathsep()
return funcs.fnamemodify('.', ':p'):sub(-1)
end
+-- Returns a valid, platform-independent $NVIM_LISTEN_ADDRESS.
+-- Useful for communicating with child instances.
+local function new_pipename()
+ -- HACK: Start a server temporarily, get the name, then stop it.
+ local pipename = nvim_eval('serverstart()')
+ funcs.serverstop(pipename)
+ return pipename
+end
+
local function missing_provider(provider)
if provider == 'ruby' then
local prog = funcs['provider#' .. provider .. '#Detect']()
@@ -732,6 +741,7 @@ local module = {
missing_provider = missing_provider,
alter_slashes = alter_slashes,
hexdump = hexdump,
+ new_pipename = new_pipename,
}
return function(after_each)
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)
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index d1357ea525..2252e3580f 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -4,7 +4,7 @@ local os = require('os')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local command = helpers.command
local eval, exc_exec = helpers.eval, helpers.exc_exec
-local feed_command, request, eq = helpers.feed_command, helpers.request, helpers.eq
+local feed_command, eq = helpers.feed_command, helpers.eq
local curbufmeths = helpers.curbufmeths
describe('colorscheme compatibility', function()
@@ -14,8 +14,6 @@ describe('colorscheme compatibility', function()
it('t_Co is set to 256 by default', function()
eq('256', eval('&t_Co'))
- request('nvim_set_option', 't_Co', '88')
- eq('88', eval('&t_Co'))
end)
end)