Skip to content

Add tests for the command line (tests/test_main.py) - #2

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/cli-tests
Oct 3, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/cli-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: src/arcade/__main__.py was the only source module without a tests/test_<module>.py mirror. tests/test_routers.py already covered parts of the CLI; this PR adds tests/test_main.py with characterization tests for the paths that were not covered:

  • --version output, and argparse's exit status 2 when no subcommand is given
  • routers without --check (the generated document on stdout), and the --check success message
  • check-registry's N game(s) OK line, and --domain changing which aliases are refused
  • registry errors on routers and hosts reported as arcade: … with exit status 1 and no traceback
  • hash-token trimming whitespace, and refusing a whitespace-only token
  • _reporter(): no client when ARCADE_TRACE_KEY is unset or blank; the URL, program, version and key are passed through, and the documented defaults (https://trace.danielstephenson.dev, arcade) apply. DO_NOT_TRACK=1 keeps the client's sender thread from starting, so nothing reaches the network.
  • serve with makeServer replaced by a fake, so nothing binds: host and port come from ARCADE_HOST/ARCADE_PORT, the startup log line, startup reported and the reporter closed, and an invalid registry refused (exit 1) before any server is made

Production code is unchanged, and no CHANGELOG entry was added because nothing user-visible changes. One gap found while writing these tests was filed separately rather than fixed here: a missing registry file makes the CLI print a traceback (#1).

No tracking issue: the gap was found during triage, when the open-issue backlog was empty.

Test plan

  • python3 -m pytest -v: 119 passed locally on Python 3.8.10 (15 new in tests/test_main.py)
  • python3 -m black --check tests/test_main.py: clean
  • CI: test (3.8), test (3.12), docker

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Characterization tests for src/arcade/__main__.py: --version, the
required subcommand, routers output and --check success, check-registry
counts and --domain, registry errors reported without a traceback,
hash-token whitespace, the trace reporter's construction and defaults,
and serve (with makeServer replaced, so nothing binds).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (one intrinsic pass; anchored on CI run 37113174170):

  • Scope: PASS. gh pr diff lists one file, tests/test_main.py (new); no production, config or docs changes.
  • Tests-new: PASS (not applicable). No public function added; the file adds tests only.
  • Tests-fix: PASS (not applicable). No bug fix in this PR; the traceback gap was filed as CLI prints a traceback when the registry file is missing #1 instead of being fixed under a test cycle.
  • Sibling structure: PASS. Plain def test_<behavior_in_words> functions, no test classes; builders come from tests/helpers.py (game, registryText); tmp_path for every file; recorder-style fake reporter like test_server.py's Recorder.
  • Sibling renames: PASS (not applicable). Nothing renamed.
  • Docs: PASS. Behavior unchanged, so the README/CHANGELOG rows are unaffected; the defaults asserted (https://trace.danielstephenson.dev, program arcade, ARCADE_HOST/ARCADE_PORT) match README's "Usage reporting" and "Configuration" sections.
  • Issue resolution: PASS (not applicable). No Closes; PR body records "no tracking issue".
  • CI: PASS. test (3.8), test (3.12) and docker are all green on the PR head.
  • Stdlib-only: PASS. No import added under src/arcade/.
  • Py3.8: PASS. No 3.9+ constructs; ran locally on 3.8.10 (119 passed), and test (3.8) is green.
  • Vendored client untouched: PASS. trace_client.py is not in the diff.
  • Naming: PASS. New helpers and fixtures are camelCase (makeServer, serveEnvironment), except FakeServer.serve_forever, which has to match the socketserver method name.
  • Isolation headers / Config documented / CLI documented / Changelog: PASS (not applicable). No response path, ARCADE_* variable, flag or user-visible behavior changed.

Judgment calls left for the maintainer:

  • tests/test_main.py (test_a_trace_key_builds_a_client_for_the_configured_program, test_the_trace_endpoint_and_program_default_to_the_documented_ones): these read private attributes of the vendored TraceClient (_endpoint, _application, _version, _key). That is the only way to check what _reporter() passes without a network call, but re-vendoring a trace-client release that renames them would break these two tests (and only these two).
  • tests/test_main.py: with pytest.raises(SystemExit) as exit: shadows the exit builtin inside two tests. This is harmless, but it can be renamed if preferred.

Summary: a tests-only PR that is CI-green on 3.8 and 3.12. Production code is unchanged, and the one defect found is tracked in #1.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit c34f931 into main Oct 3, 2026
3 checks passed
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