Repository navigation
feat(allowlist): exclude C and C++ test and benchmark paths - #2081
Conversation
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.
|
✅ 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}", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I use Boost for the
qmanproject, 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.
There was a problem hiding this comment.
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
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_benchmarksources.**/{test,tests,unittests}/**/*.{c,h,cc,cpp,cxx,hpp,hxx}: CTest/Catch2test/andtests/trees and LLVM-styleunittests/, 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 astest_support.cc), header suffixes, and abenchmark/orbenchmark.*pattern (google/benchmark's own library source issrc/benchmark.cc). The directory patterns list C/C++ extensions only, so CUDA/HIP kernels undertests/stay reviewable as the existing CUDA cases require. A project whose real headers live in a directory namedtest/can bring them back withinclude.The localized
review-rules.mdpages (en, ja, ko, ru, tr, zh) list the new patterns.Type of Change
How Has This Been Tested?
make testpasses locallyManual 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.cukernel undertests/. Added matchingwhyExcludedcases ininternal/agentandinternal/scan.LC_ALL=C go test ./internal/config/allowlist/... ./internal/agent/ ./internal/scan/passes;./internal/config/rules -run PatternMatchpasses.gofmt -s -landgo vetare clean on the changed packages.Checklist
go fmt,go vet)Used Claude Code (Claude Opus 5.5).
Related Issues
Closes #2079