Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ describe("generateStarterIgnoreFile", () => {
const content = generateStarterIgnoreFile(testDir);
expect(content).toContain("# bench/");
});

it("suggests benches/ directories (Cargo convention)", () => {
mkdirSync(join(testDir, "benches"), { recursive: true });
const content = generateStarterIgnoreFile(testDir);
expect(content).toContain("# benches/");
});
});

describe("language-grouped test file patterns", () => {
Expand Down Expand Up @@ -227,25 +233,52 @@ describe("generateStarterIgnoreFile", () => {
expect(content).toContain("# **/conftest.py");
});

it("includes Rust tests.rs per-module extraction convention", () => {
const content = generateStarterIgnoreFile(testDir);
expect(content).toContain("# Rust");
// Rust Book ch. 11.3 pattern — extracted sibling test module.
expect(content).toContain("# **/tests.rs");
});

it("includes Rust workspace-style *_test.rs and test_*.rs conventions", () => {
const content = generateStarterIgnoreFile(testDir);
// Dominant in large workspaces (polkadot-sdk, rust-lang/rust,
// solana-labs/solana) where tests colocate with source rather
// than living inside inline `#[cfg(test)] mod tests`.
expect(content).toContain("# **/test_*.rs");
expect(content).toContain("# **/*_test.rs");
});

it("includes Rust criterion / test::Bencher file patterns", () => {
const content = generateStarterIgnoreFile(testDir);
// Defensive: most Cargo benches live under `benches/` (covered by
// the dir rule) but a small fraction of workspaces name benchmark
// files with these prefixes/suffixes outside that directory.
expect(content).toContain("# **/bench_*.rs");
expect(content).toContain("# **/*_bench.rs");
});

it("groups patterns under the JS / TS sub-header", () => {
const content = generateStarterIgnoreFile(testDir);
expect(content).toContain("# JS / TS");
});

it("emits language groups in stable order: JS, C#, Java, Go, C++, Python", () => {
it("emits language groups in stable order: JS, C#, Java, Go, C++, Python, Rust", () => {
const content = generateStarterIgnoreFile(testDir);
const jsIdx = content.indexOf("# JS / TS");
const csIdx = content.indexOf("# C# / .NET");
const javaIdx = content.indexOf("# Java / Kotlin");
const goIdx = content.indexOf("# Go");
const cppIdx = content.indexOf("# C++");
const pyIdx = content.indexOf("# Python");
const rustIdx = content.indexOf("# Rust");
expect(jsIdx).toBeGreaterThan(-1);
expect(csIdx).toBeGreaterThan(jsIdx);
expect(javaIdx).toBeGreaterThan(csIdx);
expect(goIdx).toBeGreaterThan(javaIdx);
expect(cppIdx).toBeGreaterThan(goIdx);
expect(pyIdx).toBeGreaterThan(cppIdx);
expect(rustIdx).toBeGreaterThan(pyIdx);
});

it("keeps all suggestions commented even with no detected dirs and no .gitignore", () => {
Expand Down
22 changes: 22 additions & 0 deletions understand-anything-plugin/packages/core/src/ignore-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const EXACT_DIR_NAMES = [
"bench",
"benchmark",
"benchmarks",
"benches",
];

// Directory-name suffixes matched case-insensitively via String.endsWith.
Expand Down Expand Up @@ -111,6 +112,27 @@ const TEST_PATTERN_GROUPS: Array<{ label: string; patterns: string[] }> = [
"**/conftest.py",
],
},
{
// 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",
"**/test_*.rs",
"**/*_test.rs",
"**/bench_*.rs",
"**/*_bench.rs",
],
},
];

/**
Expand Down