diff options
Diffstat (limited to 'test/functional/terminal/buffer_spec.lua')
| -rw-r--r-- | test/functional/terminal/buffer_spec.lua | 141 |
1 files changed, 73 insertions, 68 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 423e7bdf21..02958a69e0 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -1,8 +1,10 @@ local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local assert_alive = helpers.assert_alive local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local poke_eventloop = helpers.poke_eventloop +local nvim_prog = helpers.nvim_prog local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.source local pcall_err = helpers.pcall_err local eq, neq = helpers.eq, helpers.neq @@ -17,7 +19,6 @@ local sleep = helpers.sleep local funcs = helpers.funcs local is_os = helpers.is_os local skip = helpers.skip -local nvim_prog = helpers.nvim_prog describe(':terminal buffer', function() local screen @@ -59,11 +60,7 @@ describe(':terminal buffer', function() feed('<c-\\><c-n>:set bufhidden=wipe<cr>:enew<cr>') screen:expect([[ ^ | - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*5 :enew | ]]) end) @@ -72,11 +69,7 @@ describe(':terminal buffer', function() feed(':bnext:l<esc>') screen:expect([[ ^ | - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*5 | ]]) end) @@ -88,11 +81,7 @@ describe(':terminal buffer', function() screen:expect([[ tty ready | {2:^ } | - | - | - | - | - | + |*5 ]]) end) @@ -112,10 +101,7 @@ describe(':terminal buffer', function() screen:expect([[ tty ready | {2:^ } | - | - | - | - | + |*4 {8:E21: Cannot make changes, 'modifiable' is off} | ]]) end) @@ -126,22 +112,16 @@ describe(':terminal buffer', function() feed('"ap"ap') screen:expect([[ ^tty ready | - appended tty ready | - appended tty ready | + appended tty ready |*2 {2: } | - | - | + |*2 :let @a = "appended " . @a | ]]) -- operator count is also taken into consideration feed('3"ap') screen:expect([[ ^tty ready | - appended tty ready | - appended tty ready | - appended tty ready | - appended tty ready | - appended tty ready | + appended tty ready |*5 :let @a = "appended " . @a | ]]) end) @@ -154,17 +134,14 @@ describe(':terminal buffer', function() ^tty ready | appended tty ready | {2: } | - | - | - | + |*3 :put a | ]]) -- line argument is only used to move the cursor feed_command('6put a') screen:expect([[ tty ready | - appended tty ready | - appended tty ready | + appended tty ready |*2 {2: } | | ^ | @@ -176,21 +153,13 @@ describe(':terminal buffer', function() feed('<c-\\><c-n>:bd!<cr>') screen:expect([[ ^ | - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*5 :bd! | ]]) feed_command('bnext') screen:expect([[ ^ | - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*5 :bnext | ]]) end) @@ -267,10 +236,7 @@ describe(':terminal buffer', function() screen:expect([[ ydaer ytt| {1:a}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - | - | - | - | + |*4 {3:-- TERMINAL --} | ]]) command('bdelete!') @@ -308,10 +274,7 @@ describe(':terminal buffer', function() screen:expect{grid=[[ tty ready | {2:^ } | - | - | - | - | + |*4 {3:-- (terminal) --} | ]]} eq('ntT', funcs.mode(1)) @@ -320,10 +283,7 @@ describe(':terminal buffer', function() screen:expect{grid=[[ tty ready | {2: } | - | - | - | - | + |*4 :let g:x = 17^ | ]]} @@ -331,10 +291,7 @@ describe(':terminal buffer', function() screen:expect{grid=[[ tty ready | {1: } | - | - | - | - | + |*4 {3:-- TERMINAL --} | ]]} eq('t', funcs.mode(1)) @@ -446,15 +403,16 @@ end) describe('terminal input', function() it('sends various special keys with modifiers', function() clear() - local screen = thelpers.screen_setup( - 0, - string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--cmd", 'colorscheme vim', "--cmd", "startinsert"]]=], nvim_prog) - ) + local screen = thelpers.setup_child_nvim({ + '-u', 'NONE', + '-i', 'NONE', + '--cmd', 'colorscheme vim', + '--cmd', 'set notermguicolors', + '--cmd', 'startinsert', + }) screen:expect{grid=[[ {1: } | - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*3 {5:[No Name] 0,1 All}| {3:-- INSERT --} | {3:-- TERMINAL --} | @@ -485,7 +443,7 @@ if is_os('win') then clear() feed_command('set modifiable swapfile undolevels=20') poke_eventloop() - local cmd = '["cmd.exe","/K","PROMPT=$g$s"]' + local cmd = { "cmd.exe", "/K", "PROMPT=$g$s" } screen = thelpers.screen_setup(nil, cmd) end) @@ -557,4 +515,51 @@ describe('termopen()', function() eq("Vim:E11: Invalid in command-line window; <CR> executes, CTRL-C quits", pcall_err(funcs.termopen, "bar")) end) + + describe('$COLORTERM value', function() + if skip(is_os('win'), 'Not applicable for Windows') then return end + + before_each(function() + -- Outer value should never be propagated to :terminal + funcs.setenv('COLORTERM', 'wrongvalue') + end) + + local function test_term_colorterm(expected, opts) + local screen = Screen.new(50, 4) + screen:attach() + funcs.termopen({ + nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', + '-c', 'echo $COLORTERM | quit', + }, opts) + screen:expect(([[ + ^%s{MATCH:%%s+}| + [Process exited 0] | + |*2 + ]]):format(expected)) + end + + describe("with 'notermguicolors'", function() + before_each(function() + command('set notermguicolors') + end) + it('is empty by default', function() + test_term_colorterm('') + end) + it('can be overridden', function() + test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } }) + end) + end) + + describe("with 'termguicolors'", function() + before_each(function() + command('set termguicolors') + end) + it('is "truecolor" by default', function() + test_term_colorterm('truecolor') + end) + it('can be overridden', function() + test_term_colorterm('expectedvalue', { env = { COLORTERM = 'expectedvalue' } }) + end) + end) + end) end) |
