D-040: test: parametrise make_symbol helper by line range#9
Open
Sephyi wants to merge 1 commit intodevelopmentfrom
Open
D-040: test: parametrise make_symbol helper by line range#9Sephyi wants to merge 1 commit intodevelopmentfrom
Sephyi wants to merge 1 commit intodevelopmentfrom
Conversation
Consolidate the two duplicated `make_symbol` helpers (one in `tests/context.rs`, one in `tests/splitter.rs`) into `tests/helpers.rs` and add a `make_symbol_at(..., line, end_line)` variant that lets callers pin symbols to arbitrary line ranges. `make_symbol` is kept as a thin wrapper that delegates to `make_symbol_at` with the historical defaults `line: 1, end_line: 10`, so every existing call site compiles and runs unchanged. The audit entry proposed either (a) adding a `line, end_line` parameter pair to `make_symbol` and updating ~50 call sites, or (b) introducing a sibling `make_symbol_at` alongside. Chose (b) because the diff touches only the three helper files (instead of rewriting every single `make_symbol(...)` invocation), eliminates two exact duplicate function bodies in the process, and keeps behaviour bit-identical for every existing test. Future tests that need hunk-to-span mapping (for example around `classify_span_change`) can now express real line positions without cloning the whole `CodeSymbol` literal. Two small smoke tests in `tests/context.rs` lock down the defaults (`make_symbol` ⇒ `line: 1, end_line: 10`) and confirm that `make_symbol_at` honours arbitrary positions and the other passthrough fields (`name`, `is_public`, `is_added`). Closes audit entry D-040 from #3.
There was a problem hiding this comment.
Pull request overview
This PR centralizes the make_symbol test helper into the shared tests/helpers.rs module and introduces a new make_symbol_at variant to allow tests to pin CodeSymbol line ranges (addressing audit item D-040).
Changes:
- Move duplicated
make_symbolhelper implementations out of individual test files intotests/helpers.rs. - Add
make_symbol_at(..., line, end_line)to support line-range-specific symbol construction in tests. - Update affected tests to import the shared helpers and add small smoke tests covering helper defaults/overrides.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/splitter.rs |
Removes local make_symbol and uses helpers::make_symbol instead. |
tests/helpers.rs |
Adds shared make_symbol + new make_symbol_at helper for configurable line ranges. |
tests/context.rs |
Removes local make_symbol, imports shared helpers, and adds smoke tests for default/pinned line ranges. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
test: parametrise make_symbol helper by line range.
Audit context
Closes audit entry D-040 from #3.
Verification
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all-targets