summaryrefslogtreecommitdiff
path: root/tests/modules/async
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-22 22:28:30 +0800
committerruki <[email protected]>2025-04-08 15:31:55 +0800
commitd31fc3eb8ade62b0d80280f22329bb132ea95cfc (patch)
treeaebe55d824afaf6568e9973e7a6e9bc646cddf15 /tests/modules/async
parenta260aa4d879b459aeaf3526816f1bc474485f508 (diff)
support for job group
Diffstat (limited to 'tests/modules/async')
-rw-r--r--tests/modules/async/run_jobgraph.lua26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/modules/async/run_jobgraph.lua b/tests/modules/async/run_jobgraph.lua
index a3e1edeb3..bc1b5500f 100644
--- a/tests/modules/async/run_jobgraph.lua
+++ b/tests/modules/async/run_jobgraph.lua
@@ -10,8 +10,8 @@ function _jobfunc(index, total, opt)
print("%s: run job (%d/%d) end, progress: %s, dt: %d ms", scheduler.co_running(), index, total, opt.progress, dt)
end
-function main()
- print("==================================== test jobgraph ====================================")
+function _test_basic()
+ print("==================================== test basic ====================================")
local jobs = jobgraph.new()
jobs:add("job/root", _jobfunc)
for i = 1, 3 do
@@ -27,3 +27,25 @@ function main()
end})
end
+function _test_group()
+ print("==================================== test group ====================================")
+ local jobs = jobgraph.new()
+ jobs:add("job/root", _jobfunc)
+ for i = 1, 3 do
+ jobs:add("job/" .. i, _jobfunc, {groups = "bar"})
+ for j = 1, 50 do
+ jobs:add("job/" .. i .. "/" .. j, _jobfunc, {groups = "foo"})
+ end
+ end
+ jobs:add_deps("foo", "bar", "job/root")
+ t = os.mclock()
+ runjobs("test", jobs, {comax = 6, timeout = 1000, timer = function (running_jobs_indices)
+ print("%s: timeout (%d ms), running: %s", scheduler.co_running(), os.mclock() - t, table.concat(running_jobs_indices, ","))
+ end})
+end
+
+function main()
+ _test_basic()
+ _test_group()
+end
+