docs(core): tighten Rust group rationale to reflect measured shape
The initial comment implied `tests.rs` was the load-bearing pattern.
Measurement across 10 major public Rust repos (rust-lang/rust, tokio,
cargo, ripgrep, alacritty, helix, deno, solana, foundry, polkadot-sdk)
showed the actual distribution is bimodal:
- Library-scale crates keep tests inline via `#[cfg(test)] mod`,
which no file-pattern rule can touch → group is a near-noop.
- Workspace monorepos colocate `foo_test.rs` beside `foo.rs` at
scale → `*_test.rs` alone accounts for the vast majority of hits
(232 in polkadot-sdk, 253 in rust-lang/rust even with truncated
tree).
Rewrite the block comment so a future reader lands on the right mental
model — the extracted `tests.rs` form is legitimate but rare; the win
comes from the colocated shape in workspace-heavy repos.
This commit is contained in:
@@ -113,13 +113,17 @@ const TEST_PATTERN_GROUPS: Array<{ label: string; patterns: string[] }> = [
|
||||
],
|
||||
},
|
||||
{
|
||||
// Rust's dominant unit-test convention is inline `#[cfg(test)] mod
|
||||
// tests { ... }` blocks that cannot be excluded by filename. The
|
||||
// Rust Book (chapter 11.3) also describes extracting those blocks
|
||||
// into a sibling `tests.rs` file — that extracted form is what a
|
||||
// file-pattern rule can catch. Integration tests already live under
|
||||
// tests/ (covered by EXACT_DIR_NAMES); benches/ was added in the
|
||||
// same PR as this group.
|
||||
// Rust testing is bimodal, similar to Python. Library-scale crates
|
||||
// (ripgrep, alacritty, helix, cargo) keep unit tests inline in
|
||||
// `#[cfg(test)] mod tests { ... }` blocks that no file-pattern
|
||||
// rule can catch, so the group barely moves the needle for them.
|
||||
// Workspace monorepos (paritytech/polkadot-sdk, solana-labs/solana,
|
||||
// rust-lang/rust) colocate a `foo_test.rs` beside `foo.rs` at
|
||||
// scale — measurement showed *_test.rs alone accounts for the
|
||||
// majority of hits (232 files / −15% on polkadot-sdk analysed
|
||||
// budget). Integration tests already live under tests/ and Cargo
|
||||
// benches under benches/ (both dir-covered), so the file globs
|
||||
// here target the colocated shape specifically.
|
||||
label: "Rust",
|
||||
patterns: [
|
||||
"**/tests.rs",
|
||||
|
||||
Reference in New Issue
Block a user