diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/buffer_updates_spec.lua | 79 | ||||
-rw-r--r-- | test/functional/api/highlight_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/api/rpc_fixture.lua | 2 | ||||
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 17 | ||||
-rw-r--r-- | test/functional/eval/setpos_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ex_cmds/debug_spec.lua | 110 | ||||
-rw-r--r-- | test/functional/ex_cmds/write_spec.lua | 20 | ||||
-rw-r--r-- | test/functional/ex_cmds/wviminfo_spec.lua | 18 | ||||
-rw-r--r-- | test/functional/legacy/011_autocommands_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/legacy/097_glob_path_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/assert_spec.lua | 15 | ||||
-rw-r--r-- | test/functional/legacy/delete_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/provider/nodejs_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 13 | ||||
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 101 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 23 | ||||
-rw-r--r-- | test/helpers.lua | 2 |
19 files changed, 342 insertions, 100 deletions
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 00409c1528..6da790b871 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -3,6 +3,7 @@ local eq, ok = helpers.eq, helpers.ok local buffer, command, eval, nvim, next_msg = helpers.buffer, helpers.command, helpers.eval, helpers.nvim, helpers.next_msg local expect_err = helpers.expect_err +local write_file = helpers.write_file local origlines = {"original line 1", "original line 2", @@ -18,7 +19,7 @@ end local function sendkeys(keys) nvim('input', keys) - -- give neovim some time to process msgpack requests before possibly sending + -- give nvim some time to process msgpack requests before possibly sending -- more key presses - otherwise they all pile up in the queue and get -- processed at once local ntime = os.clock() + 0.1 @@ -27,14 +28,14 @@ end local function open(activate, lines) local filename = helpers.tmpname() - helpers.write_file(filename, table.concat(lines, "\n").."\n", true) + write_file(filename, table.concat(lines, "\n").."\n", true) command('edit ' .. filename) local b = nvim('get_current_buf') -- what is the value of b:changedtick? local tick = eval('b:changedtick') - -- turn on live updates, ensure that the nvim_buf_lines_event messages - -- arrive as expectected + -- Enable buffer events, ensure that the nvim_buf_lines_event messages + -- arrive as expected if activate then local firstline = 0 ok(buffer('attach', b, true, {})) @@ -91,8 +92,8 @@ local function reopenwithfolds(b) return tick end -describe('buffer events', function() - it('when you add line to a buffer', function() +describe('API: buffer events:', function() + it('when lines are added', function() local b, tick = editoriginal(true) -- add a new line at the start of the buffer @@ -156,7 +157,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 29, 29, firstfour, false}) -- create a new empty buffer and wipe out the old one ... this will - -- turn off live updates + -- turn off buffer events command('enew!') expectn('nvim_buf_detach_event', {b}) @@ -170,7 +171,7 @@ describe('buffer events', function() tick = tick + 1 expectn('nvim_buf_lines_event', {b2, tick, 0, 0, {'new line 1'}, false}) - -- turn off live updates manually + -- turn off buffer events manually buffer('detach', b2) expectn('nvim_buf_detach_event', {b2}) @@ -192,7 +193,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b3, tick, 0, 0, {"New First Line"}, false}) end) - it('knows when you remove lines from a buffer', function() + it('when lines are removed', function() local b, tick = editoriginal(true) -- remove one line from start of file @@ -231,7 +232,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 4, 6, {}, false}) end) - it('knows when you modify lines of text', function() + it('when text is changed', function() local b, tick = editoriginal(true) -- some normal text editing @@ -286,7 +287,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {bnew, tick + 7, 1, 2, {'world'}, false}) end) - it('knows when you replace lines', function() + it('when lines are replaced', function() local b, tick = editoriginal(true) -- blast away parts of some lines with visual mode @@ -311,7 +312,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 3, 4, {}, false}) end) - it('knows when you filter lines', function() + it('when lines are filtered', function() -- Test filtering lines with !cat local b, tick = editoriginal(true, {"A", "C", "E", "B", "D", "F"}) @@ -325,7 +326,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 1, 5, {}, false}) end) - it('sends a sensible event when you use "o"', function() + it('when you use "o"', function() local b, tick = editoriginal(true, {'AAA', 'BBB'}) command('set noautoindent nosmartindent') @@ -365,7 +366,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 0, 1, {"\tmmm"}, false}) end) - it('deactivates when your buffer changes outside vim', function() + it('deactivates if the buffer is changed externally', function() -- Test changing file from outside vim and reloading using :edit local lines = {"Line 1", "Line 2"}; local b, tick, filename = editoriginal(true, lines) @@ -380,17 +381,14 @@ describe('buffer events', function() expectn('nvim_buf_changedtick_event', {b, tick}) -- change the file directly - local f = io.open(filename, 'a') - f:write("another line\n") - f:flush() - f:close() + write_file(filename, "another line\n", true, true) - -- reopen the file and watch live updates shut down + -- reopen the file and watch buffer events shut down command('edit') expectn('nvim_buf_detach_event', {b}) end) - it('allows a channel to watch multiple buffers at once', function() + it('channel can watch many buffers at once', function() -- edit 3 buffers, make sure they all have windows visible so that when we -- move between buffers, none of them are unloaded local b1, tick1 = editoriginal(true, {'A1', 'A2'}) @@ -436,12 +434,12 @@ describe('buffer events', function() expectn('nvim_buf_changedtick_event', {b3, tick3}) end) - it('doesn\'t get confused when you turn watching on/off many times', + it('does not get confused if enabled/disabled many times', function() local channel = nvim('get_api_info')[1] local b, tick = editoriginal(false) - -- turn on live updates many times + -- Enable buffer events many times. ok(buffer('attach', b, true, {})) ok(buffer('attach', b, true, {})) ok(buffer('attach', b, true, {})) @@ -451,7 +449,7 @@ describe('buffer events', function() eval('rpcnotify('..channel..', "Hello There")') expectn('Hello There', {}) - -- turn live updates off many times + -- Disable buffer events many times. ok(buffer('detach', b)) ok(buffer('detach', b)) ok(buffer('detach', b)) @@ -462,7 +460,7 @@ describe('buffer events', function() expectn('Hello Again', {}) end) - it('is able to notify several channels at once', function() + it('can notify several channels at once', function() helpers.clear() -- create several new sessions, in addition to our main API @@ -486,11 +484,11 @@ describe('buffer events', function() eq({'notification', name, args}, session:next_message()) end - -- edit a new file, but don't turn on live updates + -- Edit a new file, but don't enable buffer events. local lines = {'AAA', 'BBB'} local b, tick = open(false, lines) - -- turn on live updates for sessions 1, 2 and 3 + -- Enable buffer events for sessions 1, 2 and 3. ok(request(1, 'nvim_buf_attach', b, true, {})) ok(request(2, 'nvim_buf_attach', b, true, {})) ok(request(3, 'nvim_buf_attach', b, true, {})) @@ -498,18 +496,18 @@ describe('buffer events', function() wantn(2, 'nvim_buf_lines_event', {b, tick, 0, -1, lines, false}) wantn(3, 'nvim_buf_lines_event', {b, tick, 0, -1, lines, false}) - -- make a change to the buffer + -- Change the buffer. command('normal! x') tick = tick + 1 wantn(1, 'nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) wantn(2, 'nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) wantn(3, 'nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) - -- stop watching on channel 1 + -- Stop watching on channel 1. ok(request(1, 'nvim_buf_detach', b)) wantn(1, 'nvim_buf_detach_event', {b}) - -- undo the change to buffer 1 + -- Undo the change to buffer 1. command('undo') tick = tick + 1 wantn(2, 'nvim_buf_lines_event', {b, tick, 0, 1, {'AAA'}, false}) @@ -612,7 +610,7 @@ describe('buffer events', function() expectn('nvim_buf_lines_event', {b, tick, 5, 7, {}, false}) end) - it('sends sensible events when you manually add/remove folds', function() + it('when you manually add/remove folds', function() local b = editoriginal(true) local tick = reopenwithfolds(b) @@ -656,11 +654,11 @@ describe('buffer events', function() 'original line 6'}, false}) end) - it('turns off updates when a buffer is closed', function() + it('detaches if the buffer is closed', function() local b, tick = editoriginal(true, {'AAA'}) local channel = nvim('get_api_info')[1] - -- test live updates are working + -- Test that buffer events are working. command('normal! x') tick = tick + 1 expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) @@ -674,7 +672,7 @@ describe('buffer events', function() command('enew') expectn('nvim_buf_detach_event', {b}) - -- reopen the original buffer, make sure there are no Live Updates sent + -- Reopen the original buffer, make sure there are no buffer events sent. command('b1') command('normal! x') @@ -682,12 +680,11 @@ describe('buffer events', function() expectn('Hello There', {}) end) - -- test what happens when a buffer is hidden - it('keeps updates turned on if the buffer is hidden', function() + it('stays attached if the buffer is hidden', function() local b, tick = editoriginal(true, {'AAA'}) local channel = nvim('get_api_info')[1] - -- test live updates are working + -- Test that buffer events are working. command('normal! x') tick = tick + 1 expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) @@ -697,22 +694,22 @@ describe('buffer events', function() tick = tick + 1 expectn('nvim_buf_changedtick_event', {b, tick}) - -- close our buffer by creating a new one + -- Close our buffer by creating a new one. command('set hidden') command('enew') - -- note that no nvim_buf_detach_event is sent + -- Assert that no nvim_buf_detach_event is sent. eval('rpcnotify('..channel..', "Hello There")') expectn('Hello There', {}) - -- reopen the original buffer, make sure Live Updates are still active + -- Reopen the original buffer, assert that buffer events are still active. command('b1') command('normal! x') tick = tick + 1 expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) end) - it('turns off live updates when a buffer is unloaded, deleted, or wiped', + it('detaches if the buffer is unloaded/deleted/wiped', function() -- start with a blank nvim helpers.clear() @@ -730,7 +727,7 @@ describe('buffer events', function() end end) - it('doesn\'t send the buffer\'s content when not requested', function() + it('does not send the buffer content if not requested', function() helpers.clear() local b, tick = editoriginal(false) ok(buffer('attach', b, false, {})) diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index fed53a3dfd..76bf338d97 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -5,7 +5,7 @@ local eq, eval = helpers.eq, helpers.eval local command = helpers.command local meths = helpers.meths -describe('highlight api',function() +describe('API: highlight',function() local expected_rgb = { background = Screen.colors.Yellow, foreground = Screen.colors.Red, diff --git a/test/functional/api/rpc_fixture.lua b/test/functional/api/rpc_fixture.lua index 423864740f..e885a525af 100644 --- a/test/functional/api/rpc_fixture.lua +++ b/test/functional/api/rpc_fixture.lua @@ -31,7 +31,7 @@ end local function on_notification(event, args) if event == 'ping' and #args == 0 then - session:notify("vim_eval", "rpcnotify(g:channel, 'pong')") + session:notify("nvim_eval", "rpcnotify(g:channel, 'pong')") end end diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index e79a60fb10..856e5ca4d2 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -222,7 +222,7 @@ describe('server -> client', function() end) it('returns an error if the request failed', function() - expect_err('Vim:Invalid method name', + expect_err('Vim:Invalid method: does%-not%-exist', eval, "rpcrequest(vim, 'does-not-exist')") end) end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 1e910b6aa7..e4b343c123 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -20,9 +20,20 @@ local format_string = global_helpers.format_string local intchar2lua = global_helpers.intchar2lua local mergedicts_copy = global_helpers.mergedicts_copy -describe('api', function() +describe('API', function() before_each(clear) + it('validates requests', function() + expect_err('Invalid method: bogus', + request, 'bogus') + expect_err('Invalid method: … の り 。…', + request, '… の り 。…') + expect_err('Invalid method: <empty>', + request, '') + expect_err("can't serialize object", + request, nil) + end) + describe('nvim_command', function() it('works', function() local fname = helpers.tmpname() @@ -924,7 +935,7 @@ describe('api', function() {'i_am_not_a_method', {'xx'}}, {'nvim_set_var', {'avar', 10}}, } - eq({{}, {0, error_types.Exception.id, 'Invalid method name'}}, + eq({{}, {0, error_types.Exception.id, 'Invalid method: i_am_not_a_method'}}, meths.call_atomic(req)) eq(5, meths.get_var('avar')) end) @@ -1226,6 +1237,7 @@ describe('api', function() screen:attach() local expected = { { + chan = 1, ext_cmdline = false, ext_popupmenu = false, ext_tabline = false, @@ -1242,6 +1254,7 @@ describe('api', function() screen:attach({ rgb = false }) expected = { { + chan = 1, ext_cmdline = false, ext_popupmenu = false, ext_tabline = false, diff --git a/test/functional/eval/setpos_spec.lua b/test/functional/eval/setpos_spec.lua index 6a8b3a8732..935f387bcc 100644 --- a/test/functional/eval/setpos_spec.lua +++ b/test/functional/eval/setpos_spec.lua @@ -27,9 +27,8 @@ describe('setpos() function', function() eq(getpos("."), {0, 2, 1, 0}) setpos(".", {2, 1, 1, 0}) eq(getpos("."), {0, 1, 1, 0}) - -- Ensure get an error attempting to set position to another buffer local ret = exc_exec('call setpos(".", [1, 1, 1, 0])') - eq('Vim(call):E474: Invalid argument', ret) + eq(0, ret) end) it('can set lowercase marks in the current buffer', function() setpos("'d", {0, 2, 1, 0}) diff --git a/test/functional/ex_cmds/debug_spec.lua b/test/functional/ex_cmds/debug_spec.lua new file mode 100644 index 0000000000..5dad8098ea --- /dev/null +++ b/test/functional/ex_cmds/debug_spec.lua @@ -0,0 +1,110 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local feed = helpers.feed +local clear = helpers.clear + +describe(':debug', function() + local screen + before_each(function() + clear() + screen = Screen.new(50, 14) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, + [2] = {bold = true, reverse = true}, + [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, + }) + screen:attach() + end) + it('scrolls messages correctly', function() + feed(':echoerr bork<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2: }| + {3:E121: Undefined variable: bork} | + {3:E15: Invalid expression: bork} | + {4:Press ENTER or type command to continue}^ | + ]]) + + feed(':debug echo "aa"| echo "bb"<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2: }| + {3:E121: Undefined variable: bork} | + {3:E15: Invalid expression: bork} | + Entering Debug mode. Type "cont" to continue. | + cmd: echo "aa"| echo "bb" | + >^ | + ]]) + + feed('step<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2: }| + {3:E121: Undefined variable: bork} | + {3:E15: Invalid expression: bork} | + Entering Debug mode. Type "cont" to continue. | + cmd: echo "aa"| echo "bb" | + >step | + aa | + cmd: echo "bb" | + >^ | + ]]) + + feed('step<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {2: }| + {3:E121: Undefined variable: bork} | + {3:E15: Invalid expression: bork} | + Entering Debug mode. Type "cont" to continue. | + cmd: echo "aa"| echo "bb" | + >step | + aa | + cmd: echo "bb" | + >step | + bb | + {4:Press ENTER or type command to continue}^ | + ]]) + + feed('<cr>') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) +end) diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index bcf83698bb..3f54ff6f41 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -9,6 +9,7 @@ local command = helpers.command local feed_command = helpers.feed_command local funcs = helpers.funcs local meths = helpers.meths +local iswin = helpers.iswin local fname = 'Xtest-functional-ex_cmds-write' local fname_bak = fname .. '~' @@ -34,11 +35,14 @@ describe(':write', function() it('&backupcopy=auto preserves symlinks', function() command('set backupcopy=auto') write_file('test_bkc_file.txt', 'content0') - if helpers.iswin() then + if iswin() then command("silent !mklink test_bkc_link.txt test_bkc_file.txt") else command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") end + if eval('v:shell_error') ~= 0 then + pending('Cannot create symlink', function()end) + end source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -51,11 +55,14 @@ describe(':write', function() it('&backupcopy=no replaces symlink with new file', function() command('set backupcopy=no') write_file('test_bkc_file.txt', 'content0') - if helpers.iswin() then + if iswin() then command("silent !mklink test_bkc_link.txt test_bkc_file.txt") else command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") end + if eval('v:shell_error') ~= 0 then + pending('Cannot create symlink', function()end) + end source([[ edit test_bkc_link.txt call setline(1, ['content1']) @@ -66,7 +73,8 @@ describe(':write', function() end) it("appends FIFO file", function() - if eval("executable('mkfifo')") == 0 then + -- mkfifo creates read-only .lnk files on Windows + if iswin() or eval("executable('mkfifo')") == 0 then pending('missing "mkfifo" command', function()end) return end @@ -88,7 +96,7 @@ describe(':write', function() command('let $HOME=""') eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~')) -- Message from check_overwrite - if not helpers.iswin() then + if not iswin() then eq(('\nE17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), redir_exec('write .')) end @@ -108,7 +116,7 @@ describe(':write', function() funcs.setfperm(fname, 'r--------') eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)', exc_exec('write')) - if helpers.iswin() then + if iswin() then eq(0, os.execute('del /q/f ' .. fname)) eq(0, os.execute('rd /q/s ' .. fname_bak)) else @@ -117,7 +125,7 @@ describe(':write', function() end write_file(fname_bak, 'TTYX') -- FIXME: exc_exec('write!') outputs 0 in Windows - if helpers.iswin() then return end + if iswin() then return end lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true) eq('Vim(write):E166: Can\'t open linked file for writing', exc_exec('write!')) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index eebbd70f2b..df0b9df5dd 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -3,21 +3,21 @@ local lfs = require('lfs') local command, eq, neq, spawn, nvim_prog, set_session, write_file = helpers.command, helpers.eq, helpers.neq, helpers.spawn, helpers.nvim_prog, helpers.set_session, helpers.write_file +local iswin = helpers.iswin +local read_file = helpers.read_file describe(':wshada', function() local shada_file = 'wshada_test' local session before_each(function() - if session then - session:close() - end - -- Override the default session because we need 'swapfile' for these tests. - session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed', + session = spawn({nvim_prog, '-u', 'NONE', '-i', iswin() and 'nul' or '/dev/null', '--embed', '--cmd', 'set swapfile'}) set_session(session) - + end) + after_each(function () + session:close() os.remove(shada_file) end) @@ -36,7 +36,7 @@ describe(':wshada', function() write_file(shada_file, text) -- sanity check - eq(text, io.open(shada_file):read()) + eq(text, read_file(shada_file)) neq(nil, lfs.attributes(shada_file)) command('wsh! '..shada_file) @@ -49,8 +49,4 @@ describe(':wshada', function() assert(char1:byte() == 0x01, shada_file..' should be a shada file') end) - - teardown(function() - os.remove(shada_file) - end) end) diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index c2667d28d2..379646b2ba 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -17,9 +17,10 @@ local lfs = require('lfs') local clear, feed_command, expect, eq, neq, dedent, write_file, feed = helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.dedent, helpers.write_file, helpers.feed +local iswin = helpers.iswin local function has_gzip() - local null = helpers.iswin() and 'nul' or '/dev/null' + local null = iswin() and 'nul' or '/dev/null' return os.execute('gzip --help >' .. null .. ' 2>&1') == 0 end @@ -59,7 +60,7 @@ describe('file reading, writing and bufnew and filter autocommands', function() os.remove('test.out') end) - if not has_gzip() then + if iswin() or not has_gzip() then pending('skipped (missing `gzip` utility)', function() end) else diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua index 907f0665ae..ccd93fed60 100644 --- a/test/functional/legacy/097_glob_path_spec.lua +++ b/test/functional/legacy/097_glob_path_spec.lua @@ -74,7 +74,7 @@ describe('glob() and globpath()', function() teardown(function() if helpers.iswin() then os.execute('del /q/f Xxx{ Xxx$') - os.execute('rd /q sautest') + os.execute('rd /q /s sautest') else os.execute("rm -rf sautest Xxx{ Xxx$") end diff --git a/test/functional/legacy/assert_spec.lua b/test/functional/legacy/assert_spec.lua index 381461dc4f..10703465aa 100644 --- a/test/functional/legacy/assert_spec.lua +++ b/test/functional/legacy/assert_spec.lua @@ -77,6 +77,11 @@ describe('assert function:', function() eq('Vim(call):E724: unable to correctly dump variable with self-referencing container', exc_exec('call CheckAssert()')) end) + + it('can specify a message and get a message about what failed', function() + call('assert_equal', 'foo', 'bar', 'testing') + expected_errors({"testing: Expected 'foo' but got 'bar'"}) + end) end) -- assert_notequal({expected}, {actual}[, {msg}]) @@ -164,10 +169,10 @@ describe('assert function:', function() call assert_true('', 'file two') ]]) expected_errors({ - tmpname_one .. " line 1: 'equal assertion failed'", - tmpname_one .. " line 2: 'true assertion failed'", - tmpname_one .. " line 3: 'false assertion failed'", - tmpname_two .. " line 1: 'file two'", + tmpname_one .. " line 1: equal assertion failed: Expected 1 but got 100", + tmpname_one .. " line 2: true assertion failed: Expected False but got 'true'", + tmpname_one .. " line 3: false assertion failed: Expected True but got 'false'", + tmpname_two .. " line 1: file two: Expected True but got ''", }) end) @@ -198,7 +203,7 @@ describe('assert function:', function() it('should set v:errors to msg when given and match fails', function() call('assert_match', 'bar.*foo', 'foobar', 'wrong') - expected_errors({"'wrong'"}) + expected_errors({"wrong: Pattern 'bar.*foo' does not match 'foobar'"}) end) end) diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua index 5ef456bfe3..9ea3269828 100644 --- a/test/functional/legacy/delete_spec.lua +++ b/test/functional/legacy/delete_spec.lua @@ -4,6 +4,9 @@ local eq, eval, command = helpers.eq, helpers.eval, helpers.command describe('Test for delete()', function() before_each(clear) + after_each(function() + os.remove('Xfile') + end) it('file delete', function() command('split Xfile') @@ -52,6 +55,9 @@ describe('Test for delete()', function() silent !ln -s Xfile Xlink endif ]]) + if eval('v:shell_error') ~= 0 then + pending('Cannot create symlink', function()end) + end -- Delete the link, not the file eq(0, eval("delete('Xlink')")) eq(-1, eval("delete('Xlink')")) diff --git a/test/functional/provider/nodejs_spec.lua b/test/functional/provider/nodejs_spec.lua index f69c3e7c78..07a00f8a8c 100644 --- a/test/functional/provider/nodejs_spec.lua +++ b/test/functional/provider/nodejs_spec.lua @@ -16,7 +16,6 @@ end before_each(function() clear() - command([[let $NODE_PATH = get(split(system('npm root -g'), "\n"), 0, '')]]) end) describe('nodejs host', function() @@ -28,21 +27,18 @@ describe('nodejs host', function() it('works', function() local fname = 'Xtest-nodejs-hello.js' write_file(fname, [[ - const socket = process.env.NVIM_LISTEN_ADDRESS; const neovim = require('neovim'); - const nvim = neovim.attach({socket: socket}); + const nvim = neovim.attach({socket: process.env.NVIM_LISTEN_ADDRESS}); nvim.command('let g:job_out = "hello"'); - nvim.command('call jobstop(g:job_id)'); ]]) command('let g:job_id = jobstart(["node", "'..fname..'"])') - retry(nil, 2000, function() eq('hello', eval('g:job_out')) end) + retry(nil, 3000, function() eq('hello', eval('g:job_out')) end) end) it('plugin works', function() local fname = 'Xtest-nodejs-hello-plugin.js' write_file(fname, [[ - const socket = process.env.NVIM_LISTEN_ADDRESS; const neovim = require('neovim'); - const nvim = neovim.attach({socket: socket}); + const nvim = neovim.attach({socket: process.env.NVIM_LISTEN_ADDRESS}); class TestPlugin { hello() { @@ -54,6 +50,6 @@ describe('nodejs host', function() plugin.instance.hello(); ]]) command('let g:job_id = jobstart(["node", "'..fname..'"])') - retry(nil, 2000, function() eq('hello-plugin', eval('g:job_out')) end) + retry(nil, 3000, function() eq('hello-plugin', eval('g:job_out')) end) end) end) diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index 4f22f7385d..f98add41a0 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -47,6 +47,16 @@ describe(':terminal', function() ]]) end) + it("reads output buffer on terminal reporting #4151", function() + if helpers.pending_win32(pending) then return end + if iswin() then + feed_command([[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]]) + else + feed_command([[terminal printf '\e[6n'; sleep 0.5 ]]) + end + screen:expect('%^%[%[1;1R', nil, nil, nil, true) + end) + it("in normal-mode :split does not move cursor", function() if iswin() then feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]]) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 0ae5802a01..5603224975 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -253,6 +253,19 @@ describe('tui', function() {4:-- TERMINAL --} | ]]) end) + + it('shows up in nvim_list_uis', function() + feed_data(':echo map(nvim_list_uis(), {k,v -> sort(items(v))})\013') + screen:expect([=[ + {5: }| + [[['ext_cmdline', v:false], ['ext_popupmenu', v:fa| + lse], ['ext_tabline', v:false], ['ext_wildmenu', v| + :false], ['height', 6], ['rgb', v:false], ['width'| + , 50]]] | + {10:Press ENTER or type command to continue}{1: } | + {3:-- TERMINAL --} | + ]=]) + end) end) describe('tui with non-tty file descriptors', function() diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 41c290a462..5ce49822e5 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -22,6 +22,8 @@ describe('external cmdline', function() [1] = {bold = true, foreground = Screen.colors.Blue1}, [2] = {reverse = true}, [3] = {bold = true, reverse = true}, + [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [5] = {bold = true, foreground = Screen.colors.SeaGreen4}, }) screen:set_on_event_handler(function(name, data) if name == "cmdline_show" then @@ -157,24 +159,87 @@ describe('external cmdline', function() end) end) - it("redraws statusline on entering", function() - command('set laststatus=2') - command('set statusline=%{mode()}') - feed(':') - screen:expect([[ - | - {1:~ }| - {1:~ }| - {3:c^ }| - | - ]], nil, nil, function() - eq({{ - content = { { {}, "" } }, - firstc = ":", - indent = 0, - pos = 0, - prompt = "" - }}, cmdline) + describe("redraws statusline on entering", function() + before_each(function() + command('set laststatus=2') + command('set statusline=%{mode()}') + end) + + it('from normal mode', function() + feed(':') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {3:c^ }| + | + ]], nil, nil, function() + eq({{ + content = { { {}, "" } }, + firstc = ":", + indent = 0, + pos = 0, + prompt = "" + }}, cmdline) + end) + end) + + it('but not with scrolled messages', function() + screen:try_resize(50,10) + feed(':echoerr doesnotexist<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {5:Press ENTER or type command to continue}^ | + ]]) + feed(':echoerr doesnotexist<cr>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {5:Press ENTER or type command to continue}^ | + ]]) + + feed(':echoerr doesnotexist<cr>') + screen:expect([[ + | + {1:~ }| + {3: }| + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {4:E121: Undefined variable: doesnotexist} | + {4:E15: Invalid expression: doesnotexist} | + {5:Press ENTER or type command to continue}^ | + ]]) + + feed('<cr>') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {3:n }| + | + ]]) end) end) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index c6ddc78618..b60d520ca0 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -31,6 +31,29 @@ describe("'wildmenu'", function() ]]) end) + it(':sign <tab> <space> hides wildmenu #8453', function() + command('set wildmode=full') + -- only a regression if status-line open + command('set laststatus=2') + command('set wildmenu') + feed(':sign <tab>') + screen:expect([[ + | + ~ | + ~ | + define jump list > | + :sign define^ | + ]]) + feed('<space>') + screen:expect([[ + | + ~ | + ~ | + [No Name] | + :sign define ^ | + ]]) + end) + it('does not crash after cycling back to original text', function() command('set wildmode=full') feed(':j<Tab><Tab><Tab>') diff --git a/test/helpers.lua b/test/helpers.lua index 0d3fe1316b..a774a67df3 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -259,7 +259,7 @@ local function check_cores(app, force) else initial_path = '.' re = '/core[^/]*$' - exc_re = { '^/%.deps$', local_tmpdir } + exc_re = { '^/%.deps$', local_tmpdir, '^/%node_modules$' } db_cmd = gdb_db_cmd random_skip = true end |