summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-21 22:33:24 +0800
committerruki <[email protected]>2025-11-21 11:28:51 +0800
commit44098a2d8c47acdb78abe34c0dc8104ed823cf00 (patch)
tree3da15cdae847f05aed16945a13db1844de830815
parentc68c8d698fdb270b86378567e7fad823a2a7acc2 (diff)
disable multirow progress for xmake test
-rw-r--r--xmake/actions/test/main.lua7
-rw-r--r--xmake/modules/utils/progress.lua45
2 files changed, 52 insertions, 0 deletions
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index 8a917678b..c85895b4d 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -310,6 +310,10 @@ function _run_tests(tests)
return
end
+ -- temporarily switch to scroll mode to avoid progress refresh interference with test output
+ -- @see https://github.com/xmake-io/xmake/issues/7045
+ progress.set_style("scroll")
+
-- do test
local spent = os.mclock()
print("running tests ...")
@@ -353,6 +357,9 @@ function _run_tests(tests)
comax = jobs,
isolate = true})
+ -- restore the original progress style
+ progress.restore_style()
+
-- generate report
spent = os.mclock() - spent
local passed_rate = math.floor(report.passed * 100 / report.total)
diff --git a/xmake/modules/utils/progress.lua b/xmake/modules/utils/progress.lua
index 9cc4c53ac..b6201d5cc 100644
--- a/xmake/modules/utils/progress.lua
+++ b/xmake/modules/utils/progress.lua
@@ -33,6 +33,10 @@ local COLOR_SLOW = "${color.build.progress_slow}"
-- is scroll output?
function _is_scroll()
+ -- if style is forced, use it
+ if _g.forced_style then
+ return _g.forced_style == "scroll"
+ end
local is_scroll = _g.is_scroll
if is_scroll == nil then
local style = project.policy("build.progress_style") or theme.get("text.build.progress_style") or "scroll"
@@ -46,6 +50,10 @@ end
-- is multi-row refresh output?
function _is_multirow_refresh()
+ -- if style is forced, use it
+ if _g.forced_style then
+ return _g.forced_style == "multirow"
+ end
local is_multirow_refresh = _g.is_multirow_refresh
if is_multirow_refresh == nil then
local style = project.policy("build.progress_style") or theme.get("text.build.progress_style")
@@ -59,6 +67,10 @@ end
-- is single-row refresh output?
function _is_singlerow_refresh()
+ -- if style is forced, use it
+ if _g.forced_style then
+ return _g.forced_style == "singlerow"
+ end
local is_singlerow_refresh = _g.is_singlerow_refresh
if is_singlerow_refresh == nil then
local style = project.policy("build.progress_style") or theme.get("text.build.progress_style")
@@ -70,6 +82,39 @@ function _is_singlerow_refresh()
return is_singlerow_refresh
end
+-- set progress style (temporarily override the current style)
+-- @param style "scroll", "singlerow", or "multirow"
+function set_style(style)
+ -- save the original style if not already saved
+ if not _g.saved_style then
+ -- get current effective style
+ if _is_multirow_refresh() then
+ _g.saved_style = "multirow"
+ elseif _is_singlerow_refresh() then
+ _g.saved_style = "singlerow"
+ else
+ _g.saved_style = "scroll"
+ end
+ end
+
+ -- set forced style
+ _g.forced_style = style
+ -- clear cached flags to force recalculation
+ _g.is_scroll = nil
+ _g.is_multirow_refresh = nil
+ _g.is_singlerow_refresh = nil
+end
+
+-- restore progress style (restore the original style from project policy)
+function restore_style()
+ _g.forced_style = nil
+ _g.saved_style = nil
+ -- clear cached flags to force recalculation
+ _g.is_scroll = nil
+ _g.is_multirow_refresh = nil
+ _g.is_singlerow_refresh = nil
+end
+
-- get progress prefix
function _get_progress_prefix()
if not _g.progress_prefix then