diff options
Diffstat (limited to 'test/functional/fixtures')
-rw-r--r-- | test/functional/fixtures/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/functional/fixtures/api_level_9.mpack | bin | 0 -> 30127 bytes | |||
-rw-r--r-- | test/functional/fixtures/autoload/provider/python3.vim (renamed from test/functional/fixtures/autoload/provider/python.vim) | 2 | ||||
-rw-r--r-- | test/functional/fixtures/fake-lsp-server.lua | 256 | ||||
-rw-r--r-- | test/functional/fixtures/lua/test_plug/health/init.lua | 9 | ||||
-rw-r--r-- | test/functional/fixtures/lua/test_plug/submodule/health.lua | 9 | ||||
-rw-r--r-- | test/functional/fixtures/lua/test_plug/submodule_empty/health.lua | 7 | ||||
-rw-r--r-- | test/functional/fixtures/lua/test_plug/submodule_failed/health.lua | 7 | ||||
-rw-r--r-- | test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua | 1 |
9 files changed, 261 insertions, 34 deletions
diff --git a/test/functional/fixtures/CMakeLists.txt b/test/functional/fixtures/CMakeLists.txt index 270540de2e..a5410c2f8c 100644 --- a/test/functional/fixtures/CMakeLists.txt +++ b/test/functional/fixtures/CMakeLists.txt @@ -2,9 +2,11 @@ add_executable(tty-test EXCLUDE_FROM_ALL tty-test.c) target_link_libraries(tty-test ${LIBUV_LIBRARIES}) add_executable(shell-test EXCLUDE_FROM_ALL shell-test.c) +# Fake pwsh (powershell) for testing make_filter_cmd(). #16271 +add_executable(pwsh-test EXCLUDE_FROM_ALL shell-test.c) add_executable(printargs-test EXCLUDE_FROM_ALL printargs-test.c) add_executable(printenv-test EXCLUDE_FROM_ALL printenv-test.c) -if(WIN32) +if(MINGW) set_target_properties(printenv-test PROPERTIES LINK_FLAGS -municode) endif() diff --git a/test/functional/fixtures/api_level_9.mpack b/test/functional/fixtures/api_level_9.mpack Binary files differnew file mode 100644 index 0000000000..650d7a6a4d --- /dev/null +++ b/test/functional/fixtures/api_level_9.mpack diff --git a/test/functional/fixtures/autoload/provider/python.vim b/test/functional/fixtures/autoload/provider/python3.vim index d68360ac30..8ed4330a35 100644 --- a/test/functional/fixtures/autoload/provider/python.vim +++ b/test/functional/fixtures/autoload/provider/python3.vim @@ -1,6 +1,6 @@ " Dummy test provider, missing this required variable: " let g:loaded_brokenenabled_provider = 0 -function! provider#python#Call(method, args) +function! provider#python3#Call(method, args) return 42 endfunction diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 5c0de50731..0dc0c8c2db 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -28,7 +28,10 @@ local function assert_eq(a, b, ...) if not vim.deep_equal(a, b) then error(message_parts(": ", ..., "assert_eq failed", - string.format("left == %q, right == %q", vim.inspect(a), vim.inspect(b)) + string.format("left == %q, right == %q", + table.concat(vim.split(vim.inspect(a), "\n"), ""), + table.concat(vim.split(vim.inspect(b), "\n"), "") + ) )) end end @@ -100,8 +103,12 @@ local tests = {} function tests.basic_init() skeleton { - on_init = function(_params) - return { capabilities = {} } + on_init = function(_) + return { + capabilities = { + textDocumentSync = protocol.TextDocumentSyncKind.None; + } + } end; body = function() notify('test') @@ -109,6 +116,19 @@ function tests.basic_init() } end +function tests.basic_init_did_change_configuration() + skeleton({ + on_init = function(_) + return { + capabilities = {}, + } + end, + body = function() + expect_notification('workspace/didChangeConfiguration', { settings = { dummy = 1 } }) + end, + }) +end + function tests.check_workspace_configuration() skeleton { on_init = function(_params) @@ -119,8 +139,10 @@ function tests.check_workspace_configuration() notify('workspace/configuration', { items = { { section = "testSetting1" }; { section = "testSetting2" }; + { section = "test.Setting3" }; + { section = "test.Setting4" }; } }) - expect_notification('workspace/configuration', { true; vim.NIL}) + expect_notification('workspace/configuration', { true; false; 'nested'; vim.NIL}) notify('shutdown') end; } @@ -130,8 +152,11 @@ function tests.prepare_rename_nil() skeleton { on_init = function() return { capabilities = { - renameProvider = true, - } } + renameProvider = { + prepareProvider = true + } + } + } end; body = function() notify('start') @@ -147,8 +172,11 @@ function tests.prepare_rename_placeholder() skeleton { on_init = function() return { capabilities = { - renameProvider = true, - } } + renameProvider = { + prepareProvider = true + } + } + } end; body = function() notify('start') @@ -168,8 +196,11 @@ function tests.prepare_rename_range() skeleton { on_init = function() return { capabilities = { - renameProvider = true, - } } + renameProvider = { + prepareProvider = true + } + } + } end; body = function() notify('start') @@ -191,19 +222,19 @@ end function tests.prepare_rename_error() skeleton { on_init = function() - return { capabilities = { - renameProvider = true, - } } + return { + capabilities = { + renameProvider = { + prepareProvider = true + }, + } + } end; body = function() notify('start') expect_request('textDocument/prepareRename', function() return {}, nil end) - expect_request('textDocument/rename', function(params) - assert_eq(params.newName, 'renameto') - return nil, nil - end) notify('shutdown') end; } @@ -217,6 +248,7 @@ function tests.basic_check_capabilities() return { capabilities = { textDocumentSync = protocol.TextDocumentSyncKind.Full; + codeLensProvider = false } } end; @@ -225,6 +257,51 @@ function tests.basic_check_capabilities() } end +function tests.text_document_sync_save_bool() + skeleton { + on_init = function() + return { + capabilities = { + textDocumentSync = { + save = true + } + } + } + end; + body = function() + notify('start') + expect_notification('textDocument/didSave', {textDocument = { uri = "file://" }}) + notify('shutdown') + end; + } +end + +function tests.text_document_sync_save_includeText() + skeleton { + on_init = function() + return { + capabilities = { + textDocumentSync = { + save = { + includeText = true + } + } + } + } + end; + body = function() + notify('start') + expect_notification('textDocument/didSave', { + textDocument = { + uri = "file://" + }, + text = "help me\n" + }) + notify('shutdown') + end; + } +end + function tests.capabilities_for_client_supports_method() skeleton { on_init = function(params) @@ -235,6 +312,7 @@ function tests.capabilities_for_client_supports_method() textDocumentSync = protocol.TextDocumentSyncKind.Full; completionProvider = true; hoverProvider = true; + renameProvider = false; definitionProvider = false; referencesProvider = false; codeLensProvider = { resolveProvider = true; }; @@ -542,7 +620,15 @@ function tests.basic_check_buffer_open_and_change_incremental() assert_eq(params.capabilities, expected_capabilities) return { capabilities = { - textDocumentSync = protocol.TextDocumentSyncKind.Incremental; + textDocumentSync = { + openClose = true, + change = protocol.TextDocumentSyncKind.Incremental, + willSave = true, + willSaveWaitUntil = true, + save = { + includeText = true, + } + } } } end; @@ -671,6 +757,78 @@ function tests.code_action_with_resolve() } end +function tests.code_action_server_side_command() + skeleton({ + on_init = function() + return { + capabilities = { + codeActionProvider = { + resolveProvider = false, + }, + }, + } + end, + body = function() + notify('start') + local cmd = { + title = 'Command 1', + command = 'dummy1', + } + expect_request('textDocument/codeAction', function() + return nil, { cmd } + end) + expect_request('workspace/executeCommand', function() + return nil, cmd + end) + notify('shutdown') + end, + }) +end + + +function tests.code_action_filter() + skeleton { + on_init = function() + return { + capabilities = { + codeActionProvider = { + resolveProvider = false + } + } + } + end; + body = function() + notify('start') + local action = { + title = 'Action 1', + command = 'command' + } + local preferred_action = { + title = 'Action 2', + isPreferred = true, + command = 'preferred_command', + } + local quickfix_action = { + title = 'Action 3', + kind = 'quickfix', + command = 'quickfix_command', + } + local quickfix_foo_action = { + title = 'Action 4', + kind = 'quickfix.foo', + command = 'quickfix_foo_command', + } + expect_request('textDocument/codeAction', function() + return nil, { action, preferred_action, quickfix_action, quickfix_foo_action, } + end) + expect_request('textDocument/codeAction', function() + return nil, { action, preferred_action, quickfix_action, quickfix_foo_action, } + end) + notify('shutdown') + end; + } +end + function tests.clientside_commands() skeleton { on_init = function() @@ -685,6 +843,68 @@ function tests.clientside_commands() } end +function tests.codelens_refresh_lock() + skeleton { + on_init = function() + return { + capabilities = { + codeLensProvider = { resolveProvider = true; }; + } + } + end; + body = function() + notify('start') + expect_request("textDocument/codeLens", function () + return {code = -32002, message = "ServerNotInitialized"}, nil + end) + expect_request("textDocument/codeLens", function () + local lenses = { + { + range = { + start = { line = 0, character = 0, }, + ['end'] = { line = 0, character = 3 } + }, + command = { title = 'Lens1', command = 'Dummy' } + }, + } + return nil, lenses + end) + expect_request("textDocument/codeLens", function () + local lenses = { + { + range = { + start = { line = 0, character = 0, }, + ['end'] = { line = 0, character = 3 } + }, + command = { title = 'Lens2', command = 'Dummy' } + }, + } + return nil, lenses + end) + notify('shutdown') + end; + } +end + +function tests.basic_formatting() + skeleton { + on_init = function() + return { + capabilities = { + documentFormattingProvider = true, + } + } + end; + body = function() + notify('start') + expect_request('textDocument/formatting', function() + return nil, {} + end) + notify('shutdown') + end; + } +end + -- Tests will be indexed by TEST_NAME local kill_timer = vim.loop.new_timer() diff --git a/test/functional/fixtures/lua/test_plug/health/init.lua b/test/functional/fixtures/lua/test_plug/health/init.lua index d07632cff4..58162d4515 100644 --- a/test/functional/fixtures/lua/test_plug/health/init.lua +++ b/test/functional/fixtures/lua/test_plug/health/init.lua @@ -1,11 +1,10 @@ local M = {} -local health = require("health") M.check = function() - health.report_start("report 1") - health.report_ok("everything is fine") - health.report_start("report 2") - health.report_ok("nothing to see here") + vim.health.report_start("report 1") + vim.health.report_ok("everything is fine") + vim.health.report_start("report 2") + vim.health.report_ok("nothing to see here") end return M diff --git a/test/functional/fixtures/lua/test_plug/submodule/health.lua b/test/functional/fixtures/lua/test_plug/submodule/health.lua index d07632cff4..58162d4515 100644 --- a/test/functional/fixtures/lua/test_plug/submodule/health.lua +++ b/test/functional/fixtures/lua/test_plug/submodule/health.lua @@ -1,11 +1,10 @@ local M = {} -local health = require("health") M.check = function() - health.report_start("report 1") - health.report_ok("everything is fine") - health.report_start("report 2") - health.report_ok("nothing to see here") + vim.health.report_start("report 1") + vim.health.report_ok("everything is fine") + vim.health.report_start("report 2") + vim.health.report_ok("nothing to see here") end return M diff --git a/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua b/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua new file mode 100644 index 0000000000..d2cf86e4f0 --- /dev/null +++ b/test/functional/fixtures/lua/test_plug/submodule_empty/health.lua @@ -0,0 +1,7 @@ +local M = {} + +M.check = function() + return {} +end + +return M diff --git a/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua b/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua index 3a8af6ebb2..ee5f4e404b 100644 --- a/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua +++ b/test/functional/fixtures/lua/test_plug/submodule_failed/health.lua @@ -1,10 +1,9 @@ local M = {} -local health = require("health") M.check = function() - health.report_start("report 1") - health.report_ok("everything is fine") - health.report_warn("About to add a number to nil") + vim.health.report_start("report 1") + vim.health.report_ok("everything is fine") + vim.health.report_warn("About to add a number to nil") local a = nil + 2 return a end diff --git a/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua b/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua new file mode 100644 index 0000000000..c1c33d787e --- /dev/null +++ b/test/functional/fixtures/pack/foo/start/bar/lua/baz-quux.lua @@ -0,0 +1 @@ +return {doit=function() return 9004 end} |