summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-24 17:03:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-24 17:03:18 +0800
commitef6c3fe05addbd299e4fc6e45cec94a83886c18f (patch)
tree9e526e2c558fab376874172aa51a00e800d4ce4b /test
parentb7344640a0ab9a07551ee5ebc435657b45659553 (diff)
downloadlua-language-server-ef6c3fe05addbd299e4fc6e45cec94a83886c18f.zip
cleanup
Diffstat (limited to 'test')
-rw-r--r--test/basic/noder.lua2
-rw-r--r--test/code_action/init.lua3
-rw-r--r--test/command/auto-require.lua2
-rw-r--r--test/completion/init.lua3
-rw-r--r--test/crossfile/completion.lua8
-rw-r--r--test/crossfile/definition.lua8
-rw-r--r--test/crossfile/diagnostic.lua9
-rw-r--r--test/crossfile/hover.lua8
-rw-r--r--test/crossfile/references.lua8
-rw-r--r--test/definition/init.lua3
-rw-r--r--test/diagnostics/init.lua3
-rw-r--r--test/document_symbol/init.lua2
-rw-r--r--test/full/example.lua2
-rw-r--r--test/full/projects.lua11
-rw-r--r--test/full/self.lua10
-rw-r--r--test/highlight/init.lua2
-rw-r--r--test/hover/init.lua2
-rw-r--r--test/references/init.lua2
-rw-r--r--test/rename/init.lua2
-rw-r--r--test/signature/init.lua2
-rw-r--r--test/type_formatting/init.lua2
-rw-r--r--test/type_inference/init.lua2
22 files changed, 67 insertions, 29 deletions
diff --git a/test/basic/noder.lua b/test/basic/noder.lua
index 87b34e12..49585ee8 100644
--- a/test/basic/noder.lua
+++ b/test/basic/noder.lua
@@ -30,7 +30,6 @@ end
local CARE = {}
local function TEST(script)
return function (expect)
- files.removeAll()
local newScript, catched = catch(script, '?')
files.setText('', newScript)
local source = getSource(catched['?'][1][1])
@@ -44,6 +43,7 @@ local function TEST(script)
for key in pairs(CARE) do
assert(result[key] == expect[key])
end
+ files.remove('')
end
end
diff --git a/test/code_action/init.lua b/test/code_action/init.lua
index 70d8c9ec..01423850 100644
--- a/test/code_action/init.lua
+++ b/test/code_action/init.lua
@@ -38,13 +38,12 @@ end
function TEST(script)
return function (expect)
- files.removeAll()
-
local newScript, catched = catch(script, '?')
files.setText('', newScript)
local results = core('', catched['?'][1][1], catched['?'][1][2])
assert(results)
assert(eq(expect, results))
+ files.remove('')
end
end
diff --git a/test/command/auto-require.lua b/test/command/auto-require.lua
index 8543a6ab..9dd19bd2 100644
--- a/test/command/auto-require.lua
+++ b/test/command/auto-require.lua
@@ -16,12 +16,12 @@ end
function TEST(text)
return function (name)
return function (expect)
- files.removeAll()
files.setText('', text)
EditResult = nil
local row, fmt = findInsertRow('')
applyAutoRequire('', row, name, name, fmt)
assert(util.equal(EditResult, expect))
+ files.remove('')
end
end
end
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 11d39252..52b5f02c 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -65,7 +65,6 @@ ContinueTyping = false
function TEST(script)
return function (expect)
---@diagnostic disable: await-in-sync
- files.removeAll()
local newScript, catched = catch(script, '?')
files.setText('', newScript)
@@ -77,6 +76,8 @@ function TEST(script)
end
local triggerCharacter = script:sub(inputPos, inputPos)
local result = core.completion('', inputPos, triggerCharacter)
+
+ files.remove('')
if not expect then
assert(result == nil)
return
diff --git a/test/crossfile/completion.lua b/test/crossfile/completion.lua
index c608ccab..d286a24d 100644
--- a/test/crossfile/completion.lua
+++ b/test/crossfile/completion.lua
@@ -82,8 +82,6 @@ end
---@diagnostic disable: await-in-sync
function TEST(data)
- files.removeAll()
-
local mainUri
local pos
for _, info in ipairs(data) do
@@ -98,6 +96,12 @@ function TEST(data)
files.setText(uri, script)
end
+ local _ <close> = function ()
+ for _, info in ipairs(data) do
+ files.remove(furi.encode(info.path))
+ end
+ end
+
local expect = data.completion
core.clearCache()
local result = core.completion(mainUri, pos, '')
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index c9a95658..8cf6234f 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -27,8 +27,6 @@ local function founded(targets, results)
end
function TEST(datas)
- files.removeAll()
-
local targetList = {}
local sourceList
local sourceUri
@@ -56,6 +54,12 @@ function TEST(datas)
files.setText(uri, newScript)
end
+ local _ <close> = function ()
+ for _, info in ipairs(datas) do
+ files.remove(furi.encode(info.path))
+ end
+ end
+
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
local positions = core(sourceUri, sourcePos)
if positions then
diff --git a/test/crossfile/diagnostic.lua b/test/crossfile/diagnostic.lua
index 9bdce197..ab2c3e41 100644
--- a/test/crossfile/diagnostic.lua
+++ b/test/crossfile/diagnostic.lua
@@ -31,8 +31,6 @@ end
---@diagnostic disable: await-in-sync
function TEST(datas)
- files.removeAll()
-
local targetList = {}
for _, data in ipairs(datas) do
local uri = furi.encode(data.path)
@@ -48,6 +46,13 @@ function TEST(datas)
files.setText(uri, newScript)
end
+ local _ <close> = function ()
+ for _, info in ipairs(datas) do
+ files.remove(furi.encode(info.path))
+ end
+ end
+
+
local result = {}
for _, data in ipairs(datas) do
local uri = furi.encode(data.path)
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 492efe43..cb9e83aa 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -39,8 +39,6 @@ end
---@diagnostic disable: await-in-sync
function TEST(expect)
- files.removeAll()
-
local sourcePos, sourceUri
for _, file in ipairs(expect) do
local script, list = catch(file.content, '?')
@@ -52,6 +50,12 @@ function TEST(expect)
end
end
+ local _ <close> = function ()
+ for _, info in ipairs(expect) do
+ files.remove(furi.encode(info.path))
+ end
+ end
+
local hover = core.byUri(sourceUri, sourcePos)
assert(hover)
hover = tostring(hover):gsub('\r\n', '\n')
diff --git a/test/crossfile/references.lua b/test/crossfile/references.lua
index 145792b5..ec02eef7 100644
--- a/test/crossfile/references.lua
+++ b/test/crossfile/references.lua
@@ -53,8 +53,6 @@ local function founded(targets, results)
end
function TEST(datas)
- files.removeAll()
-
local targetList = {}
local sourceList
local sourceUri
@@ -77,6 +75,12 @@ function TEST(datas)
files.setText(uri, newScript)
end
+ local _ <close> = function ()
+ for _, info in ipairs(datas) do
+ files.remove(furi.encode(info.path))
+ end
+ end
+
local sourcePos = (sourceList[1][1] + sourceList[1][2]) // 2
local positions = core(sourceUri, sourcePos)
if positions then
diff --git a/test/definition/init.lua b/test/definition/init.lua
index 2e87b0c2..fc2903c1 100644
--- a/test/definition/init.lua
+++ b/test/definition/init.lua
@@ -22,7 +22,6 @@ local function founded(targets, results)
end
function TEST(script)
- files.removeAll()
local newScript, catched = catch(script, '!?')
files.setText('', newScript)
@@ -39,6 +38,8 @@ function TEST(script)
else
assert(catched['!'] == nil)
end
+
+ files.remove('')
end
require 'definition.local'
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 16c85a63..8c8dbcf6 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -28,7 +28,6 @@ end
---@diagnostic disable: await-in-sync
function TEST(script, ...)
- files.removeAll()
local newScript, catched = catch(script, '!')
files.setText('', newScript)
files.open('')
@@ -50,6 +49,8 @@ function TEST(script, ...)
else
assert(catched['!'] == nil)
end
+
+ files.remove('')
end
TEST [[
diff --git a/test/document_symbol/init.lua b/test/document_symbol/init.lua
index 1324f29c..4ce75573 100644
--- a/test/document_symbol/init.lua
+++ b/test/document_symbol/init.lua
@@ -48,11 +48,11 @@ end
---@diagnostic disable: await-in-sync
function TEST(script)
return function (expect)
- files.removeAll()
files.setText('', script)
local result = core('')
assert(eq(expect, result))
checkArcoss(result)
+ files.remove('')
end
end
diff --git a/test/full/example.lua b/test/full/example.lua
index c0ce23ee..cae2df07 100644
--- a/test/full/example.lua
+++ b/test/full/example.lua
@@ -51,7 +51,6 @@ local function testIfExit(path)
local max = 100
local need
for i = 1, max do
- files.removeAll()
files.open('')
files.setText('', buf)
diag('', function () end)
@@ -60,6 +59,7 @@ local function testIfExit(path)
need = passed / i
break
end
+ files.remove('')
end
print(('基准诊断测试[%s]单次耗时:%.10f'):format(path:filename():string(), need))
end
diff --git a/test/full/projects.lua b/test/full/projects.lua
index 7beaa026..4a8ef62a 100644
--- a/test/full/projects.lua
+++ b/test/full/projects.lua
@@ -14,13 +14,13 @@ config.set(nil, 'Lua.diagnostics.neededFileStatus', {
---@diagnostic disable: await-in-sync
local function doProjects(pathname)
- files.removeAll()
-
local path = fs.path(pathname)
if not fs.exists(path) then
return
end
+ local uris = {}
+
print('基准诊断目录:', path)
fsu.scanDirectory(path, function (path)
if path:extension():string() ~= '.lua' then
@@ -30,8 +30,15 @@ local function doProjects(pathname)
local text = fsu.loadFile(path)
files.setText(uri, text)
files.open(uri)
+ uris[#uris+1] = uri
end)
+ local _ <close> = function ()
+ for _, uri in ipairs(uris) do
+ files.remove(uri)
+ end
+ end
+
print('开始诊断...')
ws.ready = true
diff --git a/test/full/self.lua b/test/full/self.lua
index b2c74271..0c148a91 100644
--- a/test/full/self.lua
+++ b/test/full/self.lua
@@ -4,10 +4,11 @@ local furi = require 'file-uri'
local diag = require 'provider.diagnostic'
local config = require 'config'
local ws = require 'workspace'
-files.removeAll()
local path = ROOT / 'script'
+local uris = {}
+
fsu.scanDirectory(path, function (path)
if path:extension():string() ~= '.lua' then
return
@@ -16,8 +17,15 @@ fsu.scanDirectory(path, function (path)
local text = fsu.loadFile(path)
files.setText(uri, text)
files.open(uri)
+ uris[#uris+1] = uri
end)
+local _ <close> = function ()
+ for _, uri in ipairs(uris) do
+ files.remove(uri)
+ end
+end
+
print('基准诊断目录:', path)
ws.ready = true
diff --git a/test/highlight/init.lua b/test/highlight/init.lua
index 7faa9e08..8e07c5f0 100644
--- a/test/highlight/init.lua
+++ b/test/highlight/init.lua
@@ -19,7 +19,6 @@ local function founded(targets, results)
end
function TEST(script)
- files.removeAll()
local newScript, catched = catch(script, '!')
files.setText('', newScript)
for _, enter in ipairs(catched['!']) do
@@ -32,6 +31,7 @@ function TEST(script)
end
assert(founded(catched['!'], results))
end
+ files.remove('')
end
TEST [[
diff --git a/test/hover/init.lua b/test/hover/init.lua
index 35274384..c0d5bc94 100644
--- a/test/hover/init.lua
+++ b/test/hover/init.lua
@@ -23,7 +23,6 @@ local accept = {
---@diagnostic disable: await-in-sync
function TEST(script)
return function (expect)
- files.removeAll()
local newScript, catched = catch(script, '?')
files.setText('', newScript)
local hover = core.byUri('', catched['?'][1][1])
@@ -31,6 +30,7 @@ function TEST(script)
expect = expect:gsub('^[\r\n]*(.-)[\r\n]*$', '%1'):gsub('\r\n', '\n')
local label = tostring(hover):match('```lua[\r\n]*(.-)[\r\n]*```'):gsub('\r\n', '\n')
assert(expect == label)
+ files.remove('')
end
end
diff --git a/test/references/init.lua b/test/references/init.lua
index 351c80b6..81dfb481 100644
--- a/test/references/init.lua
+++ b/test/references/init.lua
@@ -19,7 +19,6 @@ local function founded(targets, results)
end
function TEST(script)
- files.removeAll()
local newScript, catched = catch(script, '!?~')
files.setText('', newScript)
@@ -35,6 +34,7 @@ function TEST(script)
else
assert(#expect == 0)
end
+ files.remove('')
end
require 'references.common'
diff --git a/test/rename/init.lua b/test/rename/init.lua
index 29e6f1a6..c4108df2 100644
--- a/test/rename/init.lua
+++ b/test/rename/init.lua
@@ -25,7 +25,6 @@ end
function TEST(oldName, newName)
return function (oldScript)
return function (expectScript)
- files.removeAll()
files.setText('', oldScript)
local state = files.getState('')
local offset = oldScript:find('[^%w_]'..oldName..'[^%w_]')
@@ -38,6 +37,7 @@ function TEST(oldName, newName)
script = replace(script, positions)
end
assert(script == expectScript)
+ files.remove('')
end
end
end
diff --git a/test/signature/init.lua b/test/signature/init.lua
index aa9d9094..34aed96d 100644
--- a/test/signature/init.lua
+++ b/test/signature/init.lua
@@ -9,7 +9,6 @@ function TEST(script)
return function (expect)
local newScript, catched1 = catch(script, '?')
local newExpect, catched2 = catch(expect or '', '!')
- files.removeAll()
files.setText('', newScript)
local hovers = core('', catched1['?'][1][1])
if hovers then
@@ -24,6 +23,7 @@ function TEST(script)
else
assert(expect == nil)
end
+ files.remove('')
end
end
diff --git a/test/type_formatting/init.lua b/test/type_formatting/init.lua
index 46b8223d..363303cc 100644
--- a/test/type_formatting/init.lua
+++ b/test/type_formatting/init.lua
@@ -7,7 +7,6 @@ rawset(_G, 'TEST', true)
function TEST(script)
return function (expect)
- files.removeAll()
local newScript, catched = catch(script, '?')
files.setText('', newScript)
local edits = core('', catched['?'][1][1], expect.ch)
@@ -17,6 +16,7 @@ function TEST(script)
else
assert(expect.edits == nil)
end
+ files.remove('')
end
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index d62bc607..ef2d1f62 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -23,7 +23,6 @@ end
function TEST(wanted)
return function (script)
- files.removeAll()
local newScript, catched = catch(script, '?')
files.setText('', newScript)
local source = getSource(catched['?'][1][1])
@@ -33,6 +32,7 @@ function TEST(wanted)
infer.searchAndViewInfers(source)
end
assert(wanted == result)
+ files.remove('')
end
end