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",
|
parser.add_argument("--solver",
|
||||||
action="append",
|
action="append",
|
||||||
type=str,
|
type=str,
|
||||||
nargs=3,
|
metavar="CMD",
|
||||||
metavar=("NAME", "TYPE", "CMD"),
|
help="add a solver with DIMACS input/output"
|
||||||
help="add a solver; NAME is a label;"
|
" (CMD is the command to run the solver)")
|
||||||
" TYPE is either 'dimacs' or 'wmatch';"
|
parser.add_argument("--solver-wmatch",
|
||||||
" CMD is the command to run the solver")
|
action="append",
|
||||||
|
type=str,
|
||||||
|
metavar="CMD",
|
||||||
|
help="add a WMATCH solver"
|
||||||
|
" (CMD is the solver executable)")
|
||||||
parser.add_argument("--timeout",
|
parser.add_argument("--timeout",
|
||||||
action="store",
|
action="store",
|
||||||
type=float,
|
type=float,
|
||||||
|
@ -783,19 +787,21 @@ def main() -> int:
|
||||||
parser.print_help(sys.stderr)
|
parser.print_help(sys.stderr)
|
||||||
return 1
|
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)
|
print("ERROR: Specify at least one solver", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
solvers: list[Solver] = []
|
solvers: list[Solver] = []
|
||||||
for (name, typ, cmd) in args.solver:
|
if args.solver:
|
||||||
if typ.lower() == "dimacs":
|
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))
|
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))
|
solvers.append(WmatchSolver(name, cmd, args.timeout))
|
||||||
else:
|
|
||||||
print("ERROR: Unknown solver type {type!r}", file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
if args.runs < 1:
|
if args.runs < 1:
|
||||||
print("ERROR: Number of runs must be >= 1", file=sys.stderr)
|
print("ERROR: Number of runs must be >= 1", file=sys.stderr)
|
||||||
|
|
Loading…
Reference in New Issue