Skip to content
Open
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 @@ -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", () => {
Expand Down Expand Up @@ -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", () => {
Expand Down
27 changes: 25 additions & 2 deletions understand-anything-plugin/packages/core/src/ignore-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.
Expand Down Expand Up @@ -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",
],
},
];

/**
Expand Down
Loading