Simplify --solver syntax of run_test.py
This commit is contained in:
parent
76de35471f
commit
082a2d8f03
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue