diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-08-28 20:49:54 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-08-28 20:49:54 +0800 |
commit | 1c7f461c70fbcf6937097e55aae0fc1ff0645f65 (patch) | |
tree | 180391ff99e3b795203c0bc19bc0cc601232e483 /server/test.lua | |
parent | 1e878722b14c0a2448a494ea8ad475ddefeda659 (diff) | |
download | lua-language-server-1c7f461c70fbcf6937097e55aae0fc1ff0645f65.zip |
测试放到外面
Diffstat (limited to 'server/test.lua')
-rw-r--r-- | server/test.lua | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/server/test.lua b/server/test.lua index 05f1fcfd..b1945a0e 100644 --- a/server/test.lua +++ b/server/test.lua @@ -5,34 +5,60 @@ if rootPath == '' then end package.cpath = rootPath .. 'bin/?.so' .. ';' .. rootPath .. 'bin/?.dll' -package.path = rootPath .. 'src/?.lua' +package.path = rootPath .. 'test/?.lua' + .. ';' .. rootPath .. 'test/?/init.lua' + .. ';' .. rootPath .. 'src/?.lua' .. ';' .. rootPath .. 'src/?/init.lua' local fs = require 'bee.filesystem' -local subprocess = require 'bee.subprocess' -local platform = require 'bee.platform' -ROOT = fs.absolute(fs.path(rootPath)) - -local function runTest(root) - local ext = platform.OS == 'Windows' and '.exe' or '' - local exe = root / 'bin' / 'lua-language-server' .. ext - local test = root / 'test' / 'main.lua' - local lua = subprocess.spawn { - exe, - test, - '-E', - cwd = root, - stdout = true, - stderr = true, - } - for line in lua.stdout:lines 'l' do - print(line) - end - lua:wait() - local err = lua.stderr:read 'a' - if err ~= '' then - error(err) +ROOT = fs.absolute(fs.path(rootPath):parent_path()) +LANG = 'en-US' + +log = require 'log' +log.init(ROOT, ROOT / 'log' / 'test.log') +log.debug('测试开始') +ac = {} + +require 'utility' +require 'global_protect' +dofile((ROOT / 'build_package.lua'):string()) + +local function loadAllLibs() + assert(require 'bee.filesystem') + assert(require 'bee.subprocess') + assert(require 'bee.thread') + assert(require 'bee.socket') + assert(require 'lni') + assert(require 'lpeglabel') +end + +local function main() + local function test(name) + local clock = os.clock() + print(('测试[%s]...'):format(name)) + require(name) + print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock)) end + + test 'core' + test 'definition' + test 'rename' + test 'highlight' + test 'references' + test 'diagnostics' + test 'type_inference' + test 'find_lib' + test 'hover' + test 'completion' + test 'signature' + test 'document_symbol' + test 'crossfile' + test 'full' + + print('测试完成') end -runTest(ROOT) +loadAllLibs() +main() + +log.debug('测试完成') |