diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/core/channels_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/helpers.lua | 21 | ||||
-rw-r--r-- | test/functional/legacy/file_perm_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/plugin/shada_spec.lua | 509 | ||||
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 29 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 329 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 34 | ||||
-rw-r--r-- | test/functional/ui/mode_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 27 |
12 files changed, 640 insertions, 327 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index ddd044a10f..a20667de40 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -180,7 +180,7 @@ describe('server -> client', function() end) describe('recursive (child) nvim client', function() - if helpers.isCI('travis') and helpers.os_name() == 'osx' then + if helpers.isCI('travis') and helpers.is_os('mac') then -- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86. pending("[Hangs on Travis macOS. #5002]", function() end) return @@ -339,7 +339,7 @@ describe('server -> client', function() describe('connecting to its own pipe address', function() it('does not deadlock', function() - if not helpers.isCI('travis') and helpers.os_name() == 'osx' then + if not helpers.isCI('travis') and helpers.is_os('mac') then -- It does, in fact, deadlock on QuickBuild. #6851 pending("deadlocks on QuickBuild", function() end) return diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 07c0c5c8f3..b80b1c87af 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -11,7 +11,7 @@ local iswin = helpers.iswin local meth_pcall = helpers.meth_pcall local meths = helpers.meths local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed -local os_name = helpers.os_name +local is_os = helpers.is_os local parse_context = helpers.parse_context local request = helpers.request local source = helpers.source @@ -83,7 +83,7 @@ describe('API', function() nvim('command', 'w') local f = io.open(fname) ok(f ~= nil) - if os_name() == 'windows' then + if is_os('win') then eq('testing\r\napi\r\n', f:read('*a')) else eq('testing\napi\n', f:read('*a')) diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua index 852d9808f5..1ef34c7318 100644 --- a/test/functional/core/channels_spec.lua +++ b/test/functional/core/channels_spec.lua @@ -7,7 +7,7 @@ local sleep = helpers.sleep local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv local set_session = helpers.set_session local nvim_prog = helpers.nvim_prog -local os_name = helpers.os_name +local is_os = helpers.is_os local retry = helpers.retry local expect_twostreams = helpers.expect_twostreams @@ -140,7 +140,7 @@ describe('channels', function() command("call chansend(id, 'incomplet\004')") local is_bsd = not not string.find(uname(), 'bsd') - local bsdlike = is_bsd or (os_name() == "osx") + local bsdlike = is_bsd or is_os('mac') local extra = bsdlike and "^D\008\008" or "" expect_twoline(id, "stdout", "incomplet"..extra, "[1, ['incomplet'], 'stdin']", true) diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 88951e5b51..94b34ef05b 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -206,7 +206,7 @@ describe('jobs', function() it("will not buffer data if it doesn't end in newlines", function() if helpers.isCI('travis') and os.getenv('CC') == 'gcc-4.9' - and helpers.os_name() == "osx" then + and helpers.is_os('mac') then -- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86. pending("[Hangs on Travis macOS. #5002]", function() end) return diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index c34849b439..cf9f5f9858 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -15,6 +15,7 @@ local check_logs = global_helpers.check_logs local dedent = global_helpers.dedent local eq = global_helpers.eq local filter = global_helpers.filter +local is_os = global_helpers.is_os local map = global_helpers.map local ok = global_helpers.ok local sleep = global_helpers.sleep @@ -271,22 +272,6 @@ function module.eval(expr) return module.request('nvim_eval', expr) end -module.os_name = (function() - local name = nil - return (function() - if not name then - if module.eval('has("win32")') == 1 then - name = 'windows' - elseif module.eval('has("macunix")') == 1 then - name = 'osx' - else - name = 'unix' - end - end - return name - end) -end)() - -- Executes a VimL function. -- Fails on VimL error, but does not update v:errmsg. function module.call(name, ...) @@ -609,7 +594,7 @@ local function do_rmdir(path) -- Try Nvim delete(): it handles `readonly` attribute on Windows, -- and avoids Lua cross-version/platform incompatibilities. if -1 == module.call('delete', abspath) then - local hint = (module.os_name() == 'windows' + local hint = (is_os('win') and ' (hint: try :%bwipeout! before rmdir())' or '') error('delete() failed'..hint..': '..abspath) end @@ -626,7 +611,7 @@ end function module.rmdir(path) local ret, _ = pcall(do_rmdir, path) - if not ret and module.os_name() == "windows" then + if not ret and is_os('win') then -- Maybe "Permission denied"; try again after changing the nvim -- process to the top-level directory. module.command([[exe 'cd '.fnameescape(']]..start_dir.."')") diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua index d61fdc9b83..8fdee95e91 100644 --- a/test/functional/legacy/file_perm_spec.lua +++ b/test/functional/legacy/file_perm_spec.lua @@ -21,7 +21,7 @@ describe('Test getting and setting file permissions', function() eq(9, call('len', call('getfperm', tempfile))) eq(1, call('setfperm', tempfile, 'rwx------')) - if helpers.os_name() == 'windows' then + if helpers.is_os('win') then eq('rw-rw-rw-', call('getfperm', tempfile)) else eq('rwx------', call('getfperm', tempfile)) diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua index d96b479a62..5663f248bf 100644 --- a/test/functional/plugin/shada_spec.lua +++ b/test/functional/plugin/shada_spec.lua @@ -12,9 +12,7 @@ local shada_helpers = require('test.functional.shada.helpers') local get_shada_rw = shada_helpers.get_shada_rw local function reset(shada_file) - clear{ args={'-u', 'NORC', - '-i', shada_file or 'NONE', - }} + clear{ args={'-u', 'NORC', '-i', shada_file or 'NONE', }} end local mpack_eq = function(expected, mpack_result) @@ -2143,7 +2141,7 @@ describe('plugin/shada.vim', function() local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0) local eol = helpers.iswin() and '\r\n' or '\n' before_each(function() - reset() + -- Note: reset() is called explicitly in each test. os.remove(fname) os.remove(fname .. '.tst') os.remove(fname_tmp) @@ -2159,272 +2157,263 @@ describe('plugin/shada.vim', function() mpack_eq(expected, mpack_result) end - describe('event BufReadCmd', function() - it('works', function() - wshada('\004\000\009\147\000\196\002ab\196\001a') - wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') - nvim_command('edit ' .. fname) - eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "a"', - }, nvim_eval('getline(1, "$")')) - eq(false, curbuf('get_option', 'modified')) - eq('shada', curbuf('get_option', 'filetype')) - nvim_command('edit ' .. fname_tmp) - eq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "b"', - }, nvim_eval('getline(1, "$")')) - eq(false, curbuf('get_option', 'modified')) - eq('shada', curbuf('get_option', 'filetype')) - eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname)) - neq({ - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "a"', - }, nvim_eval('getline(1, "$")')) - neq(true, curbuf('get_option', 'modified')) - end) + it('event BufReadCmd', function() + reset() + wshada('\004\000\009\147\000\196\002ab\196\001a') + wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') + nvim_command('edit ' .. fname) + eq({ + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "a"', + }, nvim_eval('getline(1, "$")')) + eq(false, curbuf('get_option', 'modified')) + eq('shada', curbuf('get_option', 'filetype')) + nvim_command('edit ' .. fname_tmp) + eq({ + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "b"', + }, nvim_eval('getline(1, "$")')) + eq(false, curbuf('get_option', 'modified')) + eq('shada', curbuf('get_option', 'filetype')) + eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname)) + neq({ + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "a"', + }, nvim_eval('getline(1, "$")')) + neq(true, curbuf('get_option', 'modified')) end) - describe('event FileReadCmd', function() - it('works', function() - wshada('\004\000\009\147\000\196\002ab\196\001a') - wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') - nvim_command('$read ' .. fname) - eq({ - '', - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "a"', - }, nvim_eval('getline(1, "$")')) - eq(true, curbuf('get_option', 'modified')) - neq('shada', curbuf('get_option', 'filetype')) - nvim_command('1,$read ' .. fname_tmp) - eq({ - '', - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "a"', - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "b"', - }, nvim_eval('getline(1, "$")')) - eq(true, curbuf('get_option', 'modified')) - neq('shada', curbuf('get_option', 'filetype')) - curbuf('set_option', 'modified', false) - eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname)) - eq({ - '', - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "a"', - 'History entry with timestamp ' .. epoch .. ':', - ' @ Description_ Value', - ' - history type CMD', - ' - contents "ab"', - ' - "b"', - }, nvim_eval('getline(1, "$")')) - neq(true, curbuf('get_option', 'modified')) - end) + it('event FileReadCmd', function() + reset() + wshada('\004\000\009\147\000\196\002ab\196\001a') + wshada_tmp('\004\000\009\147\000\196\002ab\196\001b') + nvim_command('$read ' .. fname) + eq({ + '', + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "a"', + }, nvim_eval('getline(1, "$")')) + eq(true, curbuf('get_option', 'modified')) + neq('shada', curbuf('get_option', 'filetype')) + nvim_command('1,$read ' .. fname_tmp) + eq({ + '', + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "a"', + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "b"', + }, nvim_eval('getline(1, "$")')) + eq(true, curbuf('get_option', 'modified')) + neq('shada', curbuf('get_option', 'filetype')) + curbuf('set_option', 'modified', false) + eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname)) + eq({ + '', + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "a"', + 'History entry with timestamp ' .. epoch .. ':', + ' @ Description_ Value', + ' - history type CMD', + ' - contents "ab"', + ' - "b"', + }, nvim_eval('getline(1, "$")')) + neq(true, curbuf('get_option', 'modified')) end) - describe('event BufWriteCmd', function() - it('works', function() - nvim('set_var', 'shada#add_own_header', 0) - curbuf('set_lines', 0, 1, true, { - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - }) - nvim_command('w ' .. fname .. '.tst') - nvim_command('w ' .. fname) - nvim_command('w ' .. fname_tmp) - eq('++opt not supported', exc_exec('w! ++enc=latin1 ' .. fname)) - eq(table.concat({ - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - }, eol) .. eol, read_file(fname .. '.tst')) - shada_eq({{ - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }}, fname) - shada_eq({{ - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }}, fname_tmp) - end) + it('event BufWriteCmd', function() + reset() + nvim('set_var', 'shada#add_own_header', 0) + curbuf('set_lines', 0, 1, true, { + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + }) + nvim_command('w ' .. fname .. '.tst') + nvim_command('w ' .. fname) + nvim_command('w ' .. fname_tmp) + eq('++opt not supported', exc_exec('w! ++enc=latin1 ' .. fname)) + eq(table.concat({ + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + }, eol) .. eol, read_file(fname .. '.tst')) + shada_eq({{ + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }}, fname) + shada_eq({{ + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }}, fname_tmp) end) - describe('event FileWriteCmd', function() - it('works', function() - nvim('set_var', 'shada#add_own_header', 0) - curbuf('set_lines', 0, 1, true, { - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - }) - nvim_command('1,3w ' .. fname .. '.tst') - nvim_command('1,3w ' .. fname) - nvim_command('1,3w ' .. fname_tmp) - eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 ' .. fname)) - eq(table.concat({ - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - }, eol) .. eol, read_file(fname .. '.tst')) - shada_eq({{ - timestamp=0, - type=8, - value={n=('A'):byte()}, - }}, fname) - shada_eq({{ - timestamp=0, - type=8, - value={n=('A'):byte()}, - }}, fname_tmp) - end) + it('event FileWriteCmd', function() + reset() + nvim('set_var', 'shada#add_own_header', 0) + curbuf('set_lines', 0, 1, true, { + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + }) + nvim_command('1,3w ' .. fname .. '.tst') + nvim_command('1,3w ' .. fname) + nvim_command('1,3w ' .. fname_tmp) + eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 ' .. fname)) + eq(table.concat({ + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + }, eol) .. eol, read_file(fname .. '.tst')) + shada_eq({{ + timestamp=0, + type=8, + value={n=('A'):byte()}, + }}, fname) + shada_eq({{ + timestamp=0, + type=8, + value={n=('A'):byte()}, + }}, fname_tmp) end) - describe('event FileAppendCmd', function() - it('works', function() - nvim('set_var', 'shada#add_own_header', 0) - curbuf('set_lines', 0, 1, true, { - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - }) - funcs.writefile({''}, fname .. '.tst', 'b') - funcs.writefile({''}, fname, 'b') - funcs.writefile({''}, fname_tmp, 'b') - nvim_command('1,3w >> ' .. fname .. '.tst') - nvim_command('1,3w >> ' .. fname) - nvim_command('1,3w >> ' .. fname_tmp) - nvim_command('w >> ' .. fname .. '.tst') - nvim_command('w >> ' .. fname) - nvim_command('w >> ' .. fname_tmp) - eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 >> ' .. fname)) - eq(table.concat({ - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - 'Jump with timestamp ' .. epoch .. ':', - ' % Key________ Description Value', - ' + n name \'A\'', - ' + f file name ["foo"]', - ' + l line number 2', - ' + c column -200', - }, eol) .. eol, read_file(fname .. '.tst')) - shada_eq({{ - timestamp=0, - type=8, - value={n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }}, fname) - shada_eq({{ - timestamp=0, - type=8, - value={n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }, { - timestamp=0, - type=8, - value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, - }}, fname_tmp) - end) + it('event FileAppendCmd', function() + reset() + nvim('set_var', 'shada#add_own_header', 0) + curbuf('set_lines', 0, 1, true, { + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + }) + funcs.writefile({''}, fname .. '.tst', 'b') + funcs.writefile({''}, fname, 'b') + funcs.writefile({''}, fname_tmp, 'b') + nvim_command('1,3w >> ' .. fname .. '.tst') + nvim_command('1,3w >> ' .. fname) + nvim_command('1,3w >> ' .. fname_tmp) + nvim_command('w >> ' .. fname .. '.tst') + nvim_command('w >> ' .. fname) + nvim_command('w >> ' .. fname_tmp) + eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 >> ' .. fname)) + eq(table.concat({ + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + 'Jump with timestamp ' .. epoch .. ':', + ' % Key________ Description Value', + ' + n name \'A\'', + ' + f file name ["foo"]', + ' + l line number 2', + ' + c column -200', + }, eol) .. eol, read_file(fname .. '.tst')) + shada_eq({{ + timestamp=0, + type=8, + value={n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }}, fname) + shada_eq({{ + timestamp=0, + type=8, + value={n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }, { + timestamp=0, + type=8, + value={c=-200, f={'foo'}, l=2, n=('A'):byte()}, + }}, fname_tmp) end) - describe('event SourceCmd', function() - before_each(function() - reset(fname) - end) - it('works', function() - wshada('\004\000\006\146\000\196\002ab') - wshada_tmp('\004\001\006\146\000\196\002bc') - eq(0, exc_exec('source ' .. fname)) - eq(0, exc_exec('source ' .. fname_tmp)) - eq('bc', funcs.histget(':', -1)) - eq('ab', funcs.histget(':', -2)) - end) + it('event SourceCmd', function() + reset(fname) + wshada('\004\000\006\146\000\196\002ab') + wshada_tmp('\004\001\006\146\000\196\002bc') + eq(0, exc_exec('source ' .. fname)) + eq(0, exc_exec('source ' .. fname_tmp)) + eq('bc', funcs.histget(':', -1)) + eq('ab', funcs.histget(':', -2)) end) end) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 065cb98e69..f4441a5396 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -403,12 +403,8 @@ describe("'scrollback' option", function() end curbufmeths.set_option('scrollback', 0) - if iswin() then - feed_data('for /L %I in (1,1,30) do @(echo line%I)\r') - else - feed_data('awk "BEGIN{for(n=1;n<=30;n++) print \\\"line\\\" n}"\n') - end - screen:expect{any='line30 '} + feed_data(nvim_dir..'/shell-test REP 31 line'..(iswin() and '\r' or '\n')) + screen:expect{any='30: line '} retry(nil, nil, function() expect_lines(7) end) screen:detach() @@ -428,13 +424,8 @@ describe("'scrollback' option", function() -- Wait for prompt. screen:expect{any='%$'} - if iswin() then - feed_data('for /L %I in (1,1,30) do @(echo line%I)\r') - else - feed_data('awk "BEGIN{for(n=1;n<=30;n++) print \\\"line\\\" n}"\n') - end - - screen:expect{any='line30 '} + feed_data(nvim_dir.."/shell-test REP 31 line"..(iswin() and '\r' or '\n')) + screen:expect{any='30: line '} retry(nil, nil, function() expect_lines(33, 2) end) curbufmeths.set_option('scrollback', 10) @@ -445,18 +436,14 @@ 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') - if iswin() then - feed_data('for /L %I in (1,1,40) do @(echo line%I)\r') - else - feed_data('awk "BEGIN{for(n=1;n<=40;n++) print \\\"line\\\" n}"\n') - end - screen:expect{any='line40 '} + feed_data(nvim_dir.."/shell-test REP 41 line"..(iswin() and '\r' or '\n')) + screen:expect{any='40: line '} retry(nil, nil, function() expect_lines(58) end) -- Verify off-screen state - eq((iswin() and 'line36' or 'line35'), eval("getline(line('w0') - 1)")) - eq((iswin() and 'line27' or 'line26'), eval("getline(line('w0') - 10)")) + eq((iswin() and '36: line' or '35: line'), eval("getline(line('w0') - 1)")) + eq((iswin() and '27: line' or '26: line'), eval("getline(line('w0') - 10)")) screen:detach() end) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 958c56334a..c8cf9d830e 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -963,6 +963,335 @@ describe('floating windows', function() end end) + it('can be placed relative text in a window', function() + screen:try_resize(30,5) + local firstwin = meths.get_current_win().id + meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + ^just some | + example text that is wider tha| + n the window | + | + ## grid 3 + | + ]]} + else + screen:expect{grid=[[ + ^just some | + example text that is wider tha| + n the window | + | + | + ]]} + end + + local buf = meths.create_buf(false,false) + meths.buf_set_lines(buf, 0, -1, true, {'some info!'}) + + local win = meths.open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + ^just some | + example text that is wider tha| + n the window | + | + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 3, 2, true } + }} + else + screen:expect{grid=[[ + ^just some | + example text that is wider tha| + n the window | + {1:some info! } | + | + ]]} + end + eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', + external=false, col=0, row=1, win=firstwin, focusable=true}, meths.win_get_config(win)) + + feed('<c-e>') + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [2:------------------------------]| + [3:------------------------------]| + ## grid 2 + ^example text that is wider tha| + n the window | + | + | + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 2, 2, true } + }} + else + screen:expect{grid=[[ + ^example text that is wider tha| + n the window | + {1:some info! } | + | + | + ]]} + end + + + screen:try_resize(45,5) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + ^example text that is wider than the window | + | + | + more text | + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 1, 32, true } + }} + else + -- note: appears misalinged due to cursor + screen:expect{grid=[[ + ^example text that is wider than the window | + {1:some info! } | + | + more text | + | + ]]} + end + + screen:try_resize(25,10) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [3:-------------------------]| + ## grid 2 + ^example text that is wide| + r than the window | + | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 2, 7, true } + }} + else + screen:expect{grid=[[ + ^example text that is wide| + r than the window | + {1:some info! } | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end + + meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [3:-------------------------]| + ## grid 2 + ^example text that is wide| + r than the window | + | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "SW", 2, 1, 7, true } + }} + else + screen:expect{grid=[[ + ^example{1:some info! }s wide| + r than the window | + | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end + + meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [3:-------------------------]| + ## grid 2 + ^example text that is wide| + r than the window | + | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 2, 5, true } + }} + else + screen:expect{grid=[[ + ^example text that is wide| + r than the window | + {1:some info! } | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end + + meths.win_set_config(win, {relative='win', bufpos={1,32}, row=2}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [2:-------------------------]| + [3:-------------------------]| + ## grid 2 + ^example text that is wide| + r than the window | + | + | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 5 + {1:some info! }| + ]], float_pos={ + [5] = { { + id = 1002 + }, "NW", 2, 3, 7, true } + }} + else + screen:expect{grid=[[ + ^example text that is wide| + r than the window | + | + {1:some info! } | + more text | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end + end) + it('validates cursor even when window is not entered', function() screen:try_resize(30,5) command("set nowrap") diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index ed65c4526f..a6b9ef9387 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1052,3 +1052,37 @@ describe('ui/msg_puts_printf', function() os.execute('cmake -E remove_directory '..test_build_dir..'/share') end) end) + +describe('pager', function() + local screen + + before_each(function() + clear() + screen = Screen.new(25, 5) + screen:attach() + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue1}, + [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, + }) + end) + + it('can be quit', function() + command("set more") + feed(':echon join(map(range(0, &lines*2), "v:val"), "\\n")<cr>') + screen:expect{grid=[[ + 0 | + 1 | + 2 | + 3 | + {4:-- More --}^ | + ]]} + feed('q') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) +end) diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua index a09df075aa..200f6eecdb 100644 --- a/test/functional/ui/mode_spec.lua +++ b/test/functional/ui/mode_spec.lua @@ -62,7 +62,7 @@ describe('ui mode_change event', function() ]], mode="normal"} command("set showmatch") - command("set matchtime=1") -- tenths of seconds + command("set matchtime=2") -- tenths of seconds feed('a(stuff') screen:expect{grid=[[ word(stuff^ | diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 2215c0c7d9..f3fa711fb1 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local shallowcopy = helpers.shallowcopy local clear, feed, command = helpers.clear, helpers.feed, helpers.command local iswin = helpers.iswin local funcs = helpers.funcs @@ -17,14 +16,6 @@ describe("'wildmenu'", function() screen:attach() end) - -- expect the screen stayed unchanged some time after first seen success - local function expect_stay_unchanged(args) - screen:expect(args) - args = shallowcopy(args) - args.unchanged = true - screen:expect(args) - end - it(':sign <tab> shows wildmenu completions', function() command('set wildmenu wildmode=full') feed(':sign <tab>') @@ -89,24 +80,20 @@ describe("'wildmenu'", function() feed([[:sign <Tab>]]) -- Invoke wildmenu. -- NB: in earlier versions terminal output was redrawn during cmdline mode. -- For now just assert that the screen remains unchanged. - expect_stay_unchanged{grid=[[ - | - | - | - define jump list > | - :sign define^ | - ]]} + screen:expect{any='define jump list > |\n:sign define^ |'} + screen:expect_unchanged() -- cmdline CTRL-D display should also be preserved. feed([[<C-U>]]) feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D. - expect_stay_unchanged{grid=[[ + screen:expect{grid=[[ :sign | define place | jump undefine | list unplace | :sign ^ | ]]} + screen:expect_unchanged() -- Exiting cmdline should show the buffer. feed([[<C-\><C-N>]]) @@ -118,13 +105,14 @@ describe("'wildmenu'", function() command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]]) feed([[<C-\><C-N>]]) feed([[:sign <Tab>]]) -- Invoke wildmenu. - expect_stay_unchanged{grid=[[ + screen:expect{grid=[[ | ~ | ~ | define jump list > | :sign define^ | ]]} + screen:expect_unchanged() end) it('with laststatus=0, :vsplit, :term #2255', function() @@ -152,7 +140,8 @@ describe("'wildmenu'", function() feed([[:<Tab>]]) -- Invoke wildmenu. -- Check only the last 2 lines, because the shell output is -- system-dependent. - expect_stay_unchanged{any='! # & < = > @ > |\n:!^'} + screen:expect{any='! # & < = > @ > |\n:!^'} + screen:expect_unchanged() end) it('wildmode=list,full and display+=msgsep interaction #10092', function() |