From 009876aa7b25abca1b858b63d7840f256010a05b Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 6 Dec 2022 11:38:56 +0100 Subject: [PATCH] Allow directories as test arguments --- test.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test.py b/test.py index 55f2690..b306d7d 100755 --- a/test.py +++ b/test.py @@ -11,12 +11,20 @@ MAGENTA = "\033[1;35m" RED = "\033[1;31m" +def find_solution(path, solutions): + if path.suffix == ".input": + solutions[path] = path.parent / (path.stem + ".solution") + + def find_solutions(paths): - pairs = {} + solutions = {} for path in paths: - if path.suffix == ".input": - pairs[path] = path.parent / (path.stem + ".solution") - return pairs + if path.is_dir(): + for subpath in path.glob("**/*.input"): + find_solution(subpath, solutions) + else: + find_solution(path, solutions) + return solutions def main():