From 082a2d8f0331b7289bf0b37f9b2b65e1b4a7e9bf Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Fri, 16 Jun 2023 20:09:18 +0200 Subject: [PATCH] Simplify --solver syntax of run_test.py --- tests/run_test.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/run_test.py b/tests/run_test.py index 7d1dcb6..6453641 100755 --- a/tests/run_test.py +++ b/tests/run_test.py @@ -728,11 +728,15 @@ def main() -> int: parser.add_argument("--solver", action="append", type=str, - nargs=3, - metavar=("NAME", "TYPE", "CMD"), - help="add a solver; NAME is a label;" - " TYPE is either 'dimacs' or 'wmatch';" - " CMD is the command to run the solver") + metavar="CMD", + help="add a solver with DIMACS input/output" + " (CMD is the command to run the solver)") + parser.add_argument("--solver-wmatch", + action="append", + type=str, + metavar="CMD", + help="add a WMATCH solver" + " (CMD is the solver executable)") parser.add_argument("--timeout", action="store", type=float, @@ -783,19 +787,21 @@ def main() -> int: parser.print_help(sys.stderr) return 1 - if not args.solver: + if (not args.solver) and (not args.solver_wmatch): print("ERROR: Specify at least one solver", file=sys.stderr) return 1 solvers: list[Solver] = [] - for (name, typ, cmd) in args.solver: - if typ.lower() == "dimacs": + if args.solver: + for cmd in args.solver: + name = shlex.split(cmd)[0] + if name.endswith("python") or name.endswith("python3"): + name = shlex.split(cmd)[1] solvers.append(DimacsSolver(name, cmd, args.timeout)) - elif typ.lower() == "wmatch": + if args.solver_wmatch: + for cmd in args.solver_wmatch: + name = cmd solvers.append(WmatchSolver(name, cmd, args.timeout)) - else: - print("ERROR: Unknown solver type {type!r}", file=sys.stderr) - return 1 if args.runs < 1: print("ERROR: Number of runs must be >= 1", file=sys.stderr)