Fix CLI test suite pytest flags
- allow pytest flags after core test --suite without requiring separator - preserve strict unknown-argument rejection for non-test commands - add regression coverage for core test --suite packs -q
This commit is contained in:
parent
3d0b632e3b
commit
b4ecf67e35
2 changed files with 35 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ _CORE_RS_DIR = _REPO_ROOT / "core-rs"
|
|||
_CORE_RS_MANIFEST = _CORE_RS_DIR / "Cargo.toml"
|
||||
|
||||
DESCRIPTION = "CORE versor engine command suite."
|
||||
EPILOG = "Examples:\n core chat\n core trace \"word beginning truth\"\n core trace --output-language grc --frame-pack grc --json \"logos\"\n core rust status\n core rust build\n core oov covenant\n core pack list\n core pack verify en_minimal_v1\n core test --suite smoke\n core test --suite cognition\n core test -- tests/test_alignment_graph.py -q"
|
||||
EPILOG = "Examples:\n core chat\n core trace \"word beginning truth\"\n core trace --output-language grc --frame-pack grc --json \"logos\"\n core rust status\n core rust build\n core oov covenant\n core pack list\n core pack verify en_minimal_v1\n core test --suite smoke -q\n core test --suite cognition -q\n core test -- tests/test_alignment_graph.py -q"
|
||||
|
||||
_TEST_SUITES: dict[str, tuple[str, ...]] = {
|
||||
"smoke": (
|
||||
|
|
@ -556,7 +556,12 @@ def _print_version() -> None:
|
|||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(list(argv) if argv is not None else None)
|
||||
raw_args = list(argv) if argv is not None else sys.argv[1:]
|
||||
args, unknown = parser.parse_known_args(raw_args)
|
||||
if unknown:
|
||||
if getattr(args, "command", None) != "test":
|
||||
parser.error(f"unrecognized arguments: {' '.join(unknown)}")
|
||||
args.args = [*(getattr(args, "args", None) or ()), *unknown]
|
||||
if args.version:
|
||||
_print_version()
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from core import cli
|
||||
|
||||
|
||||
|
|
@ -38,6 +40,27 @@ def test_core_test_suite_expands_to_expected_pytest_paths(monkeypatch) -> None:
|
|||
assert "-q" in command
|
||||
|
||||
|
||||
def test_core_test_suite_accepts_pytest_flags_without_separator(monkeypatch) -> None:
|
||||
calls: list[tuple[str, ...]] = []
|
||||
|
||||
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
||||
calls.append(args)
|
||||
return 0
|
||||
|
||||
monkeypatch.setattr(cli, "_run", fake_run)
|
||||
|
||||
rc = cli.main(["test", "--suite", "packs", "-q"])
|
||||
|
||||
assert rc == 0
|
||||
assert calls[0] == (
|
||||
cli.sys.executable,
|
||||
"-m",
|
||||
"pytest",
|
||||
"tests/test_core_semantic_seed_pack.py",
|
||||
"-q",
|
||||
)
|
||||
|
||||
|
||||
def test_core_test_passthrough_still_accepts_arbitrary_pytest_args(monkeypatch) -> None:
|
||||
calls: list[tuple[str, ...]] = []
|
||||
|
||||
|
|
@ -57,3 +80,8 @@ def test_core_test_passthrough_still_accepts_arbitrary_pytest_args(monkeypatch)
|
|||
"tests/test_core_semantic_seed_pack.py",
|
||||
"-q",
|
||||
)
|
||||
|
||||
|
||||
def test_non_test_commands_still_reject_unknown_args() -> None:
|
||||
with pytest.raises(SystemExit):
|
||||
cli.main(["pack", "list", "-q"])
|
||||
|
|
|
|||
Loading…
Reference in a new issue