summaryrefslogtreecommitdiff
path: root/test.lua
blob: 9f29b9d9d2059d00a43a2a5fee67eba4ce16cc71 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package.path  = package.path
      .. ';./test/?.lua'
      .. ';./test/?/init.lua'
local fs = require 'bee.filesystem'
local rootPath = fs.exe_path():parent_path():parent_path():string()
ROOT = fs.path(rootPath)
TEST = true
DEVELOP = true
--FOOTPRINT = true
--TRACE = true
LOGPATH  = LOGPATH  or (ROOT:string() .. '/log')
METAPATH = METAPATH or (ROOT:string() .. '/meta')

collectgarbage 'generational'

io.write = function () end

---@diagnostic disable-next-line: lowercase-global
log = require 'log'
log.init(ROOT, ROOT / 'log' / 'test.log')
log.debug('测试开始')

--dofile((ROOT / 'build_package.lua'):string())
require 'tracy'

local function loadAllLibs()
    assert(require 'bee.filesystem')
    assert(require 'bee.subprocess')
    assert(require 'bee.thread')
    assert(require 'bee.socket')
    assert(require 'lpeglabel')
end

local function test(name)
    local clock = os.clock()
    print(('测试[%s]...'):format(name))
    local originRequire = require
    require = function (n, ...)
        local v, p = originRequire(n, ...)
        if p and p:find 'test/' then
            package.loaded[n] = nil
        end
        return v, p
    end
    require(name)
    require = originRequire
    print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock))
end

local function testAll()
    test 'basic'
    test 'references'
    test 'definition'
    test 'type_inference'
    test 'hover'
    test 'completion'
    test 'crossfile'
    test 'diagnostics'
    test 'highlight'
    test 'rename'
    test 'signature'
    test 'command'
    test 'document_symbol'
    test 'code_action'
    test 'type_formatting'
    --test 'other'
end

local function main()
    LOCALE = 'zh-cn'
    require 'utility'.enableCloseFunction()
    require 'client' .client 'VSCode'

    local lclient = require 'tclient.lclient'
    local ws      = require 'workspace'

    for _, os in ipairs {'Windows', 'Linux', 'macOS'} do
        require 'bee.platform'.OS = os
        ---@async
        lclient():start(function (client)
            client:registerFakers()
            client:initialize()

            ws.awaitReady()

            testAll()
        end)
    end

    test 'tclient'
    test 'full'
    print('测试完成')
end

loadAllLibs()
main()

log.debug('测试完成')
require 'bee.thread'.sleep(1)
os.exit()