2015-10-01 11:03:40 -07:00
|
|
|
-- Some sanity checks for the TUI using the builtin terminal emulator
|
|
|
|
-- as a simple way to send keys and assert screen state.
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-10-01 11:03:40 -07:00
|
|
|
local thelpers = require('test.functional.terminal.helpers')
|
2017-04-08 17:11:08 -07:00
|
|
|
local feed_data = thelpers.feed_data
|
2017-04-08 14:12:26 -07:00
|
|
|
local feed_command = helpers.feed_command
|
2015-11-20 11:47:20 -07:00
|
|
|
local nvim_dir = helpers.nvim_dir
|
2017-04-08 17:11:08 -07:00
|
|
|
local retry = helpers.retry
|
2015-10-01 11:03:40 -07:00
|
|
|
|
2016-08-15 16:42:12 -07:00
|
|
|
if helpers.pending_win32(pending) then return end
|
|
|
|
|
2015-10-01 11:03:40 -07:00
|
|
|
describe('tui', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
helpers.clear()
|
2017-02-09 19:39:00 -07:00
|
|
|
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
|
|
|
|
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
2015-10-02 06:59:06 -07:00
|
|
|
-- 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
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-10-01 11:03:40 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
screen:detach()
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('accepts basic utf-8 input', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('iabc\ntest1\ntest2')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
abc |
|
|
|
|
test1 |
|
|
|
|
test2{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
abc |
|
|
|
|
test1 |
|
|
|
|
test{1:2} |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
2015-10-01 11:03:40 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2016-01-10 14:23:24 -07:00
|
|
|
it('interprets leading <Esc> byte as ALT modifier in normal-mode', function()
|
2015-10-02 06:59:06 -07:00
|
|
|
local keys = 'dfghjkl'
|
|
|
|
for c in keys:gmatch('.') do
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027'..c)
|
2015-10-02 06:59:06 -07:00
|
|
|
end
|
|
|
|
screen:expect([[
|
|
|
|
alt-j |
|
|
|
|
alt-k |
|
|
|
|
alt-l |
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{5:[No Name] [+] }|
|
2015-10-02 06:59:06 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-10-02 06:59:06 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('gg')
|
2015-10-02 06:59:06 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1:a}lt-d |
|
|
|
|
alt-f |
|
|
|
|
alt-g |
|
|
|
|
alt-h |
|
2016-08-09 08:01:56 -07:00
|
|
|
{5:[No Name] [+] }|
|
2015-10-02 06:59:06 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-10-02 06:59:06 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2016-01-10 14:23:24 -07:00
|
|
|
it('does not mangle unmapped ALT-key chord', function()
|
|
|
|
-- Vim represents ALT/META by setting the "high bit" of the modified key;
|
|
|
|
-- we do _not_. #3982
|
|
|
|
--
|
|
|
|
-- Example: for input ALT+j:
|
|
|
|
-- * Vim (Nvim prior to #3982) sets high-bit, inserts "ê".
|
|
|
|
-- * Nvim (after #3982) inserts "j".
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('i\027j')
|
2016-01-10 14:23:24 -07:00
|
|
|
screen:expect([[
|
|
|
|
j{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2016-01-10 14:23:24 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
2015-10-02 06:59:06 -07:00
|
|
|
it('accepts ascii control sequences', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('i')
|
|
|
|
feed_data('\022\007') -- ctrl+g
|
|
|
|
feed_data('\022\022') -- ctrl+v
|
|
|
|
feed_data('\022\013') -- ctrl+m
|
2015-10-02 06:59:06 -07:00
|
|
|
screen:expect([[
|
2016-08-09 08:01:56 -07:00
|
|
|
{9:^G^V^M}{1: } |
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
2015-10-02 06:59:06 -07:00
|
|
|
end)
|
|
|
|
|
2015-10-01 11:03:40 -07:00
|
|
|
it('automatically sends <Paste> for bracketed paste sequences', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('i\027[200~')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
|
|
|
{3:-- INSERT (paste) --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('pasted from terminal')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
pasted from terminal{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
|
|
|
{3:-- INSERT (paste) --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027[201~')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
pasted from terminal{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] [+] }|
|
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-10-01 11:03:40 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can handle arbitrarily long bursts of input', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set ruler')
|
2015-10-01 11:03:40 -07:00
|
|
|
local t = {}
|
|
|
|
for i = 1, 3000 do
|
|
|
|
t[i] = 'item ' .. tostring(i)
|
|
|
|
end
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('i\027[200~'..table.concat(t, '\n')..'\027[201~')
|
2015-10-01 11:03:40 -07:00
|
|
|
screen:expect([[
|
|
|
|
item 2997 |
|
|
|
|
item 2998 |
|
|
|
|
item 2999 |
|
|
|
|
item 3000{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{5:[No Name] [+] 3000,10 Bot}|
|
|
|
|
{3:-- INSERT --} |
|
|
|
|
{3:-- TERMINAL --} |
|
2015-11-13 09:20:32 -07:00
|
|
|
]])
|
|
|
|
end)
|
2015-11-20 16:09:30 -07:00
|
|
|
end)
|
2015-11-13 09:20:32 -07:00
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
describe('tui with non-tty file descriptors', function()
|
|
|
|
before_each(helpers.clear)
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
os.remove('testF') -- ensure test file is removed
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can handle pipes as stdout and stderr', function()
|
2017-02-09 19:39:00 -07:00
|
|
|
local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog
|
|
|
|
..' -u NONE -i NONE --cmd \'set noswapfile noshowcmd noruler\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data(':w testF\n:q\n')
|
2015-11-20 16:09:30 -07:00
|
|
|
screen:expect([[
|
|
|
|
:w testF |
|
|
|
|
:q |
|
|
|
|
abc |
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
[Process exited 0]{1: } |
|
2015-11-20 16:09:30 -07:00
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 16:09:30 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
|
|
|
|
describe('tui focus event handling', function()
|
2015-11-17 15:31:22 -07:00
|
|
|
local screen
|
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
before_each(function()
|
|
|
|
helpers.clear()
|
2017-02-09 19:39:00 -07:00
|
|
|
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog
|
|
|
|
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
|
|
|
feed_data(":autocmd FocusLost * echo 'lost'\n")
|
|
|
|
feed_data("\034\016") -- CTRL-\ CTRL-N
|
2015-11-20 16:09:30 -07:00
|
|
|
end)
|
2015-11-20 11:47:20 -07:00
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
it('can handle focus events in normal mode', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027[I')
|
2015-11-13 09:20:32 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-13 09:20:32 -07:00
|
|
|
gained |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-13 09:20:32 -07:00
|
|
|
]])
|
|
|
|
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027[O')
|
2015-11-13 09:20:32 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-13 09:20:32 -07:00
|
|
|
lost |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 11:47:20 -07:00
|
|
|
]])
|
2015-11-20 16:09:30 -07:00
|
|
|
end)
|
2015-11-20 11:47:20 -07:00
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
it('can handle focus events in insert mode', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set noshowmode')
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('i')
|
|
|
|
feed_data('\027[I')
|
2015-11-20 11:47:20 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-20 11:47:20 -07:00
|
|
|
gained |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 11:47:20 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027[O')
|
2015-11-20 11:47:20 -07:00
|
|
|
screen:expect([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-20 11:47:20 -07:00
|
|
|
lost |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 11:47:20 -07:00
|
|
|
]])
|
2015-11-20 16:09:30 -07:00
|
|
|
end)
|
2015-11-20 11:47:20 -07:00
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
it('can handle focus events in cmdline mode', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data(':')
|
|
|
|
feed_data('\027[I')
|
2015-11-20 11:47:20 -07:00
|
|
|
screen:expect([[
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-20 11:47:20 -07:00
|
|
|
g{1:a}ined |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 11:47:20 -07:00
|
|
|
]])
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data('\027[O')
|
2015-11-20 11:47:20 -07:00
|
|
|
screen:expect([[
|
|
|
|
|
|
2016-08-09 08:01:56 -07:00
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{4:~ }|
|
|
|
|
{5:[No Name] }|
|
2015-11-20 11:47:20 -07:00
|
|
|
l{1:o}st |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
2015-11-20 11:47:20 -07:00
|
|
|
]])
|
2015-11-20 16:09:30 -07:00
|
|
|
end)
|
2015-11-20 11:47:20 -07:00
|
|
|
|
2015-11-20 16:09:30 -07:00
|
|
|
it('can handle focus events in terminal mode', function()
|
2017-04-08 17:11:08 -07:00
|
|
|
feed_data(':set shell='..nvim_dir..'/shell-test\n')
|
|
|
|
feed_data(':set noshowmode laststatus=0\n')
|
|
|
|
|
|
|
|
retry(2, 3 * screen.timeout, function()
|
|
|
|
feed_data(':terminal\n')
|
|
|
|
feed_data('\027[I')
|
|
|
|
screen:expect([[
|
|
|
|
ready $ |
|
|
|
|
[Process exited 0]{1: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gained |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
feed_data('\027[O')
|
|
|
|
screen:expect([[
|
|
|
|
ready $ |
|
|
|
|
[Process exited 0]{1: } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lost |
|
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]])
|
|
|
|
|
|
|
|
-- If retry is needed...
|
|
|
|
feed_data("\034\016") -- CTRL-\ CTRL-N
|
|
|
|
feed_data(':bwipeout!\n')
|
|
|
|
end)
|
2015-10-01 11:03:40 -07:00
|
|
|
end)
|
|
|
|
end)
|
2016-07-02 22:13:48 -07:00
|
|
|
|
|
|
|
-- These tests require `thelpers` because --headless/--embed
|
|
|
|
-- does not initialize the TUI.
|
|
|
|
describe("tui 't_Co' (terminal colors)", function()
|
|
|
|
local screen
|
2016-07-06 06:11:26 -07:00
|
|
|
local is_linux = (helpers.eval("system('uname') =~? 'linux'") == 1)
|
2017-05-27 10:11:35 -07:00
|
|
|
local is_freebsd = (helpers.eval("system('uname') =~? 'FreeBSD'") == 1)
|
2016-07-02 22:13:48 -07:00
|
|
|
|
|
|
|
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(
|
2017-02-09 19:39:00 -07:00
|
|
|
[=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile noshowcmd noruler"']]=],
|
2016-07-02 22:13:48 -07:00
|
|
|
term,
|
|
|
|
(colorterm ~= nil and "COLORTERM="..colorterm or ""),
|
|
|
|
helpers.nvim_prog))
|
|
|
|
|
|
|
|
thelpers.feed_data(":echo &t_Co\n")
|
2017-03-28 17:13:50 -07:00
|
|
|
helpers.wait()
|
2016-08-09 08:01:56 -07:00
|
|
|
local tline
|
2017-05-27 10:11:35 -07:00
|
|
|
if maxcolors == 8 or maxcolors == 16 then
|
2016-08-09 08:01:56 -07:00
|
|
|
tline = "~ "
|
|
|
|
else
|
|
|
|
tline = "{4:~ }"
|
|
|
|
end
|
2016-07-02 22:13:48 -07:00
|
|
|
screen:expect(string.format([[
|
|
|
|
{1: } |
|
2016-08-09 08:01:56 -07:00
|
|
|
%s|
|
|
|
|
%s|
|
|
|
|
%s|
|
|
|
|
{5:[No Name] }|
|
2016-07-02 22:13:48 -07:00
|
|
|
%-3s |
|
2016-08-09 08:01:56 -07:00
|
|
|
{3:-- TERMINAL --} |
|
|
|
|
]], tline, tline, tline, tostring(maxcolors and maxcolors or "")))
|
2016-07-02 22:13:48 -07:00
|
|
|
end
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
-- ansi and no terminal type at all:
|
|
|
|
|
|
|
|
it("no TERM uses 8 colors", function()
|
|
|
|
assert_term_colors(nil, nil, 8)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=ansi no COLORTERM uses 8 colors", function()
|
|
|
|
assert_term_colors("ansi", nil, 8)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=ansi with COLORTERM=anything-no-number uses 16 colors", function()
|
|
|
|
assert_term_colors("ansi", "yet-another-term", 16)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("unknown TERM COLORTERM with 256 in name uses 256 colors", function()
|
|
|
|
assert_term_colors("ansi", "yet-another-term-256color", 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=ansi-256color sets 256 colours", function()
|
|
|
|
assert_term_colors("ansi-256color", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Unknown terminal types:
|
|
|
|
|
|
|
|
it("unknown TERM no COLORTERM sets 8 colours", function()
|
|
|
|
assert_term_colors("yet-another-term", nil, 8)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("unknown TERM with COLORTERM=anything-no-number uses 16 colors", function()
|
|
|
|
assert_term_colors("yet-another-term", "yet-another-term", 16)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("unknown TERM with 256 in name sets 256 colours", function()
|
|
|
|
assert_term_colors("yet-another-term-256color", nil, 256)
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
it("unknown TERM COLORTERM with 256 in name uses 256 colors", function()
|
|
|
|
assert_term_colors("yet-another-term", "yet-another-term-256color", 256)
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
-- Linux kernel terminal emulator:
|
|
|
|
|
2017-05-03 11:47:03 -07:00
|
|
|
it("TERM=linux uses 256 colors", function()
|
2017-05-27 10:11:35 -07:00
|
|
|
assert_term_colors("linux", nil, 256)
|
2017-05-03 11:47:03 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=linux-16color uses 256 colors", function()
|
2017-05-27 10:11:35 -07:00
|
|
|
assert_term_colors("linux-16color", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- screen and tmux:
|
|
|
|
|
|
|
|
it("TERM=screen no COLORTERM uses 8/256 colors", function()
|
|
|
|
if is_freebsd then
|
|
|
|
assert_term_colors("screen", nil, 256)
|
2016-07-06 06:11:26 -07:00
|
|
|
else
|
2017-05-27 10:11:35 -07:00
|
|
|
assert_term_colors("screen", nil, 8)
|
2016-07-06 06:11:26 -07:00
|
|
|
end
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
it("TERM=screen COLORTERM=screen uses 16/256 colors", function()
|
|
|
|
if is_freebsd then
|
|
|
|
assert_term_colors("screen", "screen", 256)
|
2016-07-06 06:11:26 -07:00
|
|
|
else
|
2017-05-27 10:11:35 -07:00
|
|
|
assert_term_colors("screen", "screen", 16)
|
2016-07-06 06:11:26 -07:00
|
|
|
end
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=screen COLORTERM=screen-256color uses 256 colors", function()
|
|
|
|
assert_term_colors("screen", "screen-256color", 256)
|
|
|
|
end)
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
it("TERM=screen-256color no COLORTERM uses 256 colors", function()
|
|
|
|
assert_term_colors("screen-256color", nil, 256)
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|
|
|
|
|
2017-05-27 11:52:14 -07:00
|
|
|
it("TERM=tmux no COLORTERM uses 256 colors", function()
|
|
|
|
assert_term_colors("tmux", nil, 256)
|
2017-05-27 10:11:35 -07:00
|
|
|
end)
|
|
|
|
|
2017-05-27 11:52:14 -07:00
|
|
|
it("TERM=tmux COLORTERM=tmux uses 256 colors", function()
|
|
|
|
assert_term_colors("tmux", "tmux", 256)
|
2017-05-27 10:11:35 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=tmux COLORTERM=tmux-256color uses 256 colors", function()
|
|
|
|
assert_term_colors("tmux", "tmux-256color", 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=tmux-256color no COLORTERM uses 256 colors", function()
|
|
|
|
assert_term_colors("tmux-256color", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- xterm and imitators:
|
|
|
|
|
2016-07-02 22:13:48 -07:00
|
|
|
it("TERM=xterm uses 256 colors", function()
|
|
|
|
assert_term_colors("xterm", nil, 256)
|
|
|
|
end)
|
|
|
|
|
2017-05-27 10:11:35 -07:00
|
|
|
it("TERM=xterm COLORTERM=gnome-terminal uses 256 colors", function()
|
|
|
|
assert_term_colors("xterm", "gnome-terminal", 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=xterm COLORTERM=mate-terminal uses 256 colors", function()
|
|
|
|
assert_term_colors("xterm", "mate-terminal", 256)
|
|
|
|
end)
|
|
|
|
|
2016-07-02 22:13:48 -07:00
|
|
|
it("TERM=xterm-256color uses 256 colors", function()
|
|
|
|
assert_term_colors("xterm-256color", nil, 256)
|
|
|
|
end)
|
2017-05-27 10:11:35 -07:00
|
|
|
|
|
|
|
-- rxvt and stterm:
|
|
|
|
|
|
|
|
it("TERM=rxvt no COLORTERM uses 256 colors", function()
|
|
|
|
assert_term_colors("rxvt", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=rxvt-256color uses 256 colors", function()
|
|
|
|
assert_term_colors("rxvt-256color", nil, 256)
|
|
|
|
end)
|
|
|
|
|
2017-05-27 11:52:14 -07:00
|
|
|
it("TERM=st no COLORTERM uses 8/256 colors", function()
|
|
|
|
if is_freebsd then
|
|
|
|
assert_term_colors("st", nil, 256)
|
|
|
|
else
|
|
|
|
assert_term_colors("st", nil, 8)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=st COLORTERM=st uses 16/256 colors", function()
|
|
|
|
if is_freebsd then
|
|
|
|
assert_term_colors("st", nil, 256)
|
|
|
|
else
|
|
|
|
assert_term_colors("st", nil, 16)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=st COLORTERM=st-256color uses 256 colors", function()
|
2017-05-27 10:11:35 -07:00
|
|
|
assert_term_colors("st", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("TERM=st-256color uses 256 colors", function()
|
|
|
|
assert_term_colors("st-256color", nil, 256)
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- others:
|
|
|
|
|
|
|
|
it("TERM=interix uses 8 colors", function()
|
|
|
|
assert_term_colors("interix", nil, 8)
|
|
|
|
end)
|
|
|
|
|
2017-05-27 11:52:14 -07:00
|
|
|
it("TERM=iterm uses 256 colors", function()
|
|
|
|
assert_term_colors("iterm", nil, 256)
|
2017-05-27 10:11:35 -07:00
|
|
|
end)
|
|
|
|
|
2016-07-02 22:13:48 -07:00
|
|
|
end)
|