Skip to content

fix(extract-rust): mark #[test]/#[tokio::test] fns is_test so they are filtered#857

Merged
DeusData merged 1 commit into
DeusData:mainfrom
moofone:fix/855-rust-test-attr-is_test
Jul 4, 2026
Merged

fix(extract-rust): mark #[test]/#[tokio::test] fns is_test so they are filtered#857
DeusData merged 1 commit into
DeusData:mainfrom
moofone:fix/855-rust-test-attr-is_test

Conversation

@moofone

@moofone moofone commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Closes #855.

Summary

  • Inline Rust test functions — #[test], #[tokio::test], #[async_std::test], #[actix_rt::test], #[test_case::case] — inside a regular .rs file are now marked is_test = true on the Function node, so the store.c is_test != 1 filter 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_*).
  • Adds rust_def_is_test(decorators) (mirrors rust_cfg_qualified_name's decorator scan), set on def in extract_func_def's Rust branch. extract_decorators stores attribute_item text in its bracketed form ("#[test]", "#[tokio::test]", "#[tokio::test(...)]"), so the matcher is substring-based and robust to argument lists.
  • Rust-scoped per the issue. Free functions are covered, including #[cfg(test)] mod tests { #[tokio::test] async fn … }. impl/trait methods can follow in a separate change.

Verification

  • scripts/test.sh5831 passed (clean ASan + UBSan build). New regression extract_rust_test_attr_marks_is_test_issue855 covers #[test], #[tokio::test], and a negative (non-test) case.
  • Red → green: with detection disabled, the new test fails exactly at 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 surrounding rust_cfg_qualified_name style.

Notes

…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>
@moofone moofone requested a review from DeusData as a code owner July 4, 2026 17:22
@DeusData DeusData enabled auto-merge July 4, 2026 17:34
@DeusData DeusData merged commit bf3657f into DeusData:main Jul 4, 2026
14 checks passed
@DeusData

DeusData commented Jul 4, 2026

Copy link
Copy Markdown
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(extract-rust): inline test fns (#[test]/#[tokio::test]) are not marked is_test — leak into graph/agent context

2 participants