Repository navigation
test: split the rest of test_cli.py into topic files (2 of 2) - #22152
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS
[DESIGN-REVIEWED] bfef27b Description read[DESCRIPTION-READ] e4a833cdbe7a3e88c73807cc8844edc6e7b71fdda8ee134309a3d89d6f60062e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at 4adfaf2.
The split itself is sound. Every test and helper of the base test_cli.py appears AST-identical in the 12 family files, apart from the three edits the description declares (a brand respelling, the re-rooted FindupException fixture and the UTF-8 decode on one subprocess.run). All AI lanes pass, the Design punchline is answered, and every check on this head is green.
One deferred item is not tracked yet. The description defers the stale citation at gateway-stop.js#L33-L34, which still names test/test_cli.py::TestDesktopGatewayIdentityParity, to #21320. That issue's table and comments have no row for it. Add a row to #21320 (it should say test/test_cli_stop.py::TestDesktopGatewayIdentityParity, moved by #22152), or fix the comment in this PR.
I compared sources by AST; I did not run the tests.
— crew-pr-reviewer (r112)
|
@iamwhatever thanks for the review (r112 at 4adfaf2). Deferred citation in The JS comment stays out of this PR on purpose: editing a |
mbriones98
left a comment
There was a problem hiding this comment.
Checks green and readiness passed at 4adfaf2; no behavior change.
test/test_cli.py is about 9,500 lines after part 1, still over the 2,000-line cap. This second PR moves its command tests into one file per command or concern (cron, setup, main entry, gateway client, stop, restart, restart readiness, token, the doctor's MCP and STT/memory sections) and the doctor tests' helpers into test/cli_helpers.py. test_cli.py keeps the doctor's full report, the update failure paths, the banner spelling and the config-set grammar, and its line-cap row goes. Test bodies move verbatim, except lines a gate requires: the product name respelled in one comment and three docstrings, brand-ok markers on eight data lines, one stderr fixture's namespace re-rooted, one docstring reworded to name no internal process, an explicit UTF-8 decode on the moved child-watcher subprocess (its subprocess-encoding row goes), and own-line nosemgrep / flake-ok markers above moved findings. The collected (class, name, params) multiset, fixtures per test and markers equal BASE. Part of #20192
bfef27b
4adfaf2 to
bfef27b
Compare
|
iamwhatever
left a comment
There was a problem hiding this comment.
APPROVE at bfef27b.
The split moves tests and changes nothing they check. I compared every top-level unit and class member of the base test_cli.py and cli_helpers.py by AST against test_cli.py, cli_helpers.py and the 11 new part files at this head. Every unit matches, apart from module docstrings and the five edits the description declares: two "Kiro Crew" respellings, the re-rooted FindupException fixture, one reworded docstring, and the UTF-8 decode on one subprocess.run. The only other edits re-point citations and remove two baseline rows. No test_cli.py:: node id remains outside website/. The gateway-stop.js cite that r112 asked about is now a row on #21320, and the Design punchline has a current-head disposition. The GPT and Opus lanes found nothing, and every check on this head is green. I did not run the tests.
— crew-pr-reviewer (r114)
Problem / Motivation
Goal: Bring
test/test_cli.pyfrom about 9,500 lines to about 620, under the 2,000-line cap, by moving its tests into topic files, without changing what any test checks.test/test_cli.pyis the CLI's largest test file and is far over the 2,000-line capscripts/check_file_line_cap.pyenforces (it is listed in.github/file-line-cap-baseline.txt). The first PR of this series moved itskirocrew chatpermission tests; this second one moves the rest of the commands' tests into one file per command or concern, and deletes the file's line-cap row.Why it matters
The maintainers' rule is that no hand-written file may exceed 2,000 lines. This file changes most weeks, and every new test makes it harder to navigate and review. One file per command (cron, setup, stop, restart, token, doctor sections) makes each topic findable by name and gives each file room to grow.
Not a goal
What changed (motivation → approach → change)
The file splits along its own test classes, grouped by the command or concern under test. A recipe tool did the move, reading the file at BASE, so it can be re-run after a rebase instead of hand-merged. The few classes whose text the added-line gates cannot judge stay in
test_cli.py.test/test_cli.py(9,533 → 621)TestDoctor), the update failure paths, the banner spelling, theconfig setvalue grammartest_cli_cron.py(763),test_cli_setup.py(737)kirocrew cron add,update,remove; the setup wizard's prompts, the Slack manifest, the prerequisite check, the files underconfig_dir(), channel gatingtest_cli_main_entry.py(1,021)cli.main()'s entry checks, builtin and--seeddispatch, the gateway lock-refusal exit, the asyncio child watchertest_cli_gateway_client.py(880),test_cli_token.py(1,088)logout,status,spawn,artifact;kirocrew token, the post-restart token URL, the owner-verified secret transporttest_cli_stop.py(914)kirocrew stopand the gateway-process classifierstest_cli_restart.py(1,250),test_cli_restart_readiness.py(765)kirocrew restart's dispatch, stop and spawn; what restart waits for after the spawn and reportstest_cli_mcp_doctor.py(803),test_cli_stt_memory_doctor.py(805)test/cli_helpers.py(210 → 319)test_cli.pyand the two doctor partsLines that are not pure moves, each required by a gate or rule: the product name is respelled "Kiro Crew" in one moved comment and three moved docstrings, and eight moved data lines that must keep
KiroCrewget a# brand-okmarker; one stderr fixture's tool namespace is re-rooted toExample::Cli::(the assertions read onlyFindupException); one docstring drops an untrue parenthetical about which builtins ship; thesubprocess.runthat starts the movedTestInstallPidfdChildWatcherchild gainsencoding="utf-8", errors="replace"(decoding the CPython child's output as UTF-8), so its subprocess-encoding row goes; own-line# nosemgrep:/# flake-ok:comments sit above moved findings, and four keptTestDoctorfixtures get one too becausetest_cli.pyparses under semgrep.Backwards compatibility
Compatible: test-only change. Every collected test keeps its class, name, parameters and markers (the multiset is identical before and after). No test module imports
test_cli, and no production module, import path, patch target or CLI changes.Removes nothing: every test, fixture and helper still exists.
Tests
No test was added or rewritten. These proofs show the move lost nothing:
pytest --collect-onlybefore part 1 (207ed5ae4c:test_cli.py, plus the threeTestCronCliitems #15524 added since) vs HEAD (test_cli.py+ its 12 parts)(class, name, params)multiset is identical (the consent-surface class from part 1 mapped to its BASE class)pytest --fixtures-per-testbefore part 1 vs HEADconftest.py(60), every corpus gatescripts/leaf_test_scope.pyderives (608), everysource_corpus/repo_files(scanner, the facade patch scanners and every test file main changed since part 1's base: 715 files,-n 3(at the first cut of this commit, on main64c6f446e3; the head differs from it only in docstrings, two marker reasons, oneconftest.pydocstring cite and the #15524 lines intest_cli_cron.py)test_file_line_cap.py,test_host_isolation_floor_restores.pyand the cite files (36), the related set (61) and the 123 corpus scanners main changed since the first cut: 192 files,-n 3test_cli_setup.py,test_cli_main_entry.py,test_cli_gateway_client.py,test_cli_restart.py,test_cli_mcp_doctor.py),-n0, three seeded shuffled orderstest_cli_cron.py, which holds the ported #15524 tests,-n0, five seeded shuffled orders_doctor_mcp_toolsmutated to drop the indented stderr linestest_failure_shows_error_head_and_indented_stderrfails (and passes unmutated)--baseline-commitmain, over the 16 changed.pyfilestest_cli.pyparses (none of its classes holds a bare-*lambda); with--disable-nosemexactly the marked sitesMove audit
Every other unit moved with an identical AST; comment-only edits (the respelled TestRestart comment,
# brand-ok,# nosemgrep:,# flake-ok:) leave the AST unchanged.git diff main...HEADis 829,921 bytes. Main's #15524 additions to_add_job_kwargsandTestCronClimove with those units intotest_cli_cron.py, byte-identical to main.Moved findings, each with an own-line marker:
# nosemgrep: kirocrew.test-autouse-shared-monkeypatchon five moved class fixtures (between decorator anddef);# nosemgrep: kirocrew.mock-pid-allocatableon nineMagicMock(pid=N)doubles that are never signalled;# nosemgrep: kirocrew.test-stdlib-clock-reboundplus# flake-ok:on the fivetime.sleepstubs;# flake-ok:on the loopback server's shutdown, join and three 5 s socket ceilings, the child-watcher child's 60 s bound and the in-processproc.wait().test_cli.pyitself parses under semgrep 1.78 (the bare-*lambdas moved with their classes), so its four keptTestDoctorautouse fixtures carry the same marker. Placeholder paths (/home/u/...,/Users/x/.toolbox/...), the@builder-mcpserver name, the "Dev/Brazil-workspace" comment andamazon_transcribemodule names move verbatim; each has merged added-line precedent.Diff alignment (L36):
git diffandgit diff --minimalgive the same added/deleted counts for every changed file:test_cli.py13/8925,cli_helpers.py114/5,cli.md2/2,conftest.py2/2,test/conftest.py1/1, each baseline 0/1, each cite 1/1, and each new file only added lines.Logger names (L25): no new module defines a logger.
Citations re-pointed (L29, same line count), file:line old -> new:
conftest.py:2434:test_cli.py->test_cli_main_entry.py(the file whosecli.main()tests leak the log listener)conftest.py:2575:test_cli.py::TestCronCli::test_cli_argparse_cron_add_agent_flag->test_cli_cron.py::TestCronCli::...test/conftest.py:1757:test_cli.py::test_real_subprocess_works_after_install_on_linux->test_cli_main_entry.py::...docs/system-specs/modules/cli.md:1279:test_cli.py::TestSeedDispatch::...->test_cli_main_entry.py::TestSeedDispatch::...docs/system-specs/modules/cli.md:1762:test/test_cli.py::TestDesktopGatewayIdentityParity->test/test_cli_stop.py::TestDesktopGatewayIdentityParitytest/test_cli_server_facade.py:275:test_cli.pyswaps ->test_cli_restart_readiness.pyandtest_cli_token.pyswaptest/test_cli_split_dispatch.py:6:test_cli.py's lock-refusal and--seedtests ->test_cli_main_entry.py'sReferences not edited (cost):
website/electron/gateway-stop.js:34namestest/test_cli.py::TestDesktopGatewayIdentityParity, which lives intest/test_cli_stop.py; tracked as a row on #21320 (#21320 (comment)).Kept verbatim on purpose: the moved
_pin_default_configdocstring (like part 1's_doctor_reads_the_warm_probe_cache) says "this file";cli_helpers.py's module docstring says that meanstest_cli.pyand its doctor parts.CI path references
None: no workflow filter, explicit file list,
AUTOSDE.yamlglob or sensitive-change glob namestest_cli.py.Manual verification
N/A: unit coverage is sufficient. This is a test-only move, and the collected-test multiset plus the runs of every moved test prove it.
Related Issues
Part of #20192
Follow-up: #20383 (pre-existing shapes moved verbatim; de-flake there; this PR's sites are listed in #20383 (comment))
Follow-up: #21320 (deferred comment citation in
website/electron/gateway-stop.js)Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)