Skip to content

test: add unit + subprocess tests for the gdb CLI#8

Merged
mohitgargai merged 1 commit intomainfrom
test/cli-coverage
Apr 24, 2026
Merged

test: add unit + subprocess tests for the gdb CLI#8
mohitgargai merged 1 commit intomainfrom
test/cli-coverage

Conversation

@mohitgargai
Copy link
Copy Markdown
Contributor

Summary

Adds the first test suite for this repo. 42 tests, ~0.7s locally, covering the pure-function surface of gdb.cli and gdb.suites that previously had no regression safety net beyond gdb verify as a de-facto integration test.

This was raised as a follow-up in #7 and is a precondition for refactoring any of the CLI glue code with confidence.

Changes

tests/test_suites.py

  • resolve_suite routing for all four v0-* suites.
  • Partition invariants: v0-understanding ∪ v0-generation == v0-all, and ∩ == ∅.
  • Sorted / unique output; static-suite list is safe from caller mutation.
  • Error messages on unknown suites enumerate the valid names.

tests/test_cli_helpers.py

  • _parse_model_spec: plain, aliased, whitespace-tolerant, colon-in-entrypoint (custom provider), missing-colon / unknown-provider errors.
  • _parse_json_dict_arg: None, empty / whitespace, inline JSON, on-disk JSON file via tmp_path, non-dict JSON and wrong-type rejections.
  • _resolve_benchmark_ids: suite path, explicit list, both-given, neither-given, unknown suite.
  • _render_markdown_report: empty results render, full table with metric columns, em-dash for rows missing a metric, metadata section presence, pipe-count consistency.

tests/test_cli_integration.py

  • python -m gdb --version prints lica-gdb <version>.
  • python -m gdb --help lists core subcommands.
  • python -m gdb list shows 39 benchmark(s).
  • python -m gdb suites shows all four v0-* suites.
  • python -m gdb info <known|unknown> exits 0 / non-zero appropriately.

Tooling

  • Add pytest>=7 to the [dev] extras, so pip install -e .[dev] is the contributor one-liner.
  • CI: rename test-importtest, install .[dev], extend ruff check to cover tests/, run pytest tests/ -v on the existing 3.9 / 3.11 / 3.12 matrix. The registry-count sanity check and the legacy scripts/run_benchmarks.py --list smoke are preserved.

Testing

  • pytest tests/ -v — 42 passed in 0.74s on Python 3.12 locally
  • ruff check src/ scripts/ tests/ — clean
  • CI matrix (3.9 / 3.11 / 3.12) will run once this PR is opened

Known follow-ups (not in this PR)

  • Online-path tests (gdb eval with real providers) are intentionally out of scope — they require API keys and belong in an out-of-band smoke, not in CI.
  • gdb submit / gdb collect manifest handling is not yet tested; deferred until the multi-task submit work lands.

Made with Cursor

Covers the pure-function surface of `gdb.cli` and `gdb.suites` that had no
regression safety net besides `gdb verify`. 42 tests, ~0.7s locally:

- `test_suites.py` — `resolve_suite` routing for all four `v0-*` suites,
  partition invariants (understanding ∪ generation == all; ∩ == ∅),
  sorted / unique output, static-suite list safety, and error messages
  for unknown suites.
- `test_cli_helpers.py` — `_parse_model_spec` (plain, aliased, whitespace,
  colon-in-entrypoint, invalid forms), `_parse_json_dict_arg` (None,
  empty, inline JSON, file path, type rejections), `_resolve_benchmark_ids`
  (suite vs explicit list, conflicting/missing args, unknown suite), and
  `_render_markdown_report` (empty results, full table, em-dash for
  missing metric per row, metadata presence, pipe-count consistency).
- `test_cli_integration.py` — `python -m gdb` subprocess smokes for
  `--version`, `--help`, `list`, `suites`, `info <known>`, `info <unknown>`.

Also:

- Add `pytest>=7` to the `[dev]` extras so `pip install -e .[dev]` is the
  one-line setup for contributors.
- CI: rename `test-import` → `test`, install `.[dev]`, extend `ruff check`
  to cover `tests/`, and run `pytest tests/ -v` on the existing 3.9 / 3.11
  / 3.12 matrix. The registry-count sanity check and the legacy
  `scripts/run_benchmarks.py --list` smoke are preserved.

Made-with: Cursor
@mohitgargai mohitgargai requested a review from purvanshi as a code owner April 24, 2026 10:36
@mohitgargai mohitgargai merged commit d3412b6 into main Apr 24, 2026
4 checks passed
@mohitgargai mohitgargai deleted the test/cli-coverage branch April 24, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant