summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/publish.lua2
-rw-r--r--server/src/workspace.lua4
-rw-r--r--server/test.lua28
-rw-r--r--server/test/crossfile/hover.lua3
4 files changed, 35 insertions, 2 deletions
diff --git a/server/publish.lua b/server/publish.lua
index 3b4d4420..c7cbefcc 100644
--- a/server/publish.lua
+++ b/server/publish.lua
@@ -63,7 +63,7 @@ local function copyFiles(root, out)
end
local function runTest(root)
- local exe = root / 'bin' / 'lua-language-server.exe'
+ local exe = root / 'bin' / 'lua-language-server'
local test = root / 'test' / 'main.lua'
local lua = subprocess.spawn {
exe,
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index 2837f5a2..ef449e1a 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -52,6 +52,10 @@ local mt = {}
mt.__index = mt
function mt:uriDecode(uri)
+ -- Unix-like系统根是/
+ if uri:sub(1, 9) == 'file:////' then
+ return fs.path(uri:sub(9))
+ end
if uri:sub(1, 8) ~= 'file:///' then
log.error('uri decode failed: ', uri)
return nil
diff --git a/server/test.lua b/server/test.lua
new file mode 100644
index 00000000..fe2efd23
--- /dev/null
+++ b/server/test.lua
@@ -0,0 +1,28 @@
+local fs = require 'bee.filesystem'
+local subprocess = require 'bee.subprocess'
+
+ROOT = fs.current_path()
+package.path = (ROOT / 'src' / '?.lua'):string()
+ .. ';' .. (ROOT / 'src' / '?' / 'init.lua'):string()
+
+local function runTest(root)
+ local exe = root / 'bin' / 'lua-language-server'
+ local test = root / 'test' / 'main.lua'
+ local lua = subprocess.spawn {
+ exe,
+ test,
+ '-E',
+ 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)
+ end
+end
+
+runTest(ROOT)
diff --git a/server/test/crossfile/hover.lua b/server/test/crossfile/hover.lua
index cdc4ebca..41aef8dc 100644
--- a/server/test/crossfile/hover.lua
+++ b/server/test/crossfile/hover.lua
@@ -76,7 +76,8 @@ function TEST(data)
local hover = core.hover(source, lsp)
assert(hover)
if data.hover.description then
- data.hover.description = data.hover.description:gsub('%$ROOT%$', ws:uriEncode(ROOT):gsub('%%', '%%%%'))
+ local uriROOT = ws:uriEncode(ROOT):gsub('%%', '%%%%')
+ data.hover.description = data.hover.description:gsub('%$ROOT%$', uriROOT)
end
if hover.label then
hover.label = hover.label:gsub('\r\n', '\n')