diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-18 16:06:26 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-18 16:06:26 +0800 |
commit | b7fdf179a9015e3bef83f89c5a0811f1a67ef4d0 (patch) | |
tree | db0a36705b76f5ecf83b6de4612f035a6d9f43f7 /test/tclient | |
parent | 9cc6ca5866fcfcf22bb42f9089ff21ca51a96987 (diff) | |
download | lua-language-server-b7fdf179a9015e3bef83f89c5a0811f1a67ef4d0.zip |
update
Diffstat (limited to 'test/tclient')
-rw-r--r-- | test/tclient/init.lua | 1 | ||||
-rw-r--r-- | test/tclient/lclient.lua | 32 | ||||
-rw-r--r-- | test/tclient/tests/library-ignore-limit.lua | 27 | ||||
-rw-r--r-- | test/tclient/tests/single-mode.lua | 11 |
4 files changed, 58 insertions, 13 deletions
diff --git a/test/tclient/init.lua b/test/tclient/init.lua index 627aed17..8e7df570 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -1 +1,2 @@ require 'tclient.tests.single-mode' +require 'tclient.tests.library-ignore-limit' diff --git a/test/tclient/lclient.lua b/test/tclient/lclient.lua index 4273d88c..52b72290 100644 --- a/test/tclient/lclient.lua +++ b/test/tclient/lclient.lua @@ -36,6 +36,26 @@ function mt:_flushServer() files.reset() end +---@async +function mt:initialize(params) + self:awaitRequest('initialize', params or {}) + self:notify('initialized') +end + +function mt:reportHangs() + local hangs = {} + hangs[#hangs+1] = ('====== C -> S ======') + for _, waiting in util.sortPairs(self._waiting) do + hangs[#hangs+1] = ('%03d %s'):format(waiting.id, waiting.method) + end + hangs[#hangs+1] = ('====== S -> C ======') + for _, waiting in util.sortPairs(proto.waiting) do + hangs[#hangs+1] = ('%03d %s'):format(waiting.id, waiting.method) + end + hangs[#hangs+1] = ('====================') + return table.concat(hangs, '\n') +end + ---@param callback async fun(client: languageClient) function mt:start(callback) self:_fakeProto() @@ -68,7 +88,7 @@ function mt:start(callback) timer.timeJump(1.0) jumpedTime = jumpedTime + 1.0 if jumpedTime > 2 * 60 * 60 then - error('two hours later ...') + error('two hours later ...\n' .. self:reportHangs()) end ::CONTINUE:: end @@ -93,7 +113,11 @@ end function mt:request(method, params, callback) local id = counter() - self._waiting[id] = callback + self._waiting[id] = { + id = id, + params = params, + callback = callback, + } proto.doMethod { id = id, method = method, @@ -126,7 +150,7 @@ function mt:update() error('Unknown method: ' .. out.method) end else - local callback = self._waiting[out.id] + local callback = self._waiting[out.id].callback self._waiting[out.id] = nil callback(out.result, out.error) end @@ -141,6 +165,8 @@ end function mt:registerFakers() for _, method in ipairs { 'workspace/configuration', + 'workspace/semanticTokens/refresh', + 'window/workDoneProgress/create', 'textDocument/publishDiagnostics', } do self:register(method, function () diff --git a/test/tclient/tests/library-ignore-limit.lua b/test/tclient/tests/library-ignore-limit.lua new file mode 100644 index 00000000..66d6cc09 --- /dev/null +++ b/test/tclient/tests/library-ignore-limit.lua @@ -0,0 +1,27 @@ +local lclient = require 'tclient.lclient' +local util = require 'utility' +local ws = require 'workspace' +local files = require 'files' +local furi = require 'file-uri' + +local libraryPath = LOGPATH .. '/large-file-library' +local largeFilePath = LOGPATH .. '/large-file-library/large-file.lua' + +---@async +lclient():start(function (client) + client:registerFakers() + + client:register('workspace/configuration', function () + return { + ['Lua.workspace.library'] = { libraryPath } + } + end) + + util.saveFile(largeFilePath, string.rep('--this is a large file\n', 20000)) + + client:initialize() + + ws.awaitReady() + + assert(files.getState(furi.encode(largeFilePath)) ~= nil) +end) diff --git a/test/tclient/tests/single-mode.lua b/test/tclient/tests/single-mode.lua index 897eee31..d26eb98a 100644 --- a/test/tclient/tests/single-mode.lua +++ b/test/tclient/tests/single-mode.lua @@ -6,16 +6,7 @@ local util = require 'utility' ---@async lclient():start(function (client) client:registerFakers() - - client:awaitRequest('initialize', { - clientInfo = { - name = 'unit-test', - version = 'single-mode', - }, - rootUri = nil, - }) - - client:notify('initialized') + client:initialize() client:notify('textDocument/didOpen', { textDocument = { |