aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-21 10:04:32 -0800
committerAshkan Kiani <ashkan.k.kiani@gmail.com>2019-11-21 10:04:32 -0800
commit6a5140137865025dee68e75a4e8feb2d20a430cf (patch)
treebd9815ea488c4ee77bdfd6631ba7159f039ebe3e /test
parentb7170f2d722cee24a62eb74ac836d6192e5475dc (diff)
parentcc5487e32f6fc6d0034634a1f9e736968afb4450 (diff)
downloadrneovim-6a5140137865025dee68e75a4e8feb2d20a430cf.tar.gz
rneovim-6a5140137865025dee68e75a4e8feb2d20a430cf.tar.bz2
rneovim-6a5140137865025dee68e75a4e8feb2d20a430cf.zip
Merge remote-tracking branch 'origin/master' into lsp-followup
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/fileio_spec.lua25
-rw-r--r--test/functional/fixtures/lsp-test-rpc-server.lua53
-rw-r--r--test/functional/plugin/lsp/lsp_spec.lua48
3 files changed, 117 insertions, 9 deletions
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index e6bce85b8a..f4c476560d 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -9,9 +9,12 @@ local nvim_prog = helpers.nvim_prog
local request = helpers.request
local retry = helpers.retry
local rmdir = helpers.rmdir
+local mkdir = helpers.mkdir
local sleep = helpers.sleep
local read_file = helpers.read_file
local trim = helpers.trim
+local currentdir = helpers.funcs.getcwd
+local iswin = helpers.iswin
describe('fileio', function()
before_each(function()
@@ -24,6 +27,7 @@ describe('fileio', function()
os.remove('Xtest_startup_file2')
os.remove('Xtest_ั‚ะตัั‚.md')
rmdir('Xtest_startup_swapdir')
+ rmdir('Xtest_backupdir')
end)
it('fsync() codepaths #8304', function()
@@ -88,6 +92,27 @@ describe('fileio', function()
eq('foo', bar_contents);
end)
+ it('backup with full path #11214', function()
+ clear()
+ mkdir('Xtest_backupdir')
+ command('set backup')
+ command('set backupdir=Xtest_backupdir//')
+ command('write Xtest_startup_file1')
+ feed('ifoo<esc>')
+ command('write')
+ feed('Abar<esc>')
+ command('write')
+
+ -- Backup filename = fullpath, separators replaced with "%".
+ local backup_file_name = string.gsub(currentdir()..'/Xtest_startup_file1',
+ iswin() and '[:/\\]' or '/', '%%') .. '~'
+ local foo_contents = trim(read_file('Xtest_backupdir/'..backup_file_name))
+ local foobar_contents = trim(read_file('Xtest_startup_file1'))
+
+ eq('foobar', foobar_contents);
+ eq('foo', foo_contents);
+ end)
+
it('readfile() on multibyte filename #10586', function()
clear()
local text = {
diff --git a/test/functional/fixtures/lsp-test-rpc-server.lua b/test/functional/fixtures/lsp-test-rpc-server.lua
index 971e61b072..798883ced0 100644
--- a/test/functional/fixtures/lsp-test-rpc-server.lua
+++ b/test/functional/fixtures/lsp-test-rpc-server.lua
@@ -170,7 +170,7 @@ function tests.basic_check_buffer_open()
expect_notification('textDocument/didOpen', {
textDocument = {
languageId = "";
- text = table.concat({"testing"; "123"}, "\n");
+ text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
version = 0;
};
@@ -197,6 +197,42 @@ function tests.basic_check_buffer_open_and_change()
expect_notification('textDocument/didOpen', {
textDocument = {
languageId = "";
+ text = table.concat({"testing"; "123"}, "\n") .. '\n';
+ uri = "file://";
+ version = 0;
+ };
+ })
+ expect_notification('textDocument/didChange', {
+ textDocument = {
+ uri = "file://";
+ version = 3;
+ };
+ contentChanges = {
+ { text = table.concat({"testing"; "boop"}, "\n") .. '\n'; };
+ }
+ })
+ expect_notification("finish")
+ notify('finish')
+ end;
+ }
+end
+
+function tests.basic_check_buffer_open_and_change_noeol()
+ skeleton {
+ on_init = function(params)
+ local expected_capabilities = protocol.make_client_capabilities()
+ assert_eq(params.capabilities, expected_capabilities)
+ return {
+ capabilities = {
+ textDocumentSync = protocol.TextDocumentSyncKind.Full;
+ }
+ }
+ end;
+ body = function()
+ notify('start')
+ expect_notification('textDocument/didOpen', {
+ textDocument = {
+ languageId = "";
text = table.concat({"testing"; "123"}, "\n");
uri = "file://";
version = 0;
@@ -216,7 +252,6 @@ function tests.basic_check_buffer_open_and_change()
end;
}
end
-
function tests.basic_check_buffer_open_and_change_multi()
skeleton {
on_init = function(params)
@@ -233,7 +268,7 @@ function tests.basic_check_buffer_open_and_change_multi()
expect_notification('textDocument/didOpen', {
textDocument = {
languageId = "";
- text = table.concat({"testing"; "123"}, "\n");
+ text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
version = 0;
};
@@ -244,7 +279,7 @@ function tests.basic_check_buffer_open_and_change_multi()
version = 3;
};
contentChanges = {
- { text = table.concat({"testing"; "321"}, "\n"); };
+ { text = table.concat({"testing"; "321"}, "\n") .. '\n'; };
}
})
expect_notification('textDocument/didChange', {
@@ -253,7 +288,7 @@ function tests.basic_check_buffer_open_and_change_multi()
version = 4;
};
contentChanges = {
- { text = table.concat({"testing"; "boop"}, "\n"); };
+ { text = table.concat({"testing"; "boop"}, "\n") .. '\n'; };
}
})
expect_notification("finish")
@@ -278,7 +313,7 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
expect_notification('textDocument/didOpen', {
textDocument = {
languageId = "";
- text = table.concat({"testing"; "123"}, "\n");
+ text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
version = 0;
};
@@ -289,7 +324,7 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
version = 3;
};
contentChanges = {
- { text = table.concat({"testing"; "321"}, "\n"); };
+ { text = table.concat({"testing"; "321"}, "\n") .. '\n'; };
}
})
expect_notification('textDocument/didChange', {
@@ -298,7 +333,7 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
version = 4;
};
contentChanges = {
- { text = table.concat({"testing"; "boop"}, "\n"); };
+ { text = table.concat({"testing"; "boop"}, "\n") .. '\n'; };
}
})
expect_notification('textDocument/didClose', {
@@ -328,7 +363,7 @@ function tests.basic_check_buffer_open_and_change_incremental()
expect_notification('textDocument/didOpen', {
textDocument = {
languageId = "";
- text = table.concat({"testing"; "123"}, "\n");
+ text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
version = 0;
};
diff --git a/test/functional/plugin/lsp/lsp_spec.lua b/test/functional/plugin/lsp/lsp_spec.lua
index cd0974b81c..c38c9b72ce 100644
--- a/test/functional/plugin/lsp/lsp_spec.lua
+++ b/test/functional/plugin/lsp/lsp_spec.lua
@@ -410,6 +410,54 @@ describe('Language Client API', function()
}
end)
+ it('should check the body and didChange full with noeol', function()
+ local expected_callbacks = {
+ {NIL, "shutdown", {}, 1};
+ {NIL, "finish", {}, 1};
+ {NIL, "start", {}, 1};
+ }
+ local client
+ test_rpc_server {
+ test_name = "basic_check_buffer_open_and_change_noeol";
+ on_setup = function()
+ exec_lua [[
+ BUFFER = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_buf_set_lines(BUFFER, 0, -1, false, {
+ "testing";
+ "123";
+ })
+ vim.api.nvim_buf_set_option(BUFFER, 'eol', false)
+ ]]
+ end;
+ on_init = function(_client)
+ client = _client
+ local full_kind = exec_lua("return require'vim.lsp.protocol'.TextDocumentSyncKind.Full")
+ eq(full_kind, client.resolved_capabilities().text_document_did_change)
+ eq(true, client.resolved_capabilities().text_document_open_close)
+ exec_lua [[
+ assert(lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID))
+ ]]
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code") eq(0, signal, "exit signal")
+ end;
+ on_callback = function(err, method, params, client_id)
+ if method == 'start' then
+ exec_lua [[
+ vim.api.nvim_buf_set_lines(BUFFER, 1, 2, false, {
+ "boop";
+ })
+ ]]
+ client.notify('finish')
+ end
+ eq(table.remove(expected_callbacks), {err, method, params, client_id}, "expected callback")
+ if method == 'finish' then
+ client.stop()
+ end
+ end;
+ }
+ end)
+
-- TODO(askhan) we don't support full for now, so we can disable these tests.
pending('should check the body and didChange incremental', function()
local expected_callbacks = {