Skip to content

aft_callgraph includeTests:false still lists Rust callers in an inline #[cfg(test)] module #973

Closed

Description

@iceteaSA

Summary

With includeTests: false, aft_callgraph still lists callers that are Rust unit tests in an inline #[cfg(test)] mod tests { … }. The filter checks only the file path. Rust unit tests are usually in the same file as the code, so for a Rust crate includeTests: false does not hide most tests. The parameter description says "Defaults to false; tests are hidden."

Reproduction

Checked on main at 8876c44, with the binary built from that commit and isolated storage.

Cargo.toml with [package] name = "fx", and src/lib.rs:

pub fn production() -> u32 {
    1
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn checks_production() {
        assert_eq!(production(), 1);
    }
}

NDJSON requests after configure:

{"command":"callers","file":"<root>/src/lib.rs","symbol":"production","depth":3,"includeTests":false}
{"command":"callers","file":"<root>/src/lib.rs","symbol":"production","depth":3,"includeTests":true}

Both responses are the same:

"callers": [{"file": "src/lib.rs", "callers": [{"symbol": "tests::checks_production", "line": 11}]}], "total_callers": 1

With includeTests: false, the expected result is no callers, or a note that test callers in production files are not filtered.

Cause

crates/aft/src/commands/callgraph_store_adapter.rs filters with is_test_file(path) only (:117, :438, :442, :522, :574). is_test_file (crates/aft/src/inspect/job.rs:936) classifies the file name and directory, not the item. A #[cfg(test)] module or a #[test] function in a production file is not detected.

Question

Which behaviour is intended?

  1. includeTests applies to items too. It hides callers in a #[cfg(test)] module or with a #[test] attribute. Other languages with inline tests can get the same rule.
  2. includeTests applies only to test files: change the description from "tests are hidden" to "test files are hidden", and tell the agent that inline test callers stay in the result.

Option 1 matches what an agent expects from the current description.

Activity

  1. aft-alfonso commented on Oct 28, 2026

    @aft-alfonso

    Thanks. This is fixed on main in #1015 with option 1, and will ship in the next release. With includeTests: false, Rust callers inside a #[cfg(test)] module or marked #[test] are hidden, even in production files. When AFT can't tell whether a caller is a test, the result says so instead of hiding it.

  2. aft-alfonso commented on Oct 30, 2026

    @aft-alfonso

    Released in v0.63.4. With includeTests: false, aft_callgraph now leaves out callers inside Rust inline test modules (#[cfg(test)]), not only callers in test files. Thanks for the report.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions