Repository navigation
Coverage imports map pytest contexts to live test files - #872
Merged
Merged
Conversation
Normalize repository-relative test names before layout resolution and union the executed ranges of contexts that map to one file. Count their union once and retain the strongest measured specificity score; existing stored pairs require an explicit reimport. Signed-off-by: zlareb1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
Measured coverage imports accept pytest node IDs and setup, run and teardown contexts in repository test layouts. Contexts from the same test file contribute their combined executed lines.
Why
A test name such as
tests/test_example.py::test_create|runwas compared with indexed file paths without removing its context. That left the test unmapped. Names outside the integration and query layouts also lacked a repository-relative candidate.Several function contexts can resolve to one source/test-file pair. Assigning each context to that pair discarded the earlier ranges. The import keeps their full union before applying the evidence range cap, counts overlapping lines once, and retains the strongest measured specificity score.
Scope and risk
This changes coverage-name resolution and in-memory import aggregation. A candidate must still match a live indexed file exactly in the selected namespace. Existing integration and query layout candidates remain available. The import retains the union's ranges while planning; stored evidence keeps its existing range cap and format.
Compatibility, rollout and rollback
loom code coverage-import --namespace <namespace> --dry-runto check unmapped names, then import without--dry-runto rebuild pairs from the coverage source. A server update alone does not rebuild stored coverage.Tests
python -m pytest tests/unit/test_code_coverage_import.py tests/unit/test_doc_links.py tests/unit/test_public_copy.py -q: 298 passed.git diff --checkpassed.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (Codex); checked the import path, reproduced the failing cases, and ran the focused regression and static checks.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
main: no migration.frontend/changed: no frontend files change.docs/describe the system as it is, including operator steps and wire changes.git commit -s).