summaryrefslogtreecommitdiff
path: root/test.lua
blob: bab770ac2cb98f31e345119e307d1513e6337d85 (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
local currentPath = debug.getinfo(1, 'S').source:sub(2)
local rootPath = currentPath:gsub('[/\\]*[^/\\]-$', '')
rootPath = rootPath == '' and '.' or rootPath
loadfile(rootPath .. '/platform.lua')('script')
package.path  = package.path
      .. ';' .. rootPath .. '/test/?.lua'
      .. ';' .. rootPath .. '/test/?/init.lua'
local fs = require 'bee.filesystem'
ROOT = fs.path(rootPath)
TEST = true
DEVELOP = true
LOGPATH  = LOGPATH  or (ROOT .. '/log')
METAPATH = METAPATH or (ROOT .. '/meta')

collectgarbage 'generational'

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 loadDocMetas()
    local files   = require 'files'
    local library = require 'library'
    local furi    = require 'file-uri'
    local fsu     = require 'fs-utility'
    local client  = require 'provider.client'
    client.client 'vscode'
    library.init()
    for _, path in ipairs(library.metaPaths) do
        local uri = furi.encode(path)
        files.setText(uri, fsu.loadFile(path))
        files.setLibraryPath(uri, library.metaPath)
    end
end

local function main()
    debug.setcstacklimit(1000)
    require 'parser.guide'.debugMode = true
    require 'language' 'zh-cn'
    require 'utility'.enableCloseFunction()
    local function test(name)
        local clock = os.clock()
        print(('测试[%s]...'):format(name))
        require(name)
        print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock))
    end

    local config = require 'config'
    config.config.runtime.version = 'Lua 5.4'
    --config.config.intelliSense.searchDepth = 5
    loadDocMetas()

    test 'basic'
    test 'references'
    test 'definition'
    test 'type_inference'
    test 'diagnostics'
    test 'highlight'
    test 'rename'
    test 'hover'
    test 'completion'
    test 'signature'
    test 'document_symbol'
    test 'code_action'
    test 'crossfile'
    test 'full'
    --test 'other'

    print('测试完成')
end

loadAllLibs()
main()

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