From dd7e24bf55dc45956efa3af0eb3773699b95befb Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 29 Oct 2023 15:52:05 +0800 Subject: try to build target in test --- xmake/actions/test/main.lua | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua index ea1187084..56a52ad0b 100644 --- a/xmake/actions/test/main.lua +++ b/xmake/actions/test/main.lua @@ -304,6 +304,23 @@ function _run_tests(tests) end end +-- try to build the given target +function _try_build_target(targetname) + local errors + local passed = try { + function () + build_action.build_targets(targetname) + return true + end, + catch { + function (errs) + errors = tostring(errs) + end + } + } + return passed, errors +end + function main() -- do action for remote? @@ -368,18 +385,7 @@ function main() for _, testinfo in table.orderpairs(tests) do local targetname = testinfo.target:name() if testinfo.build_only then - local errors - local passed = try { - function () - build_action.build_targets(targetname) - return true - end, - catch { - function (errs) - errors = tostring(errs) - end - } - } + local passed, errors = _try_build_target(targetname) testinfo.passed = passed testinfo.errors = errors else -- cgit v1.3.1