diff --git a/changelog.md b/changelog.md index f948369b6..ea6bb97b7 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## Unreleased +* `NEW` Test CLI: `--name=` `-n=`: 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 diff --git a/test.lua b/test.lua index 1ede0b3ed..bd1d8cb06 100644 --- a/test.lua +++ b/test.lua @@ -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' @@ -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