Repository navigation
Conversation
…ast radius (colbymchenry#3265) The blast radius told test callers apart by file path alone, so Rust unit tests -- an inline `#[cfg(test)] mod tests { ... }`, or a `tests.rs` that a `#[cfg(test)] mod tests;` loads -- read as production callers and the entry said "no tests found". It now uses the shared test-code reading per caller, which also learns the out-of-line `tests.rs` / `tests/mod.rs` layout from the parent module's declaration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maxmilian
marked this pull request as ready for review
November 11, 2026 01:40
This branch has not been deployed
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.
Fixes #3265.
Problem
In Rust,
codegraph_explore's blast radius reportedno tests found within 3 caller hopsfor functions that unit tests call directly. The callers were found; they just weren't counted as tests.Cause
The blast radius classified callers with
isTestFile(path), which only reads the path. Rust unit tests live where no path rule reaches: an inline#[cfg(test)] mod tests { … }next to production code, or atests.rs(ortests/mod.rs) that the parent loads with#[cfg(test)] mod tests;. The repo already hasisTestCode(path + qualified name + inline#[cfg(test)]module) forcodegraph implementations, but the blast radius didn't use it, and it didn't know the out-of-line layout either.Fix
isTestCodenow takes a source reader instead of one file's source. For Rust it also checks whether the file is a module that its parent (dir.rs,dir/mod.rs, or a crate root indir/) declares at the top level under a testcfg, following plainmod x;declarations down from such a file.#[cfg(not(test))]and declarations inside inline blocks don't count.isTestCode, per caller rather than per file, since an inline test module shares its file with the code it tests. Each file is read at most once per section, and only for Rust callers.codegraph implementationspasses the reader through, so a mock intests.rsis marked as test code too.One behavior to be aware of: because the blast radius now uses
isTestCoderather thanisTestFile, a caller in any language whose qualified name has a test scope (the same rulecodegraph implementationsalready applies) is also counted as a test.Tests
explore-blast-radius.test.ts: a Rust crate with both layouts, plus controls (a production caller, a#[cfg(not(test))]module). The two layout cases fail onmain(f72c9d2e) and pass here.rust-cfg-test-file.test.ts: unit cases for the parent-declaration reading (tests.rs/tests/mod.rs,mod.rsand crate-root parents, nesting, plain /not(test)/ nested declarations).npm run buildpasses.npm test: the only failures are 30 ininstaller-targets.test.ts(local installs for bob/droid/kimi/pi/qoder/qwen), with identical assertions on a cleanmaincheckout, so they're pre-existing in this environment.🤖 Generated with Claude Code