Skip to content

Commit e4a633d

Browse files
authored
Merge pull request #880 from eyal0/dry_run
feat: --dry-run argument to python tools.
2 parents 0c25032 + 28fb81c commit e4a633d

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

tools/parallel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def main() -> None:
5454
help="Keep same order. If set, print outputs in input order; if not, print in completion order."
5555
)
5656
parser.add_argument(
57-
"--dry-run",
57+
"-n", "--dry-run",
5858
action="store_true",
5959
help="Print the command that would be run for each input instead of running it."
6060
)

tools/run_example.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def parse_args() -> argparse.Namespace:
2323
required=True,
2424
help="Path to pcb2gcode binary to run.",
2525
)
26+
parser.add_argument(
27+
"-n", "--dry-run",
28+
action="store_true",
29+
help="Dry run (print the command that would be run instead of running it)",
30+
)
2631
parser.add_argument(
2732
"example_dir",
2833
help="Example directory to run (e.g. a subdir of tests/data/gerbv_example)",
@@ -36,7 +41,7 @@ def main() -> None:
3641
code_coverage_enabled = args.code_coverage
3742
pcb2gcode_binary = args.pcb2gcode_binary
3843
pcb2gcode_binary = os.path.abspath(pcb2gcode_binary)
39-
44+
dry_run = args.dry_run
4045
have_valgrind = shutil.which("valgrind") is not None
4146
return_code = 0
4247
try:
@@ -75,9 +80,13 @@ def main() -> None:
7580
cmd = [pcb2gcode_binary]
7681

7782
start = time.perf_counter()
78-
result = subprocess.run(cmd, cwd=example_dir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
79-
print(result.stdout, end="")
80-
return_code = result.returncode
83+
if dry_run:
84+
print(shlex.join(cmd))
85+
return_code = 0
86+
else:
87+
result = subprocess.run(cmd, cwd=example_dir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
88+
print(result.stdout, end="")
89+
return_code = result.returncode
8190
elapsed = time.perf_counter() - start
8291
print(f"real {elapsed:.3f} seconds")
8392
if return_code != 0:

0 commit comments

Comments
 (0)