Repository navigation
test: split four oversized test files under the 2,000-line cap - #21916
Conversation
test_slack_gateway_cron_exec_coverage.py, test_cloud_source.py, test_dashboard_templates.py and test_host_isolation_floor.py were each over the cap. Each keeps its path and the tests of its core topic; the rest moves verbatim into sibling test_<stem>_<topic>.py files, with the pieces two or more files read in a <stem>_helpers.py module. - slack: the message arm (_message_arm) and where cron results, alerts and task-runner notices go (_delivery) move out; the command and script arms and claim-time vetting stay. - cloud: the tarball staging directory and its ancestor walk, Windows arm included, move to _staging. - dashboard templates: the page and contract readers move to _readers; the invariants, registry and scaffold stay. - host isolation floor: the between-test restores move to _restores and the worker budget to _worker_budget; the path pins, telemetry, temp and working-directory guards stay. The same 580 tests are collected with the same markers. The 41 moved host tests no longer get the module autouse fixture _record_own_basetemp, which only sets the guard's basetemp for _inside_a_guarded_root; none of them calls it. The four line-cap baseline rows go, and three citations of moved tests point at their new files. Part of #20192
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 Please check that CI collects 583 tests across the ten split files, matching the base count. [DESIGN-REVIEWED] f1b22d0 Description read[DESCRIPTION-READ] 4fa430f8f169ec8ef3b7333306a74b2e1eb341333b5ab75ef5d2c765011a48f2 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 |
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: |
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: |
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (17 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: moves tests out of four oversized test files into sibling modules and shared helpers; every removed test function is re-added, plus docstring path updates and line-cap baseline removals. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/common/testing-conventions.md.
Problem / Motivation
Goal: Bring four oversized test files under the 2,000-line cap by moving their tests, unchanged, into sibling files named for the behaviour they cover.
test/test_host_isolation_floor.py(2,458 lines),test/test_slack_gateway_cron_exec_coverage.py(2,367),test/test_cloud_source.py(2,288) andtest/test_dashboard_templates.py(2,286) are over the 2,000-line cap andlisted in
.github/file-line-cap-baseline.txt.Why it matters
Files this long are hard to review and to navigate, and the cap only holds if baselined files shrink. Leaving them
over the cap keeps four rows in the baseline, and every new test in these areas lands in an oversized file.
Not a goal
What changed (motivation → approach → change)
Each file is split along its own seams (Test classes and section banners). Tests move byte for byte; the builders,
doubles and constants that two or more files of a family read move to one
*_helpers.pyper family, which eachfile imports explicitly. Every file ends at or below 1,600 lines.
test_slack_gateway_cron_exec_coverage.py(2,367): command and script arms, claim-time vetting, script-result delivery_message_arm.py(310): the LLM arm's denial,_init_cronwiring, alias resolution;_delivery.py(774): where cron results, alerts and task-runner notices go;slack_gateway_cron_exec_coverage_helpers.py(223)test_cloud_source.py(2,288): repo root, tarball contents, checksum pin, bucket, boundaries, uploadtest_cloud_source_staging.py(1,133): the staging directory and its ancestor walk, Windows arm includedtest_dashboard_templates.py(2,286): the invariants, host caps, registry and scaffoldtest_dashboard_templates_readers.py(872): the page and contract readers;dashboard_templates_helpers.py(31)test_host_isolation_floor.py(2,458): the guard, path pins and ratchet, telemetry, temp, cwd and test loop_restores.py(580): the between-test restores;_worker_budget.py(418);host_isolation_floor_helpers.py(33)The four line-cap rows go. Three citations name the file that now holds the cited test:
conftest.py(
TestInheritedShellEnvironmentIsScrubbed),docs/system-specs/common/testing-conventions.md(the hooksdispatcher restore) and
test/test_ci_failure_annotations.py(the conftest-by-path idiom). The two small helpersmodules hold only what two or more files of their family share; the cloud family needs none.
Backwards compatibility
Compatible: no product code changes, and no test file imports from the four origins. Every test keeps its name,
parameters and markers.
Removes nothing: tests move between files and none is dropped (583 collected before and after).
Move audit
move_audit.py --base 330812e688(every unit not listed moved unchanged):The changed
Exprunits are the module docstrings (one appended paragraph each naming the sibling files). Theother non-move edits:
# nosemgrep: kirocrew.test-autouse-shared-monkeypatchmarker on each of the two class-level autousefixtures that move (
TestTheLogQueueListenerIsRestored,TestTheWorkerBudgetIsMemoryBounded), silencingtheir pre-existing finding at its new path;
TestTheWorkerBudgetIsMemoryBounded("this file's own ratchet" becomes"test_host_isolation_floor.py's ratchet"; the ratchet stays there). The AST is unchanged.
Default and
--minimaldiffs add the same lines for every file but one: the slack remainder's import headerre-shows one blank line under the default diff (20/1,238 vs 19/1,237). The line is a blank in import glue, so it
carries no gate token.
Tests
Proof that nothing was lost (BASE vs HEAD,
-n0):(class, name, params)multiset: 583 at BASE, 583 at HEAD, equal (91+107+265+120 -> 43+10+38,55+52, 136+129, 79+22+19);
iter_markers): 583, equal;--fixtures-per-test: equal except for the 41 host tests that moved. They no longer request the module autouse_record_own_basetemp, and that is the only difference. The fixture only records pytest's basetemp in aglobal that
_inside_a_guarded_rootreads, and none of the moved tests calls that guard. It stays withTestTheGuardItself, which patches that global throughsys.modules[__name__].Local gates at HEAD:
-n 3, on base9d088c85ad(same split patch): 586 files (the split files, the 556leaf_test_scopecorpus gates, the 52 tests that read theroot conftest, and the related set without the
conftest.pytoken): 39,025 passed, 136 skipped, 5 xfailed,1 failed. The one failure was
test_history_bindings.py::test_the_member_set_is_the_frozen_inventoryon theolder base, fixed upstream by test(history): list the members #21108 added in the frozen inventory #21792; it passes on this base (212 passed);
330812e688, which adds threeTestTheTempResidueReporttests to the host remainder): the10 split files plus
test_ci_failure_annotations,test_history_bindings,test_file_line_cap,test_wait_discipline_ratchet,test_windows_gap_list,test_codebuild_gap_list,test_ci_file_shards,test_host_service_guardand the flake ratchet at-n0: 1,137 passed, 2 skipped;-n0pass over the 580 split-file ids of the earlier base: 578 passed, 2 skipped;brand, harness parity, docs lint,
check_file_line_cap.py(0 failures), and semgrep with the CI configs and--baseline-commit(0 findings;--disable-nosemshows only the pre-existing marked sites).scripts/local-gate.py --dry-runselects 557 backend and 374 frontend files (theconftest.pycitation makes mostof the suite "related"), so it was not run whole; the floor above ran instead and CI runs the full matrix.
The encoding scan
test_no_text_io_here_relies_on_the_platform_default_encodingreads its own module. Everytext-I/O call it examined at BASE (8) is still in that module; the moved slack code makes none.
Determinism: the moved tests are not rewritten, and none of them carries a sleep, clock or unbounded-wait shape.
Manual verification
N/A — a pure test move: the collection, fixture and marker proofs and the test runs above cover it.
CI path references
None: no workflow path filter, explicit file list,
AUTOSDE.yamlglob or sensitive-change glob names these files.test_dashboard_templates_readers.pyreads the website binder, soci-surface-tests.pyadds it to the backendtests a frontend diff runs;
test_host_isolation_floor_worker_budget.pyreadstest/conftest.py, so it becomes aleaf_test_scopecorpus gate. No logger is created in any moved or new module (L25).Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)