From a5a5c83608e6d4455ac40e8786fd16eaf817c608 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 23 May 2017 00:16:23 +0300 Subject: api/vim: Fix nvim_list_runtimepaths It used to 1. Always omit last component in runtimepath. 2. Always omit trailing empty item and leave uninitialized memory in place of it. --- test/functional/api/vim_spec.lua | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 161682b973..c531d4af46 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -327,11 +327,11 @@ describe('api', function() {'nvim_get_mode', {}}, {'nvim_eval', {'1'}}, } - eq({{{mode='n', blocking=false}, - 13, - {mode='n', blocking=false}, -- TODO: should be blocked=true - 1}, - NIL}, meths.call_atomic(req)) + eq({ { {mode='n', blocking=false}, + 13, + {mode='n', blocking=false}, -- TODO: should be blocked=true + 1 }, + NIL}, meths.call_atomic(req)) eq({mode='r', blocking=true}, nvim("get_mode")) end) -- TODO: bug #6166 @@ -588,6 +588,36 @@ describe('api', function() end) end) + describe('list_runtime_paths', function() + it('returns nothing with empty &runtimepath', function() + meths.set_option('runtimepath', '') + eq({}, meths.list_runtime_paths()) + end) + it('returns single runtimepath', function() + meths.set_option('runtimepath', 'a') + eq({'a'}, meths.list_runtime_paths()) + end) + it('returns two runtimepaths', function() + meths.set_option('runtimepath', 'a,b') + eq({'a', 'b'}, meths.list_runtime_paths()) + end) + it('returns empty strings when appropriate', function() + meths.set_option('runtimepath', 'a,,b') + eq({'a', '', 'b'}, meths.list_runtime_paths()) + meths.set_option('runtimepath', ',a,b') + eq({'', 'a', 'b'}, meths.list_runtime_paths()) + meths.set_option('runtimepath', 'a,b,') + eq({'a', 'b', ''}, meths.list_runtime_paths()) + end) + it('truncates too long paths', function() + local long_path = ('/a'):rep(8192) + meths.set_option('runtimepath', long_path) + local paths_list = meths.list_runtime_paths() + neq({long_path}, paths_list) + eq({long_path:sub(1, #(paths_list[1]))}, paths_list) + end) + end) + it('can throw exceptions', function() local status, err = pcall(nvim, 'get_option', 'invalid-option') eq(false, status) -- cgit From ca4633bfe4d0f58bd5fb7343d282fafb71f3a3ee Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 00:30:00 +0200 Subject: ci/quickbuild: XXX: disable server_requests test (#6851) Temporarily disable this test which hangs quickbuild. From #6905: The hang occurs when calling nvim_set_current_line. References #6594 5a151555c8dce70bbf235e7f6d5bd1ced5e7c46c --- test/functional/api/server_requests_spec.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index cf15062325..6a32f979ea 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -282,8 +282,13 @@ describe('server -> client', function() end) end) - describe('when connecting to its own pipe adress', function() - it('it does not deadlock', function() + describe('connecting to its own pipe address', function() + it('does not deadlock', function() + if not os.getenv("TRAVIS") and helpers.os_name() == "osx" then + -- It does, in fact, deadlock on QuickBuild. #6851 + pending("deadlocks on QuickBuild", function() end) + return + end local address = funcs.serverlist()[1] local first = string.sub(address,1,1) ok(first == '/' or first == '\\') -- cgit From 4b8bdd953e2b7928af80e8b97118d52f99f0d95a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:21:21 +0300 Subject: functests: Remove local_copy function --- test/functional/api/keymap_spec.lua | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 833e0d2f3c..7d6445f49c 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -1,5 +1,6 @@ - local helpers = require('test.functional.helpers')(after_each) +local global_helpers = require('test.helpers') + local clear = helpers.clear local command = helpers.command local curbufmeths = helpers.curbufmeths @@ -8,13 +9,7 @@ local funcs = helpers.funcs local meths = helpers.meths local source = helpers.source -local function local_copy(t) - local copy = {} - for k,v in pairs(t) do - copy[k] = v - end - return copy -end +local shallowcopy = global_helpers.shallowcopy describe('get_keymap', function() before_each(clear) @@ -50,7 +45,7 @@ describe('get_keymap', function() -- Add another mapping command('nnoremap foo_longer bar_longer') - local foolong_bar_map_table = local_copy(foo_bar_map_table) + local foolong_bar_map_table = shallowcopy(foo_bar_map_table) foolong_bar_map_table['lhs'] = 'foo_longer' foolong_bar_map_table['rhs'] = 'bar_longer' @@ -72,7 +67,7 @@ describe('get_keymap', function() command('inoremap foo bar') -- The table will be the same except for the mode - local insert_table = local_copy(foo_bar_map_table) + local insert_table = shallowcopy(foo_bar_map_table) insert_table['mode'] = 'i' eq({insert_table}, meths.get_keymap('i')) @@ -81,11 +76,11 @@ describe('get_keymap', function() it('considers scope', function() -- change the map slightly command('nnoremap foo_longer bar_longer') - local foolong_bar_map_table = local_copy(foo_bar_map_table) + local foolong_bar_map_table = shallowcopy(foo_bar_map_table) foolong_bar_map_table['lhs'] = 'foo_longer' foolong_bar_map_table['rhs'] = 'bar_longer' - local buffer_table = local_copy(foo_bar_map_table) + local buffer_table = shallowcopy(foo_bar_map_table) buffer_table['buffer'] = 1 command('nnoremap foo bar') @@ -98,7 +93,7 @@ describe('get_keymap', function() it('considers scope for overlapping maps', function() command('nnoremap foo bar') - local buffer_table = local_copy(foo_bar_map_table) + local buffer_table = shallowcopy(foo_bar_map_table) buffer_table['buffer'] = 1 command('nnoremap foo bar') @@ -121,7 +116,7 @@ describe('get_keymap', function() command('nnoremap foo bar') -- Final buffer will have buffer mappings - local buffer_table = local_copy(foo_bar_map_table) + local buffer_table = shallowcopy(foo_bar_map_table) buffer_table['buffer'] = final_buffer eq({buffer_table}, meths.buf_get_keymap(final_buffer, 'n')) eq({buffer_table}, meths.buf_get_keymap(0, 'n')) -- cgit From a1fee487ba5199ff672a87c5830732c224fa59eb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:28:44 +0300 Subject: functests: Add tests for new behaviour Apparently it is not working yet. --- test/functional/api/keymap_spec.lua | 72 +++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 10 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 7d6445f49c..b7858888c4 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -17,16 +17,16 @@ describe('get_keymap', function() -- Basic mapping and table to be used to describe results local foo_bar_string = 'nnoremap foo bar' local foo_bar_map_table = { - lhs='foo', - silent=0, - rhs='bar', - expr=0, - sid=0, - buffer=0, - nowait=0, - mode='n', - noremap=1, - } + lhs='foo', + silent=0, + rhs='bar', + expr=0, + sid=0, + buffer=0, + nowait=0, + mode='n', + noremap=1, + } it('returns empty list when no map', function() eq({}, meths.get_keymap('n')) @@ -238,4 +238,56 @@ describe('get_keymap', function() eq('', meths.get_keymap('n')[1]['lhs']) eq(':let g:maparg_test_var = 1', meths.get_keymap('n')[1]['rhs']) end) + + it('works correctly despite various &cpo settings', function() + local cpo_table = { + silent=0, + expr=0, + sid=0, + buffer=0, + nowait=0, + noremap=1, + } + local function cpomap(lhs, rhs, mode) + local ret = shallowcopy(cpo_table) + ret.lhs = lhs + ret.rhs = rhs + ret.mode = mode + return ret + end + + command('set cpo-=< cpo+=B') + command('nnoremap \\ \\') + command('nnoremap \\ \\') + + command('set cpo+=B<') + command('xnoremap \\ \\') + command('xnoremap \\ \\') + + command('set cpo-=B<') + command('snoremap \\ \\') + command('snoremap \\ \\') + + command('set cpo-=B cpo+=<') + command('onoremap \\ \\') + command('onoremap \\ \\') + + for _, cmd in ipairs({ + 'set cpo-=B cpo+=<', + 'set cpo-=B<', + 'set cpo+=B<', + 'set cpo-=< cpo+=B', + }) do + command(cmd) + eq({cpomap('\\', '\\', 'n'), cpomap('\\', '\\', 'n')}, + meths.get_keymap('n')) + -- FIXME + -- eq({cpomap('\\', '\\', 'x'), cpomap('\\C-A>', '\\C-B>', 'x')}, + -- meths.get_keymap('x')) + -- eq({cpomap('C-C>', 'C-D>', 's'), cpomap('C-A>', 'C-B>', 's')}, + -- meths.get_keymap('x')) + -- eq({cpomap('C-C>', 'C-D>', 'o'), cpomap('C-A>', 'C-B>', 'o')}, + -- meths.get_keymap('x')) + end + end) end) -- cgit From 24f0056ca5cb392f1e1bf38d648a6037acf1f1ef Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:37:21 +0300 Subject: message: Add support for replacing `<` to str2special --- test/functional/api/keymap_spec.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index b7858888c4..fc3ab2d179 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -281,13 +281,12 @@ describe('get_keymap', function() command(cmd) eq({cpomap('\\', '\\', 'n'), cpomap('\\', '\\', 'n')}, meths.get_keymap('n')) - -- FIXME - -- eq({cpomap('\\', '\\', 'x'), cpomap('\\C-A>', '\\C-B>', 'x')}, - -- meths.get_keymap('x')) - -- eq({cpomap('C-C>', 'C-D>', 's'), cpomap('C-A>', 'C-B>', 's')}, - -- meths.get_keymap('x')) - -- eq({cpomap('C-C>', 'C-D>', 'o'), cpomap('C-A>', 'C-B>', 'o')}, - -- meths.get_keymap('x')) + eq({cpomap('\\', '\\', 'x'), cpomap('\\C-a>', '\\C-b>', 'x')}, + meths.get_keymap('x')) + eq({cpomap('C-c>', 'C-d>', 's'), cpomap('C-a>', 'C-b>', 's')}, + meths.get_keymap('s')) + eq({cpomap('C-c>', 'C-d>', 'o'), cpomap('C-a>', 'C-b>', 'o')}, + meths.get_keymap('o')) end end) end) -- cgit From 5fe5d712aae512c62083754bc364030848d67987 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:49:40 +0300 Subject: functests: Use more extensive testing Fixes #6937 --- test/functional/api/keymap_spec.lua | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index fc3ab2d179..f1c4d7bdf3 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -257,20 +257,20 @@ describe('get_keymap', function() end command('set cpo-=< cpo+=B') - command('nnoremap \\ \\') - command('nnoremap \\ \\') + command('nnoremap \\C-a>\\ \\C-b>\\') + command('nnoremap \\C-c>\\ \\C-d>\\') command('set cpo+=B<') - command('xnoremap \\ \\') - command('xnoremap \\ \\') + command('xnoremap \\C-a>\\ \\C-b>\\') + command('xnoremap \\C-c>\\ \\C-d>\\') command('set cpo-=B<') - command('snoremap \\ \\') - command('snoremap \\ \\') + command('snoremap \\C-a>\\ \\C-b>\\') + command('snoremap \\C-c>\\ \\C-d>\\') command('set cpo-=B cpo+=<') - command('onoremap \\ \\') - command('onoremap \\ \\') + command('onoremap \\C-a>\\ \\C-b>\\') + command('onoremap \\C-c>\\ \\C-d>\\') for _, cmd in ipairs({ 'set cpo-=B cpo+=<', @@ -279,13 +279,17 @@ describe('get_keymap', function() 'set cpo-=< cpo+=B', }) do command(cmd) - eq({cpomap('\\', '\\', 'n'), cpomap('\\', '\\', 'n')}, + eq({cpomap('\\C-c>\\', '\\C-d>\\', 'n'), + cpomap('\\C-a>\\', '\\C-b>\\', 'n')}, meths.get_keymap('n')) - eq({cpomap('\\', '\\', 'x'), cpomap('\\C-a>', '\\C-b>', 'x')}, + eq({cpomap('\\C-c>\\', '\\C-d>\\', 'x'), + cpomap('\\C-a>C-a>LT>C-a>\\', '\\C-b>C-b>LT>C-b>\\', 'x')}, meths.get_keymap('x')) - eq({cpomap('C-c>', 'C-d>', 's'), cpomap('C-a>', 'C-b>', 's')}, + eq({cpomap('C-c>C-c> ', 'C-d>C-d>', 's'), + cpomap('C-a>C-a> ', 'C-b>C-b>', 's')}, meths.get_keymap('s')) - eq({cpomap('C-c>', 'C-d>', 'o'), cpomap('C-a>', 'C-b>', 'o')}, + eq({cpomap('C-c>C-c> ', 'C-d>C-d>', 'o'), + cpomap('C-a>C-a>LT>C-a> ', 'C-b>C-b>LT>C-b>', 'o')}, meths.get_keymap('o')) end end) -- cgit From d5916a823a37a1c0fb1d3d2f52db7cad4107b924 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 20:08:00 +0300 Subject: functests: Test how spaces appear in get_keymap output --- test/functional/api/keymap_spec.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index f1c4d7bdf3..aa556b563d 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -293,4 +293,20 @@ describe('get_keymap', function() meths.get_keymap('o')) end end) + + it('always uses space for space and bar for bar', function() + local space_table = { + lhs='| |', + rhs='| |', + mode='n', + silent=0, + expr=0, + sid=0, + buffer=0, + nowait=0, + noremap=1, + } + command('nnoremap \\| \\| ') + eq({space_table}, meths.get_keymap('n')) + end) end) -- cgit From 0ea7e45bc1d1881f505da2b77e0b3e4eb56f12fe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 13:21:38 +0200 Subject: 'cpoptions': remove "<" flag; ignore Closes #6937 "nvim_get_keymap output is unreliable" --- test/functional/api/keymap_spec.lua | 18 ++++++++---------- test/functional/api/vim_spec.lua | 13 +++++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'test/functional/api') diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index aa556b563d..3a10f9c60f 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -256,40 +256,38 @@ describe('get_keymap', function() return ret end - command('set cpo-=< cpo+=B') + command('set cpo+=B') command('nnoremap \\C-a>\\ \\C-b>\\') command('nnoremap \\C-c>\\ \\C-d>\\') - command('set cpo+=B<') + command('set cpo+=B') command('xnoremap \\C-a>\\ \\C-b>\\') command('xnoremap \\C-c>\\ \\C-d>\\') - command('set cpo-=B<') + command('set cpo-=B') command('snoremap \\C-a>\\ \\C-b>\\') command('snoremap \\C-c>\\ \\C-d>\\') - command('set cpo-=B cpo+=<') + command('set cpo-=B') command('onoremap \\C-a>\\ \\C-b>\\') command('onoremap \\C-c>\\ \\C-d>\\') for _, cmd in ipairs({ - 'set cpo-=B cpo+=<', - 'set cpo-=B<', - 'set cpo+=B<', - 'set cpo-=< cpo+=B', + 'set cpo-=B', + 'set cpo+=B', }) do command(cmd) eq({cpomap('\\C-c>\\', '\\C-d>\\', 'n'), cpomap('\\C-a>\\', '\\C-b>\\', 'n')}, meths.get_keymap('n')) eq({cpomap('\\C-c>\\', '\\C-d>\\', 'x'), - cpomap('\\C-a>C-a>LT>C-a>\\', '\\C-b>C-b>LT>C-b>\\', 'x')}, + cpomap('\\C-a>\\', '\\C-b>\\', 'x')}, meths.get_keymap('x')) eq({cpomap('C-c>C-c> ', 'C-d>C-d>', 's'), cpomap('C-a>C-a> ', 'C-b>C-b>', 's')}, meths.get_keymap('s')) eq({cpomap('C-c>C-c> ', 'C-d>C-d>', 'o'), - cpomap('C-a>C-a>LT>C-a> ', 'C-b>C-b>LT>C-b>', 'o')}, + cpomap('C-a>C-a> ', 'C-b>C-b>', 'o')}, meths.get_keymap('o')) end end) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index c531d4af46..e59b5d712d 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -373,6 +373,11 @@ describe('api', function() 'xxxx', true, true, true)) end) + it('does not convert keycodes if special=false', function() + eq('xxxx', helpers.nvim('replace_termcodes', + 'xxxx', true, true, false)) + end) + it('does not crash when transforming an empty string', function() -- Actually does not test anything, because current code will use NULL for -- an empty string. @@ -391,13 +396,13 @@ describe('api', function() -- notice the special char(…) \xe2\80\xa6 nvim('feedkeys', ':let x1="…"\n', '', true) - -- Both replace_termcodes and feedkeys escape \x80 + -- Both nvim_replace_termcodes and nvim_feedkeys escape \x80 local inp = helpers.nvim('replace_termcodes', ':let x2="…"', true, true, true) - nvim('feedkeys', inp, '', true) + nvim('feedkeys', inp, '', true) -- escape_csi=true - -- Disabling CSI escaping in feedkeys + -- nvim_feedkeys with CSI escaping disabled inp = helpers.nvim('replace_termcodes', ':let x3="…"', true, true, true) - nvim('feedkeys', inp, '', false) + nvim('feedkeys', inp, '', false) -- escape_csi=false helpers.stop() end -- cgit