Skip to content

Exclude C and C++ test and benchmark files by default #2079

Done

Description

@alex09x

Problem Statement

default_exclude_patterns.json has default test-path exclusions for Go, Java, Kotlin, Python, Rust, Swift, Haskell, Zig and others, but none for C or C++. GoogleTest files (*_test.cc), Chromium-style unit tests (*_unittest.cc), Google Benchmark files (*_benchmark.cc), and the test/, tests/, unittests/ and benchmarks/ trees used by CTest, Catch2 and LLVM are all sent to the reviewer and checked against c.md and cpp.md.

Proposed Solution

Add C/C++ patterns in the style of the Rust change in #1971:

  • **/*_{test,tests,unittest,benchmark}.{c,cc,cpp,cxx}
  • **/{test,tests,unittests}/**/*.{c,h,cc,cpp,cxx,hpp,hxx}
  • **/{bench,benchmarks}/**/*.{c,h,cc,cpp,cxx,hpp,hxx}

Keep names such as contest.cc, test_support.h, src/benchmark.cc and src/testing/harness.cc reviewable, and keep the directory patterns extension-scoped so CUDA/HIP kernels under tests/ stay reviewable.

Alternatives Considered

A test_* prefix pattern (Unity/CMocka) was left out: it would also hide helpers such as test_support.cc, and those test files usually sit under test/ already. Users can already add excludes in .opencodereview/rule.json, but every C/C++ user has to discover and repeat that.

Affected Area

  • Review Rules

Additional Context

Related to #1971 (Cargo tests and benchmarks).

A PR implementing this is opened right after this issue.

AI disclosure: used Claude Code (Claude Opus 5.5) while inspecting the codebase and writing this change.

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