diff --git a/src/steerbench/cli.py b/src/steerbench/cli.py index 9e85f3d..caa7a0c 100644 --- a/src/steerbench/cli.py +++ b/src/steerbench/cli.py @@ -114,6 +114,9 @@ def main(argv: list[str] | None = None) -> int: parser = _build_parser() args, extra = parser.parse_known_args(argv) + if not args.stem.strip(): + parser.error("output stem must not be empty") + if args.run: return _run_modal(args.run, extra) diff --git a/tests/test_cli.py b/tests/test_cli.py index 87c3f7e..686ae11 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -89,3 +89,26 @@ def test_cli_errors_on_missing_named_side_csv( ) assert exc.value.code != 0 assert "side-effects CSV not found" in capsys.readouterr().err + + +@pytest.mark.parametrize("stem", ["", " "]) +def test_cli_errors_on_empty_stem( + stem: str, tmp_path: Path, capsys: pytest.CaptureFixture[str] +) -> None: + # An empty or whitespace-only --stem would write cryptic dotfiles + # (".md", ".html", ".png"); it must fail fast instead. + with pytest.raises(SystemExit) as exc: + cli.main( + [ + "--dose-csv", + str(_DOSE), + "--layer-csv", + str(_LAYER), + "--out", + str(tmp_path / "o"), + "--stem", + stem, + ] + ) + assert exc.value.code != 0 + assert "output stem must not be empty" in capsys.readouterr().err