diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-11-26 23:15:17 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-11-27 09:45:32 +0100 |
commit | 944e3c06193f6d10baa9ba3021e01626337dd884 (patch) | |
tree | 949c05f0259f1d746f68b932139b4573225e179b /test/functional | |
parent | a043899ba255524b7421579b9bd6112801f09247 (diff) | |
download | rneovim-944e3c06193f6d10baa9ba3021e01626337dd884.tar.gz rneovim-944e3c06193f6d10baa9ba3021e01626337dd884.tar.bz2 rneovim-944e3c06193f6d10baa9ba3021e01626337dd884.zip |
tui: expose terminal type in 'term' option
Since "builtin" terminfo definitions were implemented (7cbf52db1bdf),
the decisions made by tui.c and terminfo.c are more relevant. Exposing
that decision in the 'term' option helps with troubleshooting.
Also: remove code that allowed setting t_Co. `:set t_Co=…` has never
worked; the highlight_spec test asserting that nvim_set_option('t_Co')
_does_ work makes no sense, and should not have worked.
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/helpers.lua | 10 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 49 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 2 |
3 files changed, 56 insertions, 5 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..723325c040 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,7 +18,7 @@ describe('tui', function() local screen before_each(function() - helpers.clear() + clear() screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]') -- right now pasting can be really slow in the TUI, especially in ASAN. @@ -372,7 +376,7 @@ 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={}}) @@ -384,7 +388,7 @@ describe("tui 't_Co' (terminal colors)", function() (colorterm ~= nil and "COLORTERM="..colorterm or ""), helpers.nvim_prog)) - thelpers.feed_data(":echo &t_Co\n") + feed_data(":echo &t_Co\n") helpers.wait() local tline if maxcolors == 8 or maxcolors == 16 then @@ -628,3 +632,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..12d71a1603 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -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) |