diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-07-03 01:55:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-03 01:55:09 -0400 |
commit | c402f6e7a9135490a9f05e4cac733e41c6815b2d (patch) | |
tree | 9e90c402b768cbd2bf013447d84ebcba19b79c08 /test | |
parent | f80eb768c75de2065626203de001738e1dda436e (diff) | |
parent | 173d366a5b0b5f0784a1da8aef4fe5d0cab7e1ec (diff) | |
download | rneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.tar.gz rneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.tar.bz2 rneovim-c402f6e7a9135490a9f05e4cac733e41c6815b2d.zip |
Merge #5001 from justinmk/t_colors
TUI: infer 256 colors more liberally; listen to unibilium in other cases
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/options/defaults_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 60 |
2 files changed, 61 insertions, 5 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index ed978cd17e..a36939b0bd 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq +local eval, eq = helpers.eval, helpers.eq local execute = helpers.execute local function init_session(...) @@ -15,10 +15,6 @@ local function init_session(...) end describe('startup defaults', function() - before_each(function() - clear() - end) - describe(':filetype', function() local function expect_filetype(expected) local screen = Screen.new(48, 4) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 91789d6575..4bae9a8d02 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -301,3 +301,63 @@ describe('tui focus event handling', function() ]]) end) end) + +-- These tests require `thelpers` because --headless/--embed +-- does not initialize the TUI. +describe("tui 't_Co' (terminal colors)", function() + local screen + + 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', 'TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile"']]=], + term, + (colorterm ~= nil and "COLORTERM="..colorterm or ""), + helpers.nvim_prog)) + + thelpers.feed_data(":echo &t_Co\n") + screen:expect(string.format([[ + {1: } | + ~ | + ~ | + ~ | + [No Name] | + %-3s | + -- TERMINAL -- | + ]], tostring(maxcolors and maxcolors or ""))) + end + + it("unknown TERM sets empty 't_Co'", function() + assert_term_colors("yet-another-term", nil, nil) + end) + + it("unknown TERM with COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("yet-another-term", "screen-256color", 256) + end) + + it("TERM=linux uses 8 colors", function() + assert_term_colors("linux", nil, 8) + end) + + it("TERM=screen uses 8 colors", function() + assert_term_colors("screen", nil, 8) + end) + + it("TERM=screen COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("screen", "screen-256color", 256) + end) + + it("TERM=yet-another-term COLORTERM=screen-256color uses 256 colors", function() + assert_term_colors("screen", "screen-256color", 256) + end) + + it("TERM=xterm uses 256 colors", function() + assert_term_colors("xterm", nil, 256) + end) + + it("TERM=xterm-256color uses 256 colors", function() + assert_term_colors("xterm-256color", nil, 256) + end) +end) |