diff options
author | erw7 <erw7.github@gmail.com> | 2017-03-28 18:07:58 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-08-16 09:13:43 +0200 |
commit | 4b1f21de75f9981007d80aca8355239e8615d6bd (patch) | |
tree | b0322a5b61eacbd6207603b346fca2f7d957458a /test/functional/terminal | |
parent | a79785675564a4c1f02f9aa54249fc6000187c0d (diff) | |
download | rneovim-4b1f21de75f9981007d80aca8355239e8615d6bd.tar.gz rneovim-4b1f21de75f9981007d80aca8355239e8615d6bd.tar.bz2 rneovim-4b1f21de75f9981007d80aca8355239e8615d6bd.zip |
win: support :terminal
Diffstat (limited to 'test/functional/terminal')
-rw-r--r-- | test/functional/terminal/buffer_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/terminal/cursor_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 11 | ||||
-rw-r--r-- | test/functional/terminal/helpers.lua | 7 | ||||
-rw-r--r-- | test/functional/terminal/highlight_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/terminal/mouse_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 64 | ||||
-rw-r--r-- | test/functional/terminal/window_spec.lua | 2 |
8 files changed, 80 insertions, 22 deletions
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 48b8512bf0..22ab0a8c21 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -6,8 +6,6 @@ local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.s local eq, neq = helpers.eq, helpers.neq local write_file = helpers.write_file -if helpers.pending_win32(pending) then return end - describe('terminal buffer', function() local screen @@ -72,6 +70,7 @@ describe('terminal buffer', function() end) it('cannot be modified directly', function() + if helpers.pending_win32(pending) then return end feed('<c-\\><c-n>dd') screen:expect([[ tty ready | @@ -160,6 +159,7 @@ describe('terminal buffer', function() end) it('handles loss of focus gracefully', function() + if helpers.pending_win32(pending) then return end -- Change the statusline to avoid printing the file name, which varies. nvim('set_option', 'statusline', '==========') feed_command('set laststatus=0') @@ -205,7 +205,7 @@ describe('terminal buffer', function() end) describe('No heap-buffer-overflow when using', function() - + if helpers.pending_win32(pending) then return end local testfilename = 'Xtestfile-functional-terminal-buffers_spec' before_each(function() diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 84d0322f12..d49f1bfc23 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -7,8 +7,6 @@ local feed_command = helpers.feed_command local hide_cursor = thelpers.hide_cursor local show_cursor = thelpers.show_cursor -if helpers.pending_win32(pending) then return end - describe('terminal cursor', function() local screen diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index be0fd9f8ff..5eb6a5f18c 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -3,10 +3,10 @@ local Screen = require('test.functional.ui.screen') local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq local feed_command, eval = helpers.feed_command, helpers.eval - -if helpers.pending_win32(pending) then return end +local iswin = helpers.iswin describe(':terminal', function() + if helpers.pending_win32(pending) then return end local screen before_each(function() @@ -174,10 +174,15 @@ describe(':terminal (with fake shell)', function() eq('term://', string.match(eval('bufname("%")'), "^term://")) helpers.feed([[<C-\><C-N>]]) feed_command([[find */shadacat.py]]) - eq('scripts/shadacat.py', eval('bufname("%")')) + if iswin() then + eq('scripts\\shadacat.py', eval('bufname("%")')) + else + eq('scripts/shadacat.py', eval('bufname("%")')) + end end) it('works with gf', function() + if helpers.pending_win32(pending) then return end terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) wait() screen:expect([[ diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua index 3b04d17705..29381ab4f0 100644 --- a/test/functional/terminal/helpers.lua +++ b/test/functional/terminal/helpers.lua @@ -30,10 +30,14 @@ local function clear_attrs() feed_termcode('[0;10m') end -- mouse local function enable_mouse() feed_termcode('[?1002h') end local function disable_mouse() feed_termcode('[?1002l') end +local function wait_sigwinch() + helpers.sleep(1000) + hide_cursor() + show_cursor() +end local default_command = '["'..nvim_dir..'/tty-test'..'"]' - local function screen_setup(extra_rows, command, cols) extra_rows = extra_rows and extra_rows or 0 command = command and command or default_command @@ -112,5 +116,6 @@ return { clear_attrs = clear_attrs, enable_mouse = enable_mouse, disable_mouse = disable_mouse, + wait_sigwinch = wait_sigwinch, screen_setup = screen_setup } diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index bb40770235..fddc0bbb71 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -5,8 +5,6 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local nvim_dir, command = helpers.nvim_dir, helpers.command local eq, eval = helpers.eq, helpers.eval -if helpers.pending_win32(pending) then return end - describe('terminal window highlighting', function() local screen @@ -55,6 +53,7 @@ describe('terminal window highlighting', function() end) local function pass_attrs() + if helpers.pending_win32(pending) then return end screen:expect(sub([[ tty ready | {NUM:text}text{10: } | @@ -69,6 +68,7 @@ describe('terminal window highlighting', function() it('will pass the corresponding attributes', pass_attrs) it('will pass the corresponding attributes on scrollback', function() + if helpers.pending_win32(pending) then return end pass_attrs() local lines = {} for i = 1, 8 do @@ -145,6 +145,7 @@ describe('terminal window highlighting with custom palette', function() end) it('will use the custom color', function() + if helpers.pending_win32(pending) then return end thelpers.set_fg(3) thelpers.feed_data('text') thelpers.clear_attrs() diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index 9239c2ad31..29c62d7be7 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -4,8 +4,6 @@ local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval local feed, nvim = helpers.feed, helpers.nvim local feed_data = thelpers.feed_data -if helpers.pending_win32(pending) then return end - describe('terminal mouse', function() local screen @@ -67,6 +65,7 @@ describe('terminal mouse', function() end) it('will forward mouse clicks to the program', function() + if helpers.pending_win32(pending) then return end feed('<LeftMouse><1,2>') screen:expect([[ line27 | @@ -80,6 +79,7 @@ describe('terminal mouse', function() end) it('will forward mouse scroll to the program', function() + if helpers.pending_win32(pending) then return end feed('<ScrollWheelUp><0,0>') screen:expect([[ line27 | @@ -94,6 +94,7 @@ describe('terminal mouse', function() end) describe('with a split window and other buffer', function() + if helpers.pending_win32(pending) then return end before_each(function() feed('<c-\\><c-n>:vsp<cr>') screen:expect([[ diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 05f81295c2..649bb4373b 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command +local iswin, wait_sigwinch = helpers.iswin, thelpers.wait_sigwinch local eval = helpers.eval local command = helpers.command local wait = helpers.wait @@ -11,8 +12,6 @@ local curbufmeths = helpers.curbufmeths local nvim = helpers.nvim local feed_data = thelpers.feed_data -if helpers.pending_win32(pending) then return end - describe('terminal scrollback', function() local screen @@ -142,6 +141,9 @@ describe('terminal scrollback', function() describe('and the height is decreased by 1', function() local function will_hide_top_line() screen:try_resize(screen._width, screen._height - 1) + if iswin() then + wait_sigwinch() + end screen:expect([[ line2 | line3 | @@ -158,6 +160,9 @@ describe('terminal scrollback', function() before_each(function() will_hide_top_line() screen:try_resize(screen._width, screen._height - 2) + if iswin() then + wait_sigwinch() + end end) it('will hide the top 3 lines', function() @@ -184,9 +189,13 @@ describe('terminal scrollback', function() describe('and the height is decreased by 2', function() before_each(function() screen:try_resize(screen._width, screen._height - 2) + if iswin() then + wait_sigwinch() + end end) local function will_delete_last_two_lines() + if helpers.pending_win32(pending) then return end screen:expect([[ tty ready | rows: 4, cols: 30 | @@ -200,9 +209,13 @@ describe('terminal scrollback', function() it('will delete the last two empty lines', will_delete_last_two_lines) describe('and then decreased by 1', function() + if helpers.pending_win32(pending) then return end before_each(function() will_delete_last_two_lines() screen:try_resize(screen._width, screen._height - 1) + if iswin() then + wait_sigwinch() + end end) it('will delete the last line and hide the first', function() @@ -245,6 +258,9 @@ describe('terminal scrollback', function() {3:-- TERMINAL --} | ]]) screen:try_resize(screen._width, screen._height - 3) + if iswin() then + wait_sigwinch() + end screen:expect([[ line4 | rows: 3, cols: 30 | @@ -257,6 +273,9 @@ describe('terminal scrollback', function() describe('and the height is increased by 1', function() local function pop_then_push() screen:try_resize(screen._width, screen._height + 1) + if iswin() then + wait_sigwinch() + end screen:expect([[ line4 | rows: 3, cols: 30 | @@ -273,6 +292,9 @@ describe('terminal scrollback', function() pop_then_push() eq(8, curbuf('line_count')) screen:try_resize(screen._width, screen._height + 3) + if iswin() then + wait_sigwinch() + end end) local function pop3_then_push1() @@ -303,10 +325,14 @@ describe('terminal scrollback', function() it('will pop 3 lines and then push one back', pop3_then_push1) describe('and then by 4', function() + if helpers.pending_win32(pending) then return end before_each(function() pop3_then_push1() feed('Gi') screen:try_resize(screen._width, screen._height + 4) + if iswin() then + wait_sigwinch() + end end) it('will show all lines and leave a blank one at the end', function() @@ -384,10 +410,20 @@ describe("'scrollback' option", function() end it('set to 0 behaves as 1', function() - local screen = thelpers.screen_setup(nil, "['sh']", 30) + local screen + if iswin() then + screen = thelpers.screen_setup(nil, + "['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30) + else + screen = thelpers.screen_setup(nil, "['sh']", 30) + end curbufmeths.set_option('scrollback', 0) - feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + end screen:expect('line30 ', nil, nil, nil, true) retry(nil, nil, function() expect_lines(7) end) @@ -395,7 +431,13 @@ describe("'scrollback' option", function() end) it('deletes lines (only) if necessary', function() - local screen = thelpers.screen_setup(nil, "['sh']", 30) + local screen + if iswin() then + screen = thelpers.screen_setup(nil, + "['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30) + else + screen = thelpers.screen_setup(nil, "['sh']", 30) + end curbufmeths.set_option('scrollback', 200) @@ -403,7 +445,11 @@ describe("'scrollback' option", function() screen:expect('$', nil, nil, nil, true) wait() - feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 30); do echo "line$i"; done\n') + end screen:expect('line30 ', nil, nil, nil, true) @@ -416,7 +462,11 @@ describe("'scrollback' option", function() -- Terminal job data is received asynchronously, may happen before the -- 'scrollback' option is synchronized with the internal sb_buffer. command('sleep 100m') - feed_data('for i in $(seq 1 40); do echo "line$i"; done\n') + if iswin() then + feed_data('for($i=1;$i -le 40;$i++){Write-Host \"line$i\"}\r') + else + feed_data('for i in $(seq 1 40); do echo "line$i"; done\n') + end screen:expect('line40 ', nil, nil, nil, true) diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index 888b1e1328..0f705cfe40 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -3,8 +3,6 @@ local thelpers = require('test.functional.terminal.helpers') local feed, clear = helpers.feed, helpers.clear local wait = helpers.wait -if helpers.pending_win32(pending) then return end - describe('terminal window', function() local screen |