Repository navigation
refactor(layering): R84 requires each new unit test to be named for a module beside it - #3669
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
4c2e459 to
bce7f7d
Compare
|
The code at bce7f7d has one problem to fix before merge. R84 sends authors to a test/repo-guards/ directory that no test project collects. The checks are still queued, with no failures so far. The diff only touches scripts/layering, so the Repo Guards and Lint & Format jobs through check:layering are the ones that apply. No conflicts. The violation message in test-colocation.ts, the rule comment above it and the PR body all say repo-level guards belong in test/repo-guards/ and "run in unit-core". That directory does not exist at this commit, and the unit-core include in vitest.config.ts lists test/ files one by one with no test/repo-guards glob. No gate fails when a test file belongs to no vitest project. An author who follows the remedy moves a guard out of src/, and it then runs in no lane while check:layering, the unit suite and CI stay green. The burn-down will take this route for some of the 347 offenders. The rule should be that every location R84 names as a remedy is collected by a vitest project. Please add test/repo-guards/**/*.test.ts to the unit-core include and map it in check:affected, or drop that remedy from the message and comment until the PR that creates the directory lands. To validate, put a throwaway test in test/repo-guards/ and show that the unit suite runs it. Not blocking, and fine to take or leave: no fixture-repo test covers a test that was unmatched at the base and then renamed (the carry-over through the base-to-head mapping and the re-sort in ratchet-reference.ts), and a case like the one at session-authority-overlay.test.ts:312 would pin it. IN_SCOPE and TEST_FILE in test-colocation.ts also re-spell predicates from tracked-sources.ts, so exporting those and reusing them would keep one source of truth. The two open inline threads on the declaration-module regex and the unmatched-test sort are fixed at this commit. Please resolve the regex thread and the sort thread. I read the code but did not run check:layering. So I could not confirm the 347 count, which the rule comment gives as 346, or the planted-test result. The rename carry-over is checked by reading only. Before merge, a vitest project must collect test/repo-guards/, or the message must drop that remedy. |
Size Report
Startup median (7 runs, lower is better):
|
bce7f7d to
a1a7401
Compare
a1a7401 to
56bbc2e
Compare
|
The base was old: #3663 added the glob to and To keep the remedy from rotting, |
|
The PR is ready. Both earlier threads from the review of bce7f7d are fixed at 56bbc2e: Not blocking: the new test at https://github.com/callstack/agent-device/blob/56bbc2e/scripts/layering/test-colocation.test.ts#L151 matches the literal glob text in Both cubic-dev-ai threads are fixed at this head, so you can resolve them: the I did not run No conflicts. CI is still pending: every check is queued or was cancelled by a newer push, and none has failed. This diff only touches |
…dule beside it Every *.test.ts under root src/ and packages/*/src/ (test-kit excluded) sits in the directory of a module, or in its __tests__/, named <module>.test.ts or <module>-<aspect>.test.ts. The unmatched set is a merge-base ratchet like R83: growth fails, a move into place needs no edit, no baseline file. index is an ordinary module (cross-module package tests are index-<aspect>.test.ts); repo-level guards live in test/repo-guards/, under the exempt test/ tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…carried colocation entries foo.d.ts is the module foo, not foo.d, so a colocated foo.test.ts matches it; base entries mapped to head coordinates are re-sorted so a rename that changes lexical order keeps the measured ordering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e repo-guards remedy R84 reads SOURCE_TREE_ROOT from tracked-sources instead of re-spelling it, the carried merge-base entries go through a tested helper that re-sorts them, and a test pins that vitest.config.ts collects test/repo-guards/ so the remedy the rule names runs in unit-core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56bbc2e to
6bdaabf
Compare
Stacked on #3667 (test-kit single entry) on #3659 (R11 devDependencies) on #3645 (R83).
What
R84
test-colocation: every*.test.tsunder rootsrc/andpackages/<pkg>/src/sits in the directory of a module (or in that directory's__tests__/) and is named<module>.test.tsor<module>-<aspect>.test.ts. It measures its offenders against the merge-base and keeps no baseline file, the same way R83 does: 202 unmatched tests at head against 202 at the merge-base. Growth fails; moving or renaming a test into place needs no edit (base entries are carried to head coordinates throughrenamedSince, so a rename is the same entry). Burn-down belongs to the package and root workers; this PR only lands the rule.Conventions (stated in the rule's doc comment, so it needs no exemptions)
index-<aspect>.test.ts, besideindex.ts.indexis an ordinary module to the rule.test/repo-guards/, under the exempttest/tree, and run inunit-core.test/,scripts/, package-localtest/trees. The rule reads onlysrc/andpackages/*/src/, and not test-kit, whose sources are test support.isProductionSourceFile): fixtures and__tests__/helpers never count as the module a test is named for.Evidence
test-colocation.test.ts: matched by module and by-aspect; unmatched for a different name, a glued suffix or a dotted suffix;__tests__judged against the parent directory (and not against modules inside__tests__);index-<aspect>matched only with anindex.tsbeside it; fixtures never the module;test/,scripts/and package test trees unmeasured; growth fails, a cleanup or unchanged set passes; the message names both conventions.src/__tests__/planted-unmatched.test.tsin the real tree:check:layeringnamed it under R84. Removed.mergeBaseRatchets(LayeringRatchets.unmatchedTests);measureRatchetsnow takes the tracked tree ({ manifests, files }) that R83 and R84 share.pnpm check:quick,check:layering(384 node tests),check:fallow,check:gate-manifest,check:affected --run, repo-widepnpm format.🤖 Generated with Claude Code