Skip to content

Add a subprocess-layer regression test for import-time CLI breakage #187

Description

@db-tycoon-stephen

Found during review of #178 (T2-4).

The July 31 review of #178 caught a bug where a future schema_version bricked the entire CLI: load_project raised, that propagated through the module-level config = TycoonConfig() at import time, and because Typer imports every command module to build the CLI, the raise landed before argument parsing. tycoon --help, --version, and even init --upgrade all died with a traceback.

That's fixed. What's missing is a test that would catch the class of regression.

Why the current tests can't see it

CliRunner runs in-process. tycoon.config is already imported — in pytest's cwd — before any tmp_path project exists, so the singleton is built against the wrong directory and the import-time failure mode is unobservable by construction.

test_future_schema_version_loads_without_raise does guard the specific mechanism (it fails if the raise returns to load_project), which is worth having. But any new import-time side effect that kills the CLI would ship green.

Suggested test

The repo already has a subprocess layer — tests/test_sources.py, tests/test_e2e_demo_arc.py. Roughly:

def test_future_schema_version_does_not_break_cli(tmp_path):
    (tmp_path / "tycoon.yml").write_text("name: future\nschema_version: 99\n")
    r = subprocess.run([tycoon_bin, "--help"], cwd=tmp_path, capture_output=True, text=True)
    assert r.returncode == 0
    assert "Traceback" not in (r.stdout + r.stderr)

Per the standing convention, CLI-surface behaviour (PATH, Rich rendering, console scripts, exit codes, import-time failures) needs the subprocess layer — in-process Typer tests miss it.


Mirrored in Jira: PTC-112 (Subtask of PTC-84, [Rewrite M2]). Dev work continues here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions