From df12d1a281b21373dfa5f69702f9feb5900f107d Mon Sep 17 00:00:00 2001 From: Jiahui Chen Date: Tue, 17 Nov 2026 12:18:15 -0700 Subject: [PATCH] Runner: a dry run names no file it did not write (#70) --dry-run printed 'done. report: /report.json' and created the run directory, though it ran no stage. It now creates nothing and ends with 'dry run: N stage(s) listed, nothing run, nothing written.' Co-Authored-By: Claude Opus 5.5 --- s2f/run.py | 8 +++++++- tests/test_run.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/s2f/run.py b/s2f/run.py index 68b9b58..8bc60ba 100644 --- a/s2f/run.py +++ b/s2f/run.py @@ -268,7 +268,9 @@ def _record_caps(args: argparse.Namespace, stages: list[str]) -> None: def main(argv: list[str] | None = None) -> int: args = build_parser().parse_args(argv) - Path(args.run).mkdir(parents=True, exist_ok=True) + if not args.dry_run: + # A dry run writes nothing, not even the run directory (#70). + Path(args.run).mkdir(parents=True, exist_ok=True) selected = [(name, mod) for name, mod in STAGES if name not in args.skip and (not args.only or name in args.only)] @@ -297,6 +299,10 @@ def main(argv: list[str] | None = None) -> int: print("WARNING: the M2 ranking is missing weighted components:", file=sys.stderr) for line in missing: print(f" {line}", file=sys.stderr) + if args.dry_run: + # Name no output path a dry run did not write (#70). + print(f"dry run: {len(selected)} stage(s) listed, nothing run, nothing written.") + return 0 print(f"done. report: {Path(args.run) / 'report.json'}") return 0 diff --git a/tests/test_run.py b/tests/test_run.py index 96cec7d..80c7d86 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -70,3 +70,16 @@ def test_a_failed_provider_reports_its_error_and_a_full_run_is_quiet(tmp_path) - def test_no_m2_manifest_means_no_warning(tmp_path) -> None: assert missing_evidence(str(tmp_path)) == [] + + +def test_a_dry_run_writes_nothing_and_claims_no_report(tmp_path, capsys) -> None: + # #70: a dry run used to print "done. report: /report.json" for a file it never wrote. + from s2f.run import main + + run_dir = tmp_path / "x" + assert main(["--run", str(run_dir), "--from-cga-dir", "fixtures/m1/cga_sample", "--dry-run"]) == 0 + assert not run_dir.exists() + out = capsys.readouterr().out + assert "=== m1:" in out + assert "report.json" not in out + assert "nothing written" in out