diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/client/init.lua | 1 | ||||
-rw-r--r-- | test/client/lclient.lua | 61 | ||||
-rw-r--r-- | test/client/tests/single-mode.lua | 0 |
3 files changed, 62 insertions, 0 deletions
diff --git a/test/client/init.lua b/test/client/init.lua new file mode 100644 index 00000000..af373a30 --- /dev/null +++ b/test/client/init.lua @@ -0,0 +1 @@ +require 'client.tests.single-mode' diff --git a/test/client/lclient.lua b/test/client/lclient.lua new file mode 100644 index 00000000..ecf9f539 --- /dev/null +++ b/test/client/lclient.lua @@ -0,0 +1,61 @@ +local gc = require 'gc' +local util = require 'utility' + +---@class languageClient +---@field _inFile file* +---@field _outFile file* +---@field _gc gc +local mt = {} +mt.__index = mt + +function mt:__close() + self:remove() +end + +function mt:_openIO() + local r = math.random(1, 10000) + self._inPath = ('%s/%s.in'):format(LOGPATH, r) + self._outPath = ('%s/%s.out'):format(LOGPATH, r) + local stdin = io.open(self._inPath, 'rb') + local stdout = io.open(self._outPath, 'wb') + self._inFile = io.open(self._inPath, 'wb') + self._outFile = io.open(self._outPath, 'rb') + io.stdin = stdin + io.stdout = stdout + self:gc(function () + stdin:close() + stdout:close() + self._inFile:close() + self._outFile:close() + end) +end + +function mt:_flushServer() + -- reset scopes + local ws = require 'workspace' + local scope = require 'workspace.scope' + local files = require 'files' + ws.reset() + scope.reset() + files.reset() +end + +function mt:start() + self:_openIO() + self:_flushServer() +end + +function mt:gc(obj) + return self._gc:add(obj) +end + +function mt:remove() + self._gc:remove() +end + +return function () + local self = setmetatable({ + _gc = gc(), + }, mt) + return self +end diff --git a/test/client/tests/single-mode.lua b/test/client/tests/single-mode.lua new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/client/tests/single-mode.lua |