xmake run test
This commit is contained in:
10
README.md
10
README.md
@@ -50,6 +50,16 @@ $ xmake
|
|||||||
|
|
||||||
We need install [lua](https://www.lua.org/) or [luajit](http://luajit.org/) to run tests first.
|
We need install [lua](https://www.lua.org/) or [luajit](http://luajit.org/) to run tests first.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ xmake run test dialog
|
||||||
|
$ xmake run test window
|
||||||
|
$ xmake run test desktop
|
||||||
|
$ xmake run test inputdialog
|
||||||
|
$ xmake run test mconfdialog
|
||||||
|
```
|
||||||
|
|
||||||
|
Or
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ lua tests\dialog.lua
|
$ lua tests\dialog.lua
|
||||||
$ lua tests\window.lua
|
$ lua tests\window.lua
|
||||||
|
10
README_zh.md
10
README_zh.md
@@ -49,6 +49,16 @@ $ xmake
|
|||||||
|
|
||||||
你需要先安装[lua](https://www.lua.org/)或者[luajit](http://luajit.org/)程序去加载运行测试程序:
|
你需要先安装[lua](https://www.lua.org/)或者[luajit](http://luajit.org/)程序去加载运行测试程序:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ xmake run test dialog
|
||||||
|
$ xmake run test window
|
||||||
|
$ xmake run test desktop
|
||||||
|
$ xmake run test inputdialog
|
||||||
|
$ xmake run test mconfdialog
|
||||||
|
```
|
||||||
|
|
||||||
|
或者
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ lua tests\dialog.lua
|
$ lua tests\dialog.lua
|
||||||
$ lua tests\window.lua
|
$ lua tests\window.lua
|
||||||
|
@@ -43,6 +43,36 @@ else
|
|||||||
add_requires("lua", {nolink = not is_plat("windows")})
|
add_requires("lua", {nolink = not is_plat("windows")})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- add target
|
||||||
|
target("test")
|
||||||
|
|
||||||
|
-- only for test
|
||||||
|
set_kind("phony")
|
||||||
|
|
||||||
|
-- default: disable
|
||||||
|
set_default(false)
|
||||||
|
|
||||||
|
-- we need build ltui first
|
||||||
|
add_deps("ltui")
|
||||||
|
|
||||||
|
-- run tests
|
||||||
|
on_run(function (target)
|
||||||
|
|
||||||
|
-- imports
|
||||||
|
import("core.base.option")
|
||||||
|
import("lib.detect.find_tool")
|
||||||
|
|
||||||
|
-- do run
|
||||||
|
local lua = has_config("luajit") and find_tool("luajit") or find_tool("lua")
|
||||||
|
if lua then
|
||||||
|
os.cd(os.projectdir())
|
||||||
|
local testname = table.wrap(option.get("arguments"))[1] or "mconfdialog"
|
||||||
|
os.execv(lua.program, {path.join("tests", testname .. ".lua")})
|
||||||
|
else
|
||||||
|
raise("%s not found!", has_config("luajit") and "luajit" or "lua")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- add target
|
-- add target
|
||||||
target("ltui")
|
target("ltui")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user