Skip to content

Commit

Permalink
prevent sharding to more than items count
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorpela committed Mar 20, 2022
1 parent 705a81e commit 1691c3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pabot/pabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,10 @@ def shard_suites(suite_names, pabot_args):
shard_count = pabot_args["shardcount"]
if shard_index > shard_count:
raise DataError(f"Shard index ({shard_index}) greater than shard count ({shard_count}).")
q, r = divmod(len(suite_names), shard_count)
items_count = len(suite_names)
if items_count < shard_count:
raise DataError(f"Not enought items ({items_count}) for shard cound ({shard_count}).")
q, r = divmod(items_count, shard_count)
return suite_names[
(shard_index - 1) * q
+ min(shard_index - 1, r) : shard_index * q
Expand Down

0 comments on commit 1691c3a

Please sign in to comment.