44 ) -> list[int]:
45 stale_indices = []
46
47
48 total_gc = tests_that_ran
49 for method in tests_that_didnt_run:
50 total_gc = total_gc.plus(method, WithinTestGC().keep_all())
51
52 gc_roots = total_gc.items()
53 keys = snapshots.keys()
54
55 gc_idx = 0
56 key_idx = 0
57 while key_idx < len(keys) and gc_idx < len(gc_roots):
58 key: str = keys[key_idx]
59 gc: tuple[str, WithinTestGC] = gc_roots[gc_idx]
60 if key.startswith(gc[0]):
61 if len(key) == len(gc[0]):
62
63 if not gc[1].keeps(""):
64 stale_indices.append(key_idx)
65 key_idx += 1
66 continue
67 elif key[len(gc[0])] == "/":
68
69 suffix = key[len(gc[0]) :]
70 if not gc[1].keeps(suffix):
71 stale_indices.append(key_idx)
72 key_idx += 1
73 continue
74 else:
75
76 gc_idx += 1
77 continue
78 else:
79
80 if gc[0] < key:
81 gc_idx += 1
82 else:
83
84 stale_indices.append(key_idx)
85 key_idx += 1
86
87 while key_idx < len(keys):
88 stale_indices.append(key_idx)
89 key_idx += 1
90
91 return stale_indices