diff options
author | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
commit | 03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f (patch) | |
tree | a3a05c99fe20de98aafbdea9314aa0d76f71aee9 /test/functional | |
parent | 6ea3a08fdbb276fe64dda60c5fb934360327ed39 (diff) | |
parent | de8b1fd1dee5a91b2893fccc53cfd11631ccba38 (diff) | |
download | rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.gz rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.bz2 rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.zip |
Merge branch 'master' into expression-parser
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/core/startup_spec.lua | 96 | ||||
-rw-r--r-- | test/functional/eval/special_vars_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/ex_cmds/mkview_spec.lua | 67 | ||||
-rw-r--r-- | test/functional/fixtures/api_level_3.mpack | bin | 0 -> 19501 bytes | |||
-rw-r--r-- | test/functional/plugin/health_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/terminal/cursor_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/terminal/mouse_spec.lua | 28 | ||||
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/terminal/window_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/terminal/window_split_tab_spec.lua | 91 |
11 files changed, 263 insertions, 71 deletions
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua new file mode 100644 index 0000000000..ae7f949e52 --- /dev/null +++ b/test/functional/core/startup_spec.lua @@ -0,0 +1,96 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') + +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +local funcs = helpers.funcs +local nvim_prog = helpers.nvim_prog +local nvim_set = helpers.nvim_set +local read_file = helpers.read_file +local retry = helpers.retry +local iswin = helpers.iswin + +describe('startup', function() + before_each(function() + clear() + end) + after_each(function() + os.remove('Xtest_startup_ttyout') + end) + + it('pipe at both ends: has("ttyin")==0 has("ttyout")==0', function() + -- system() puts a pipe at both ends. + local out = funcs.system({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--headless', + '--cmd', nvim_set, + '-c', [[echo has('ttyin') has('ttyout')]], + '+q' }) + eq('0 0', out) + end) + it('with --embed: has("ttyin")==0 has("ttyout")==0', function() + local screen = Screen.new(25, 3) + -- Remote UI connected by --embed. + screen:attach() + command([[echo has('ttyin') has('ttyout')]]) + screen:expect([[ + ^ | + ~ | + 0 0 | + ]]) + end) + it('in a TTY: has("ttyin")==1 has("ttyout")==1', function() + local screen = Screen.new(25, 3) + screen:attach() + if iswin() then + command([[set shellcmdflag=/s\ /c shellxquote=\"]]) + end + -- Running in :terminal + command([[exe printf("terminal %s -u NONE -i NONE --cmd \"]] + ..nvim_set..[[\" ]] + ..[[-c \"echo has('ttyin') has('ttyout')\""]] + ..[[, shellescape(v:progpath))]]) + screen:expect([[ + ^ | + 1 1 | + | + ]]) + end) + it('output to pipe: has("ttyin")==1 has("ttyout")==0', function() + local screen = Screen.new(25, 5) + screen:attach() + if iswin() then + command([[set shellcmdflag=/s\ /c shellxquote=\"]]) + end + -- Running in :terminal + command([[exe printf("terminal %s -u NONE -i NONE --cmd \"]] + ..nvim_set..[[\" ]] + ..[[-c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] + ..[[-c q | cat -v"]] -- Output to a pipe. + ..[[, shellescape(v:progpath))]]) + retry(nil, 3000, function() + screen:sleep(1) + eq('1\n0\n', -- stdin is a TTY, stdout is a pipe + read_file('Xtest_startup_ttyout')) + end) + end) + it('input from pipe: has("ttyin")==0 has("ttyout")==1', function() + local screen = Screen.new(25, 5) + screen:attach() + if iswin() then + command([[set shellcmdflag=/s\ /c shellxquote=\"]]) + end + -- Running in :terminal + command([[exe printf("terminal echo foo | ]] -- Input from a pipe. + ..[[%s -u NONE -i NONE --cmd \"]] + ..nvim_set..[[\" ]] + ..[[-c \"call writefile([has('ttyin'), has('ttyout')], 'Xtest_startup_ttyout')\"]] + ..[[-c q -- -"]] + ..[[, shellescape(v:progpath))]]) + retry(nil, 3000, function() + screen:sleep(1) + eq('0\n1\n', -- stdin is a pipe, stdout is a TTY + read_file('Xtest_startup_ttyout')) + end) + end) +end) + diff --git a/test/functional/eval/special_vars_spec.lua b/test/functional/eval/special_vars_spec.lua index 3d9358447e..b5773a5529 100644 --- a/test/functional/eval/special_vars_spec.lua +++ b/test/functional/eval/special_vars_spec.lua @@ -168,4 +168,11 @@ describe('Special values', function() 'Expected True but got v:null', }, meths.get_vvar('errors')) end) + + describe('compat', function() + it('v:count is distinct from count', function() + command('let count = []') -- v:count is readonly + eq(1, eval('count is# g:["count"]')) + end) + end) end) diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua new file mode 100644 index 0000000000..97a49dbbd5 --- /dev/null +++ b/test/functional/ex_cmds/mkview_spec.lua @@ -0,0 +1,67 @@ +local lfs = require('lfs') +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local command = helpers.command +local get_pathsep = helpers.get_pathsep +local eq = helpers.eq +local funcs = helpers.funcs +local rmdir = helpers.rmdir + +local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec' + +describe(':mkview', function() + local tmp_file_base = file_prefix .. '-tmpfile' + local local_dir = file_prefix .. '.d' + local view_dir = file_prefix .. '.view.d' + + before_each(function() + clear() + lfs.mkdir(view_dir) + lfs.mkdir(local_dir) + end) + + after_each(function() + -- Remove any views created in the view directory + rmdir(view_dir) + lfs.rmdir(local_dir) + end) + + it('viewoption curdir restores local current directory', function() + local cwd_dir = funcs.getcwd() + local set_view_dir_command = 'set viewdir=' .. cwd_dir .. + get_pathsep() .. view_dir + + -- By default the local current directory should save + command(set_view_dir_command) + command('edit ' .. tmp_file_base .. '1') + command('lcd ' .. local_dir) + command('mkview') + + -- Create a new instance of Nvim to remove the 'lcd' + clear() + + -- Disable saving the local current directory for the second view + command(set_view_dir_command) + command('set viewoptions-=curdir') + command('edit ' .. tmp_file_base .. '2') + command('lcd ' .. local_dir) + command('mkview') + + -- Create a new instance of Nvim to test saved 'lcd' option + clear() + command(set_view_dir_command) + + -- Load the view without a saved local current directory + command('edit ' .. tmp_file_base .. '2') + command('loadview') + -- The view's current directory should not have changed + eq(cwd_dir, funcs.getcwd()) + -- Load the view with a saved local current directory + command('edit ' .. tmp_file_base .. '1') + command('loadview') + -- The view's local directory should have been saved + eq(cwd_dir .. get_pathsep() .. local_dir, funcs.getcwd()) + end) + +end) diff --git a/test/functional/fixtures/api_level_3.mpack b/test/functional/fixtures/api_level_3.mpack Binary files differnew file mode 100644 index 0000000000..ef36b99c8c --- /dev/null +++ b/test/functional/fixtures/api_level_3.mpack diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index b5374210e6..8ee0f258d0 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -16,6 +16,13 @@ describe(':checkhealth', function() eq(false, status) eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*')) end) + it("detects invalid 'runtimepath'", function() + clear() + command('set runtimepath=bogus') + local status, err = pcall(command, 'checkhealth') + eq(false, status) + eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*')) + end) it("detects invalid $VIM", function() clear() -- Do this after startup, otherwise it just breaks $VIMRUNTIME. diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index d49f1bfc23..d942723d02 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -50,8 +50,8 @@ describe('terminal cursor', function() it('is positioned correctly when unfocused', function() screen:expect([[ {7: 1 }tty ready | - {7: 2 }{2:^ } | - {7: 3 } | + {7: 2 }^rows: 6, cols: 46 | + {7: 3 }{2: } | {7: 4 } | {7: 5 } | {7: 6 } | @@ -60,12 +60,21 @@ describe('terminal cursor', function() end) it('is positioned correctly when focused', function() + screen:expect([[ + {7: 1 }tty ready | + {7: 2 }^rows: 6, cols: 46 | + {7: 3 }{2: } | + {7: 4 } | + {7: 5 } | + {7: 6 } | + :set number | + ]]) feed('i') helpers.wait() screen:expect([[ {7: 1 }tty ready | - {7: 2 }{1: } | - {7: 3 } | + {7: 2 }rows: 6, cols: 46 | + {7: 3 }{1: } | {7: 4 } | {7: 5 } | {7: 6 } | diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua index 29c62d7be7..5e5558ee0a 100644 --- a/test/functional/terminal/mouse_spec.lua +++ b/test/functional/terminal/mouse_spec.lua @@ -101,7 +101,7 @@ describe('terminal mouse', function() line28 |line28 | line29 |line29 | line30 |line30 | - rows: 5, cols: 25 |rows: 5, cols: 25 | + rows: 5, cols: 24 |rows: 5, cols: 24 | {2:^ } |{2: } | ========== ========== | :vsp | @@ -111,7 +111,7 @@ describe('terminal mouse', function() {7: 1 }^ |line28 | {4:~ }|line29 | {4:~ }|line30 | - {4:~ }|rows: 5, cols: 25 | + {4:~ }|rows: 5, cols: 24 | {4:~ }|{2: } | ========== ========== | :enew | set number | @@ -121,16 +121,16 @@ describe('terminal mouse', function() {7: 27 }line |line28 | {7: 28 }line |line29 | {7: 29 }line |line30 | - {7: 30 }line |rows: 5, cols: 25 | + {7: 30 }line |rows: 5, cols: 24 | {7: 31 }^ |{2: } | ========== ========== | | ]]) feed('<c-w>li') screen:expect([[ - {7: 27 }line |line29 | - {7: 28 }line |line30 | - {7: 29 }line |rows: 5, cols: 25 | + {7: 27 }line |line28 | + {7: 28 }line |line29 | + {7: 29 }line |line30 | {7: 30 }line |rows: 5, cols: 24 | {7: 31 } |{1: } | ========== ========== | @@ -140,8 +140,8 @@ describe('terminal mouse', function() thelpers.enable_mouse() thelpers.feed_data('mouse enabled\n') screen:expect([[ - {7: 27 }line |line30 | - {7: 28 }line |rows: 5, cols: 25 | + {7: 27 }line |line29 | + {7: 28 }line |line30 | {7: 29 }line |rows: 5, cols: 24 | {7: 30 }line |mouse enabled | {7: 31 } |{1: } | @@ -153,8 +153,8 @@ describe('terminal mouse', function() it('wont lose focus if another window is scrolled', function() feed('<ScrollWheelUp><0,0><ScrollWheelUp><0,0>') screen:expect([[ - {7: 21 }line |line30 | - {7: 22 }line |rows: 5, cols: 25 | + {7: 21 }line |line29 | + {7: 22 }line |line30 | {7: 23 }line |rows: 5, cols: 24 | {7: 24 }line |mouse enabled | {7: 25 }line |{1: } | @@ -163,8 +163,8 @@ describe('terminal mouse', function() ]]) feed('<S-ScrollWheelDown><0,0>') screen:expect([[ - {7: 26 }line |line30 | - {7: 27 }line |rows: 5, cols: 25 | + {7: 26 }line |line29 | + {7: 27 }line |line30 | {7: 28 }line |rows: 5, cols: 24 | {7: 29 }line |mouse enabled | {7: 30 }line |{1: } | @@ -176,8 +176,8 @@ describe('terminal mouse', function() it('will lose focus if another window is clicked', function() feed('<LeftMouse><5,1>') screen:expect([[ - {7: 27 }line |line30 | - {7: 28 }l^ine |rows: 5, cols: 25 | + {7: 27 }line |line29 | + {7: 28 }l^ine |line30 | {7: 29 }line |rows: 5, cols: 24 | {7: 30 }line |mouse enabled | {7: 31 } |{2: } | diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index af9b414311..c665e64a80 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -462,10 +462,10 @@ describe("'scrollback' option", function() screen:detach() end) - it('defaults to 1000 in terminal buffers', function() + it('defaults to 10000 in terminal buffers', function() set_fake_shell() command('terminal') - eq(1000, curbufmeths.get_option('scrollback')) + eq(10000, curbufmeths.get_option('scrollback')) end) it('error if set to invalid value', function() diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index d36eb46e54..777ef65d9e 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -380,7 +380,7 @@ describe("tui 't_Co' (terminal colors)", function() -- TODO: Revisit this after jobstart/termopen accept `env` dict. screen = thelpers.screen_setup(0, string.format( [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "silent set noswapfile noshowcmd noruler"']]=], - term, + term or "", (colorterm ~= nil and "COLORTERM="..colorterm or ""), helpers.nvim_prog)) diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index 231618c5da..842a81872e 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -43,14 +43,23 @@ describe('terminal window', function() -- numberwidth=9 feed([[<C-\><C-N>]]) feed([[:set numberwidth=9 number<CR>i]]) + screen:expect([[ + {7: 1 }tty ready | + {7: 2 }rows: 6, cols: 48 | + {7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| + {7: 4 }WXYZrows: 6, cols: 41 | + {7: 5 }{1: } | + {7: 6 } | + {3:-- TERMINAL --} | + ]]) thelpers.feed_data({' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}) screen:expect([[ {7: 1 }tty ready | {7: 2 }rows: 6, cols: 48 | {7: 3 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO| - {7: 4 }WXYZ abcdefghijklmnopqrstuvwxyzABCDEFGHIJ| - {7: 5 }KLMNOPQRSTUVWXYZrows: 6, cols: 41 | - {7: 6 }{1: } | + {7: 4 }WXYZrows: 6, cols: 41 | + {7: 5 } abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN| + {7: 6 }OPQRSTUVWXYZ{1: } | {3:-- TERMINAL --} | ]]) end) diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index c5199f620e..714c2476ce 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -3,6 +3,9 @@ local thelpers = require('test.functional.terminal.helpers') local clear = helpers.clear local feed, nvim = helpers.feed, helpers.nvim local feed_command = helpers.feed_command +local command = helpers.command +local eq = helpers.eq +local eval = helpers.eval describe('terminal', function() local screen @@ -22,72 +25,66 @@ describe('terminal', function() screen:detach() end) - it('resets its size when entering terminal window', function() + it('next to a closing window', function() + command('split') + command('terminal') + command('vsplit foo') + eq(3, eval("winnr('$')")) + feed('ZQ') -- Close split, should not crash. #7538 + eq(2, eval("1+1")) -- Still alive? + end) + + it('does not change size on WinEnter', function() if helpers.pending_win32(pending) then return end feed('<c-\\><c-n>') feed_command('2split') screen:expect([[ - rows: 2, cols: 50 | - {2:^ } | - ========== | - rows: 2, cols: 50 | - {2: } | - {4:~ }| - {4:~ }| - {4:~ }| - ========== | - :2split | - ]]) - feed_command('wincmd p') - screen:expect([[ tty ready | - rows: 2, cols: 50 | + ^rows: 5, cols: 50 | ========== | tty ready | - rows: 2, cols: 50 | rows: 5, cols: 50 | {2: } | - ^ | + | + | ========== | - :wincmd p | + :2split | ]]) feed_command('wincmd p') screen:expect([[ - rows: 2, cols: 50 | - {2:^ } | + tty ready | + rows: 5, cols: 50 | ========== | - rows: 2, cols: 50 | + tty ready | + ^rows: 5, cols: 50 | {2: } | - {4:~ }| - {4:~ }| - {4:~ }| + | + | ========== | :wincmd p | ]]) end) - describe('when the screen is resized', function() - it('will forward a resize request to the program', function() - feed([[<C-\><C-N>:]]) -- Go to cmdline-mode, so cursor is at bottom. - screen:try_resize(screen._width - 3, screen._height - 2) - screen:expect([[ - tty ready | - rows: 7, cols: 47 | - {2: } | - | - | - | - | - :^ | - ]]) - screen:try_resize(screen._width - 6, screen._height - 3) - screen:expect([[ - tty ready | - rows: 7, cols: 47 | - rows: 4, cols: 41 | - {2: } | - :^ | - ]]) - end) + it('forwards resize request to the program', function() + feed([[<C-\><C-N>:]]) -- Go to cmdline-mode, so cursor is at bottom. + screen:try_resize(screen._width - 3, screen._height - 2) + screen:expect([[ + tty ready | + rows: 7, cols: 47 | + {2: } | + | + | + | + | + :^ | + ]]) + screen:try_resize(screen._width - 6, screen._height - 3) + screen:expect([[ + tty ready | + rows: 7, cols: 47 | + rows: 4, cols: 41 | + {2: } | + :^ | + ]]) end) end) |