diff options
author | xl000 <l_xb@foxmail.com> | 2019-04-17 01:16:12 +0800 |
---|---|---|
committer | xl000 <l_xb@foxmail.com> | 2019-04-17 01:16:12 +0800 |
commit | ae53ebf48299680b8906e848903fb32d56ee90a5 (patch) | |
tree | b4c2c5a410b8cff43e46f22101e372253b6472a5 | |
parent | e676b97ee6c54ac843b51f2d6062689a428f0c28 (diff) | |
download | lua-language-server-ae53ebf48299680b8906e848903fb32d56ee90a5.zip |
Unix-like系统路径问题,osx下测试通过
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | server/publish.lua | 2 | ||||
-rw-r--r-- | server/src/workspace.lua | 4 | ||||
-rw-r--r-- | server/test.lua | 28 | ||||
-rw-r--r-- | server/test/crossfile/hover.lua | 3 |
5 files changed, 36 insertions, 2 deletions
@@ -3,6 +3,7 @@ node_modules .vscode-test /server/log /server/bin +/server/*.so /publish /build/ !*.exe 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') |