summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-29 15:52:05 +0800
committerruki <[email protected]>2023-10-29 15:52:05 +0800
commitdd7e24bf55dc45956efa3af0eb3773699b95befb (patch)
tree6be317262c6b01544905bdd99928a951d6731083
parentfc6083f9de382e3c6a6d208e9a388c1af4dd8ea1 (diff)
try to build target in test
-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