Add --no-loadscope-reorder and --loadscope-reorder options (#1217)

Based on #1098.

Closes #1098

---------

Co-authored-by: Toan Vuong <toan.vuong@hyperscience.com>
This commit is contained in:
darwintree
2025-06-30 21:59:40 +08:00
committed by GitHub
parent 532f07fb18
commit 9d7ba5b5fb
4 changed files with 58 additions and 5 deletions

View File

@@ -371,11 +371,15 @@ class LoadScopeScheduling:
work_unit = unsorted_workqueue.setdefault(scope, {})
work_unit[nodeid] = False
# Insert tests scopes into work queue ordered by number of tests.
for scope, nodeids in sorted(
unsorted_workqueue.items(), key=lambda item: -len(item[1])
):
self.workqueue[scope] = nodeids
if self.config.option.loadscopereorder:
# Insert tests scopes into work queue ordered by number of tests.
for scope, nodeids in sorted(
unsorted_workqueue.items(), key=lambda item: -len(item[1])
):
self.workqueue[scope] = nodeids
else:
for scope, nodeids in unsorted_workqueue.items():
self.workqueue[scope] = nodeids
# Avoid having more workers than work
extra_nodes = len(self.nodes) - len(self.workqueue)