Skip to content

Commit

Permalink
Merge pull request LuaLS#3013 from fesily/unittest-support-test-speci…
Browse files Browse the repository at this point in the history
…fy-unit

unittest: support test specify unit test
  • Loading branch information
sumneko authored Jan 2, 2025
2 parents fc21ee4 + ddf2788 commit 208542c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `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
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 208542c

Please sign in to comment.