summaryrefslogtreecommitdiff
path: root/xmake/actions
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-21 22:40:04 +0800
committerruki <[email protected]>2025-10-21 22:40:04 +0800
commit75b151516891d2ef7a56a24fd0938e415d398627 (patch)
tree1111c6a6b203dcbb22380f503661ad0d02ccbcb5 /xmake/actions
parent405221a5f79cda33cab7df2694a3ee818d188168 (diff)
add realtime_output for tests #6947tests
Diffstat (limited to 'xmake/actions')
-rw-r--r--xmake/actions/test/main.lua25
1 files changed, 17 insertions, 8 deletions
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index 457aae33a..8a917678b 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -61,23 +61,28 @@ function _do_test_target(target, opt)
local logname = opt.name:gsub("[/\\>=<|%*]", "_")
local outfile = path.absolute(path.join(autogendir, logname .. ".out"))
local errfile = path.absolute(path.join(autogendir, logname .. ".err"))
- os.tryrm(outfile)
- os.tryrm(errfile)
+ if opt.realtime_output then
+ outfile = nil
+ errfile = nil
+ assert(not opt.pass_outputs and not opt.fail_outputs, "add_tests(%s): we cannot check pass_outputs/fail_outputs in real output mode", opt.name)
+ else
+ os.tryrm(outfile)
+ os.tryrm(errfile)
+ end
os.mkdir(autogendir)
-
local should_fail = opt.should_fail or false
local run_timeout = opt.run_timeout
local ok, syserrors = os.execv(targetfile, runargs, {try = true, timeout = run_timeout,
curdir = rundir, envs = envs, stdout = outfile, stderr = errfile})
- local outdata = os.isfile(outfile) and io.readfile(outfile) or ""
- local errdata = os.isfile(errfile) and io.readfile(errfile) or ""
+ local outdata = (outfile and os.isfile(outfile)) and io.readfile(outfile) or ""
+ local errdata = (errfile and os.isfile(errfile)) and io.readfile(errfile) or ""
if outdata and #outdata > 0 then
opt.stdout = outdata
end
if errdata and #errdata > 0 then
opt.stderr = errdata
end
- if opt.trim_output then
+ if opt.trim_output and outdata then
outdata = outdata:trim()
end
if ok ~= 0 then
@@ -93,8 +98,12 @@ function _do_test_target(target, opt)
end
end
end
- os.tryrm(outfile)
- os.tryrm(errfile)
+ if outfile then
+ os.tryrm(outfile)
+ end
+ if errfile then
+ os.tryrm(errfile)
+ end
local passed
if ok == 0 then