Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion s2f/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: <run>/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
Loading