From 1c7f461c70fbcf6937097e55aae0fc1ff0645f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 28 Aug 2019 20:49:54 +0800 Subject: =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=94=BE=E5=88=B0=E5=A4=96=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/test.lua | 76 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 25 deletions(-) (limited to 'server/test.lua') 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('测试完成') -- cgit v1.2.3