Skip to content

feat(allowlist): exclude C and C++ test and benchmark paths - #2081

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
alex09x:feat/exclude-c-cpp-tests
Nov 25, 2026
Merged

lizhengfeng101 merged 1 commit into
alibaba:mainfrom
alex09x:feat/exclude-c-cpp-tests

Conversation

@alex09x

@alex09x alex09x commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Description

C and C++ had no default test-path exclusions, while most other supported languages do. This PR adds three extension-scoped patterns to internal/config/allowlist/default_exclude_patterns.json:

  • **/*_{test,tests,unittest,benchmark}.{c,cc,cpp,cxx}: GoogleTest/Abseil _test, _tests, Chromium _unittest, Google Benchmark _benchmark sources.
  • **/{test,tests,unittests}/**/*.{c,h,cc,cpp,cxx,hpp,hxx}: CTest/Catch2 test/ and tests/ trees and LLVM-style unittests/, including their helper headers.
  • **/{bench,benchmarks}/**/*.{c,h,cc,cpp,cxx,hpp,hxx}: benchmark trees.

Deliberately not added: a test_* prefix (it would hide helpers such as test_support.cc), header suffixes, and a benchmark/ or benchmark.* pattern (google/benchmark's own library source is src/benchmark.cc). The directory patterns list C/C++ extensions only, so CUDA/HIP kernels under tests/ stay reviewable as the existing CUDA cases require. A project whose real headers live in a directory named test/ can bring them back with include.

The localized review-rules.md pages (en, ja, ko, ru, tr, zh) list the new patterns.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally

  • Manual testing (describe below)

  • Added 29 cases to TestIsExcludedPath. Positive: absl/strings/str_cat_test.cc, src/parser_test.cpp, src/parser_tests.cxx, base/strings/string_util_unittest.cc, absl/strings/str_cat_benchmark.cc, lib/list_test.c, test/test_list.c, tests/catch_main.cpp, libfoo/tests/unit/helpers.hpp, test/support/fake_clock.h, llvm/unittests/ADT/APIntTest.cpp, benchmarks/bm_parser.cc, bench/throughput.c. Negative: ordinary sources and headers, contest.cc, latest.cpp, test_support.h, test_support.cc, unittest_main.cc, src/benchmark.cc, src/testing/, src/contest/, src/benchmarking/, and a .cu kernel under tests/. Added matching whyExcluded cases in internal/agent and internal/scan.

  • LC_ALL=C go test ./internal/config/allowlist/... ./internal/agent/ ./internal/scan/ passes; ./internal/config/rules -run PatternMatch passes.

  • gofmt -s -l and go vet are clean on the changed packages.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Used Claude Code (Claude Opus 5.5).

Related Issues

Closes #2079

Add GoogleTest, Chromium and Google Benchmark suffixes and the test/,
tests/, unittests/, bench/ and benchmarks/ trees for C and C++ sources
and headers, so test code is no longer reviewed against c.md and cpp.md.
@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

"**/benches/**/*.rs",
"**/*_{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}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/boostorg/test/tree/develop/include/boost/test

Seems like include/boost/test/unit_test.hpp is excluded.
This is part of the testing framework's implementation and public API, so maybe changes here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. You're right that this rule would skip a public Boost.Test header. On balance, I'd keep the directory rule as proposed: I don't think this exception outweighs the benefit of skipping conventional test directories by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Boost for the qman project, so I think it is worth pointing out. Due to the star count (218), it is reasonable for you to skip this. I fine with that as I don't use ocr there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Boost for the qman project, so I think it is worth pointing out. Due to the star count (218), it is reasonable for you to skip this. I fine with that as I don't use ocr there.

I believe this viewpoint has nothing to do with the number of stars.

@wu21-web wu21-web Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just we have a low number of users using Boost (Boost star count is just an indirect indicator), so

I don't think this exception outweighs the benefit of skipping conventional test directories by default.

is true, I agree

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 64e2075 into alibaba:main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants