Skip to content

Commit

Permalink
Merge branch 'master' into TIMONz1535-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko authored Jan 2, 2025
2 parents e66a8ab + 208542c commit 002f4a8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

local t = f('Smile') --> t is `Smile.Cat`
```
* `NEW` Test CLI: `--name=<testname>` `-n=<testname>`: run specify unit test
* `FIX` Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded.

## 3.13.5
`2024-12-20`
Expand Down
24 changes: 17 additions & 7 deletions script/cli/doc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function getPathDocUpdate()
return section.DOC
end
end
end)
end)
if ok then
local doc_json_dir = doc_json_path:string():gsub('/doc.json', '')
return doc_json_dir, doc_path
Expand Down Expand Up @@ -131,7 +131,7 @@ local function injectBuildScript()
},
{__index = _G}))
if err or not data then
error(err, 0)
error(err, 0)
end
data()
return module
Expand Down Expand Up @@ -193,6 +193,15 @@ function doc.runCLI()

print('root uri = ' .. rootUri)

--- If '--configpath' is specified, get the folder path of the '.luarc.doc.json' configuration file (without the file name)
--- 如果指定了'--configpath',则获取`.luarc.doc.json` 配置文件的文件夹路径(不包含文件名)
--- This option is passed into the callback function of the initialized method in provide.
--- 该选项会被传入到`provide`中的`initialized`方法的回调函数中
local luarcParentUri
if CONFIGPATH then
luarcParentUri = furi.encode(fs.absolute(fs.path(CONFIGPATH)):parent_path():string())
end

util.enableCloseFunction()

local lastClock = os.clock()
Expand All @@ -203,6 +212,7 @@ function doc.runCLI()

client:initialize {
rootUri = rootUri,
luarcParentUri = luarcParentUri,
}
io.write(lang.script('CLI_DOC_INITING'))

Expand All @@ -222,11 +232,11 @@ function doc.runCLI()
if os.clock() - lastClock > 0.2 then
lastClock = os.clock()
local output = '\x0D'
.. ('>'):rep(math.ceil(i / max * 20))
.. ('='):rep(20 - math.ceil(i / max * 20))
.. ' '
.. ('0'):rep(#tostring(max) - #tostring(i))
.. tostring(i) .. '/' .. tostring(max)
.. ('>'):rep(math.ceil(i / max * 20))
.. ('='):rep(20 - math.ceil(i / max * 20))
.. ' '
.. ('0'):rep(#tostring(max) - #tostring(i))
.. tostring(i) .. '/' .. tostring(max)
io.write(output)
end
end)
Expand Down
4 changes: 2 additions & 2 deletions script/lclient.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local defaultClientOptions = {
valueSet = {
define.DiagnosticTag.Unnecessary,
define.DiagnosticTag.Deprecated,
},
},
},
},
},
Expand All @@ -92,7 +92,7 @@ local defaultClientOptions = {
function mt:initialize(params)
local initParams = util.tableMerge(params or {}, defaultClientOptions)
self:awaitRequest('initialize', initParams)
self:notify('initialized')
self:notify('initialized', initParams)
end

function mt:reportHangs()
Expand Down
5 changes: 3 additions & 2 deletions script/provider/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ m.register 'initialize' {

m.register 'initialized'{
---@async
function (_params)
function (params)
local _ <close> = progress.create(workspace.getFirstScope().uri, lang.script.WINDOW_INITIALIZING, 0.5)
m.updateConfig()
--- 传递`.luarc.doc.json`文件所在的文件夹路径
m.updateConfig(params and params.luarcParentUri)
local registrations = {}

if client.getAbility 'workspace.didChangeConfiguration.dynamicRegistration' then
Expand Down
13 changes: 13 additions & 0 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ DEVELOP = true
--TRACE = true
LOGPATH = LOGPATH or (ROOT:string() .. '/log')
METAPATH = METAPATH or (ROOT:string() .. '/meta')
TARGET_TEST_NAME = nil

if arg then
for _, v in pairs(arg) do
if v:sub(1, 3) == "-n=" or v:sub(1, 7) == "--name=" then
TARGET_TEST_NAME = v:sub(v:find('=') + 1)
end
end
end

collectgarbage 'generational'

Expand All @@ -34,7 +43,11 @@ local function loadAllLibs()
assert(require 'lpeglabel')
end

---@param name string
local function test(name)
if TARGET_TEST_NAME and not name:match(TARGET_TEST_NAME) then
return
end
local clock = os.clock()
print(('测试[%s]...'):format(name))
local originRequire = require
Expand Down

0 comments on commit 002f4a8

Please sign in to comment.