diff options
author | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
---|---|---|
committer | CppCXY <812125110@qq.com> | 2024-02-22 20:29:13 +0800 |
commit | 9b6df71d97a70ee7179949ef9f15368cbf29dcbd (patch) | |
tree | bf7a7e62ed7c164a12bdce437c17262a5235bcec /test/plugins/ffi/test.lua | |
parent | 483fe246b6ae8c25d433aa15e43f04f0e71a74d5 (diff) | |
parent | 3e6fd3ce1f2f0528336ded939d776a29bbfaf2eb (diff) | |
download | lua-language-server-9b6df71d97a70ee7179949ef9f15368cbf29dcbd.zip |
Merge branch 'master' of github.com:CppCXY/lua-language-server
Diffstat (limited to 'test/plugins/ffi/test.lua')
-rw-r--r-- | test/plugins/ffi/test.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/plugins/ffi/test.lua b/test/plugins/ffi/test.lua new file mode 100644 index 00000000..93be2ff5 --- /dev/null +++ b/test/plugins/ffi/test.lua @@ -0,0 +1,43 @@ +local lclient = require 'lclient' +local ws = require 'workspace' +local furi = require 'file-uri' +local files = require 'files' +local diagnostic = require 'provider.diagnostic' + +--TODO how to changed the runtime version? +local template = require 'config.template' + +template['Lua.runtime.version'].default = 'LuaJIT' + +TESTURI = furi.encode(TESTROOT .. 'unittest.ffi.lua') + +---@async +local function TestBuilder() + local builder = require 'core.command.reloadFFIMeta' + files.setText(TESTURI, [[ + local ffi = require 'ffi' + ffi.cdef 'void test();' + ]]) + local uri = ws.getFirstScope().uri + builder(uri) +end + +---@async +lclient():start(function (languageClient) + languageClient:registerFakers() + local rootUri = TESTURI + languageClient:initialize { + rootUri = rootUri, + } + + diagnostic.pause() + + ws.awaitReady(rootUri) + + require 'plugins.ffi.cdef' + require 'plugins.ffi.parser' + require 'plugins.ffi.builder' + TestBuilder() + + diagnostic.resume() +end) |