summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/actions/test/main.lua30
1 files 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