diff --git a/understand-anything-plugin/packages/core/src/__tests__/ignore-generator.test.ts b/understand-anything-plugin/packages/core/src/__tests__/ignore-generator.test.ts index 1a150bec0..dccee70f0 100644 --- a/understand-anything-plugin/packages/core/src/__tests__/ignore-generator.test.ts +++ b/understand-anything-plugin/packages/core/src/__tests__/ignore-generator.test.ts @@ -138,6 +138,30 @@ describe("generateStarterIgnoreFile", () => { const content = generateStarterIgnoreFile(testDir); expect(content).not.toContain("# tests/"); }); + + it("suggests singular unittest/ (mongo-style)", () => { + mkdirSync(join(testDir, "unittest"), { recursive: true }); + const content = generateStarterIgnoreFile(testDir); + expect(content).toContain("# unittest/"); + }); + + it("suggests benchmark/ directories", () => { + mkdirSync(join(testDir, "benchmark"), { recursive: true }); + const content = generateStarterIgnoreFile(testDir); + expect(content).toContain("# benchmark/"); + }); + + it("suggests benchmarks/ directories", () => { + mkdirSync(join(testDir, "benchmarks"), { recursive: true }); + const content = generateStarterIgnoreFile(testDir); + expect(content).toContain("# benchmarks/"); + }); + + it("suggests bench/ directories", () => { + mkdirSync(join(testDir, "bench"), { recursive: true }); + const content = generateStarterIgnoreFile(testDir); + expect(content).toContain("# bench/"); + }); }); describe("language-grouped test file patterns", () => { @@ -165,21 +189,42 @@ describe("generateStarterIgnoreFile", () => { expect(content).toContain("# **/*_test.go"); }); + it("includes C++ test file patterns", () => { + const content = generateStarterIgnoreFile(testDir); + expect(content).toContain("# C++"); + // gtest-style snake_case suffix (abseil / protobuf / grpc / mongo). + expect(content).toContain("# **/*_test.cc"); + expect(content).toContain("# **/*_test.cpp"); + expect(content).toContain("# **/*_test.cxx"); + // PascalCase suffix (folly, LLVM unittests). + expect(content).toContain("# **/*Test.cc"); + expect(content).toContain("# **/*Test.cpp"); + // Chromium / protobuf / Electron idiom. + expect(content).toContain("# **/*_unittest.cc"); + expect(content).toContain("# **/*_unittest.cpp"); + expect(content).toContain("# **/*_browsertest.cc"); + // Benchmarks frequently co-located with source. + expect(content).toContain("# **/*_benchmark.cc"); + expect(content).toContain("# **/*Benchmark.cpp"); + }); + 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", () => { + it("emits language groups in stable order: JS, C#, Java, Go, C++", () => { 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++"); expect(jsIdx).toBeGreaterThan(-1); expect(csIdx).toBeGreaterThan(jsIdx); expect(javaIdx).toBeGreaterThan(csIdx); expect(goIdx).toBeGreaterThan(javaIdx); + expect(cppIdx).toBeGreaterThan(goIdx); }); it("keeps all suggestions commented even with no detected dirs and no .gitignore", () => { diff --git a/understand-anything-plugin/packages/core/src/ignore-generator.ts b/understand-anything-plugin/packages/core/src/ignore-generator.ts index 112601634..3e9a1ccc7 100644 --- a/understand-anything-plugin/packages/core/src/ignore-generator.ts +++ b/understand-anything-plugin/packages/core/src/ignore-generator.ts @@ -14,8 +14,9 @@ const HEADER = `# .understandignore — patterns for files/dirs to exclude from // Directory names matched case-insensitively against the on-disk entry name. // Mixes ecosystem conventions: __tests__ (JS), test/tests (multi), testdata -// (Go), .storybook (JS), and PascalCase variants (UnitTests/IntegrationTests) -// commonly seen in C#/.NET projects. +// (Go), .storybook (JS), PascalCase variants (UnitTests/IntegrationTests) +// commonly seen in C#/.NET projects, and benchmark dirs (bench/benchmarks) +// idiomatic to large C++ projects (LLVM, abseil, bitcoin, Catch2). const EXACT_DIR_NAMES = [ "__tests__", "test", @@ -28,7 +29,11 @@ const EXACT_DIR_NAMES = [ "migrations", ".storybook", "unittests", + "unittest", "integrationtests", + "bench", + "benchmark", + "benchmarks", ]; // Directory-name suffixes matched case-insensitively via String.endsWith. @@ -71,6 +76,24 @@ const TEST_PATTERN_GROUPS: Array<{ label: string; patterns: string[] }> = [ label: "Go", patterns: ["**/*_test.go"], }, + { + // Many C++ projects (abseil, Chromium, protobuf) interleave test files + // with source rather than using a dedicated test/ dir — so file-pattern + // exclusions matter more here than for languages where tests cluster. + label: "C++", + patterns: [ + "**/*_test.cc", + "**/*_test.cpp", + "**/*_test.cxx", + "**/*Test.cc", + "**/*Test.cpp", + "**/*_unittest.cc", + "**/*_unittest.cpp", + "**/*_browsertest.cc", + "**/*_benchmark.cc", + "**/*Benchmark.cpp", + ], + }, ]; /**