fix(extract-rust): mark #[test]/#[tokio::test] fns is_test so they are filtered#857
Merged
Merged
Conversation
…e filtered Inline Rust test fns (#[test], #[tokio::test], #[async_std::test], #[actix_rt::test], #[test_case::case]) inside a regular .rs file were indexed as ordinary Functions (is_test=false) and leaked past the store.c is_test!=1 filter into graph/agent context — test detection was file-path-based only (cbm_is_test_file: *_test.rs / test_*). Add rust_def_is_test(decorators) (mirroring rust_cfg_qualified_name's scan) and set def.is_test in extract_func_def's Rust branch. Closes DeusData#855. Signed-off-by: Greg Tiller <tiller@dal.ca>
Owner
|
Thank you — this is a correct, well-scoped fix: detecting #[test]/#[tokio::test]/#[async_std::test]/etc. attributes and marking those functions is_test, which flows end-to-end into the node properties and the store queries that exclude tests from graph/agent context. The decorator substring-matching mirrors the existing rust_cfg pattern, and your test (on a non-test path so is_test can only come from the attribute detection) is a genuine non-vacuous guard. Merged as bf3657f; closes #855. Deferring impl/trait test methods to a follow-up was the right call. Appreciated! |
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.
Closes #855.
Summary
#[test],#[tokio::test],#[async_std::test],#[actix_rt::test],#[test_case::case]— inside a regular.rsfile are now markedis_test = trueon theFunctionnode, so thestore.cis_test != 1filter excludes them from graph/agent context. Previously they leaked in because test detection was file-path-based only (cbm_is_test_file:*_test.rs/test_*).rust_def_is_test(decorators)(mirrorsrust_cfg_qualified_name's decorator scan), set ondefinextract_func_def's Rust branch.extract_decoratorsstoresattribute_itemtext in its bracketed form ("#[test]","#[tokio::test]","#[tokio::test(...)]"), so the matcher is substring-based and robust to argument lists.#[cfg(test)] mod tests { #[tokio::test] async fn … }.impl/traitmethods can follow in a separate change.Verification
scripts/test.sh→ 5831 passed (clean ASan + UBSan build). New regressionextract_rust_test_attr_marks_is_test_issue855covers#[test],#[tokio::test], and a negative (non-test) case.ASSERT(sync == 1 && "#[test] fn is_test")and is the only failure (5830 passed, 1 failed); restored → green.scripts/lint.sh(clang-tidy / cppcheck / clang-format) is not available in my local environment, so CI is the authority for it; the new code mirrors the surroundingrust_cfg_qualified_namestyle.Notes