blob: a944c8f08f49b33c269cd93bbbb27ca39de9d5f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
local currentPath = debug.getinfo(1, 'S').source:sub(2)
local rootPath = currentPath:gsub('[^/\\]-$', '')
if rootPath == '' then
rootPath = './'
end
package.cpath = rootPath .. 'bin/?.so'
.. ';' .. rootPath .. 'bin/?.dll'
package.path = rootPath .. 'src/?.lua'
.. ';' .. rootPath .. 'src/?/init.lua'
local fs = require 'bee.filesystem'
local subprocess = require 'bee.subprocess'
ROOT = fs.absolute(fs.path(rootPath))
local function runTest(root)
local is_macos = package.cpath:sub(-3) == '.so'
local ext = is_macos and '' or '.exe'
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)
end
end
runTest(ROOT)
|