diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/build_package.lua (renamed from server/test/build_package.lua) | 0 | ||||
-rw-r--r-- | server/main.lua | 2 | ||||
-rw-r--r-- | server/publish.lua | 2 | ||||
-rw-r--r-- | server/test.lua | 76 | ||||
-rw-r--r-- | server/test/main.lua | 58 |
5 files changed, 53 insertions, 85 deletions
diff --git a/server/test/build_package.lua b/server/build_package.lua index 0abfc267..0abfc267 100644 --- a/server/test/build_package.lua +++ b/server/build_package.lua diff --git a/server/main.lua b/server/main.lua index 61f17f2f..754e3759 100644 --- a/server/main.lua +++ b/server/main.lua @@ -9,7 +9,7 @@ package.path = rootPath .. 'src/?.lua' .. ';' .. rootPath .. 'src/?/init.lua' local fs = require 'bee.filesystem' -ROOT = fs.absolute(fs.path(rootPath)) +ROOT = fs.absolute(fs.path(rootPath):parent_path()) LANG = LANG or 'en-US' --collectgarbage('generational') diff --git a/server/publish.lua b/server/publish.lua index b0040641..149d54d6 100644 --- a/server/publish.lua +++ b/server/publish.lua @@ -10,7 +10,7 @@ package.path = rootPath .. 'src/?.lua' local fs = require 'bee.filesystem' local subprocess = require 'bee.subprocess' -ROOT = fs.absolute(fs.path(rootPath)) +ROOT = fs.absolute(fs.path(rootPath):parent_path()) EXTENSION = fs.absolute(fs.path(rootPath .. '..')) require 'utility' 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('测试完成') diff --git a/server/test/main.lua b/server/test/main.lua deleted file mode 100644 index 85885783..00000000 --- a/server/test/main.lua +++ /dev/null @@ -1,58 +0,0 @@ -local fs = require 'bee.filesystem' - -ROOT = fs.current_path() -LANG = 'en-US' - -package.path = (ROOT / 'src' / '?.lua'):string() - .. ';' .. (ROOT / 'src' / '?' / 'init.lua'):string() - .. ';' .. (ROOT / 'test' / '?.lua'):string() - .. ';' .. (ROOT / 'test' / '?' / 'init.lua'):string() - -log = require 'log' -log.init(ROOT, ROOT / 'log' / 'test.log') -log.debug('测试开始') -ac = {} -error '测试' -require 'utility' -require 'global_protect' -require 'build_package' - -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 - -loadAllLibs() -main() - -log.debug('测试完成') |