summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-08-28 20:49:54 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-08-28 20:49:54 +0800
commit1c7f461c70fbcf6937097e55aae0fc1ff0645f65 (patch)
tree180391ff99e3b795203c0bc19bc0cc601232e483
parent1e878722b14c0a2448a494ea8ad475ddefeda659 (diff)
downloadlua-language-server-1c7f461c70fbcf6937097e55aae0fc1ff0645f65.zip
测试放到外面
-rw-r--r--.vscode/launch.json7
-rw-r--r--server/build_package.lua (renamed from server/test/build_package.lua)0
-rw-r--r--server/main.lua2
-rw-r--r--server/publish.lua2
-rw-r--r--server/test.lua76
-rw-r--r--server/test/main.lua58
6 files changed, 54 insertions, 91 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index baa8a471..1eec0c44 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -7,15 +7,10 @@
"type": "lua",
"request": "launch",
"stopOnEntry": false,
- "program": "${workspaceRoot}/server/test/main.lua",
+ "program": "${workspaceRoot}/server/test.lua",
"cwd": "${workspaceRoot}/server",
- "env": {
- "PATH": "${workspaceRoot}\\server\\bin\\"
- },
//"luaexe": "${workspaceRoot}\\server\\bin\\lua-language-server.exe",
//"luadll": "${workspaceRoot}\\server\\bin\\lua54.dll",
- "path": "${workspaceRoot}/server/bin/?.lua",
- "cpath": "${workspaceRoot}/server/bin/?.dll;",
"arg": [
],
"consoleCoding": "utf8",
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('测试完成')