summaryrefslogtreecommitdiff
path: root/test/plugins/ffi/test.lua
blob: 7c17cb6d37bb99c54eb6ba3d64b2b0325cf18b88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local lclient = require 'lclient'
local ws = require 'workspace'
local furi = require 'file-uri'
local files = require 'files'

--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,
    }

    ws.awaitReady(rootUri)

    require 'plugins.ffi.cdef'
    require 'plugins.ffi.parser'
    require 'plugins.ffi.builder'
    TestBuilder()
end)