blob: 9e136934533a31e75e7fca6475198066dea65769 (
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
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'
---@diagnostic disable-next-line: duplicate-set-field
io.write = function () end
---@diagnostic disable-next-line: lowercase-global
log = require 'log'
log.init(ROOT, ROOT / 'log' / 'test.log')
log.debug('测试开始')
LOCALE = 'zh-cn'
--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 'definition'
test 'type_inference'
test 'references'
test 'hover'
test 'completion'
test 'diagnostics'
test 'crossfile'
test 'highlight'
test 'rename'
test 'signature'
test 'command'
test 'document_symbol'
test 'code_action'
test 'type_formatting'
test 'other'
end
local files = require "files"
local function main()
require 'utility'.enableCloseFunction()
require 'client' .client 'VSCode'
local lclient = require 'lclient'
local ws = require 'workspace'
local furi = require 'file-uri'
require 'vm'
--log.print = true
TESTURI = furi.encode('/unittest.lua')
---@async
lclient():start(function (client)
client:registerFakers()
local rootUri = furi.encode '/'
client:initialize {
rootUri = rootUri,
}
ws.awaitReady(rootUri)
print('Loaded files in', os)
for uri in files.eachFile() do
print(uri)
end
print('===============')
testAll()
end)
test 'tclient'
test 'full'
end
loadAllLibs()
main()
log.debug('test finish.')
require 'bee.thread'.sleep(1)
os.exit()
|