Skip to content

Commit 7ff2ecb

Browse files
committed
dont use string find to identify testcases
1 parent 6779038 commit 7ff2ecb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

bin/tools.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,19 @@ def print_sorted(problems: list[Problem]) -> None:
284284

285285

286286
def split_submissions_and_testcases(s: list[Path]) -> tuple[list[Path], list[Path]]:
287-
# Everything containing data/, .in, or .ans goes into testcases.
287+
# We try to identify testcases by common directory names and common suffixes
288288
submissions = []
289289
testcases = []
290290
for p in s:
291-
ps = str(p)
292-
if "data" in ps or "sample" in ps or "secret" in ps or ".in" in ps or ".ans" in ps:
293-
# Strip potential .ans and .in
294-
if p.suffix in [".ans", ".in"]:
295-
testcases.append(p.with_suffix(""))
296-
else:
297-
testcases.append(p)
291+
testcase_dirs = ["data", "sample", "secret", "fuzz"]
292+
if (
293+
any(part in testcase_dirs for part in p.parts)
294+
or p.suffix in config.KNOWN_DATA_EXTENSIONS
295+
):
296+
# Strip potential suffix
297+
if p.suffix in config.KNOWN_DATA_EXTENSIONS:
298+
p = p.with_suffix("")
299+
testcases.append(p)
298300
else:
299301
submissions.append(p)
300302
return (submissions, testcases)

0 commit comments

Comments
 (0)