File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 5858}
5959
6060
61- def should_run (nodeid : str , num_shards : int , shard_index : int ) -> bool :
61+ def find_shard_index (nodeid : str , num_shards : int ) -> int :
6262 """
63- Return true if this test should run on this shard
63+ Return the index of the shard that should run this test
6464 """
6565 for prefix , target_shard_idx in FIXED_ALLOCATION_PREFIXES .items ():
6666 if nodeid .startswith (prefix ):
6767 if target_shard_idx >= num_shards :
6868 raise RuntimeError (
6969 f"Cannot collect sharded tests, { nodeid } has hardcoded shard index { target_shard_idx } among only { num_shards } shards"
7070 )
71- return target_shard_idx == shard_index
71+ return target_shard_idx
7272
7373 if nodeid in HARDCODED_ALLOCATIONS :
7474 hash = HARDCODED_ALLOCATIONS [nodeid ]
@@ -89,5 +89,10 @@ def pytest_collection_modifyitems(config, items):
8989
9090 print (f"Marking tests for shard { shard_index } of { num_shards } " )
9191 for item in items :
92- if not should_run (item .nodeid , num_shards = num_shards , shard_index = shard_index ):
93- item .add_marker (pytest .mark .skip ())
92+ item_shard_index = find_shard_index (item .nodeid , num_shards = num_shards )
93+ item .add_marker (
94+ pytest .mark .skipif (
95+ item_shard_index != shard_index ,
96+ reason = f"Test running on shard { item_shard_index } of { num_shards } " ,
97+ )
98+ )
You can’t perform that action at this time.
0 commit comments