[CODE HEALTH] Move api/test and sdk/test classes into anonymous namespace#4217
Conversation
|
CI failure, to investigate: |
…pace Wrap file-local test helper classes in an anonymous namespace to enforce internal linkage (clang-tidy misc-use-internal-linkage), across 20 files under api/test and sdk/test, and lower the warning_limit to 278/288 accordingly. Part of open-telemetry#2053 / open-telemetry#4196. Four metrics test files (async_metric_storage_test and sync_metric_storage_{counter,gauge,up_down_counter}) share the fixture class name WritableMetricStorageTestFixture. Bazel links all of sdk/test/metrics into a single //sdk/test/metrics:all_tests binary, where gtest keys each test suite by the fixture class name. Moving these same-named fixtures into per-translation-unit anonymous namespaces turns them into distinct types registered under one suite name and aborts with "Attempted redefinition of test suite WritableMetricStorageTestFixture". Those four files are left as-is here and deferred to a follow-up that either renames the fixtures or hoists a shared one into a header. The remaining files (exporters, ext, functional, and a few needing manual handling) also follow in later batches. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
3a3ce6a to
bdd6dff
Compare
|
Thanks for flagging this, fixed and pushed. Those four files (async_metric_storage_test and the sync_metric_storage counter/gauge/up_down_counter ones) all declare Renaming as the gtest message suggests would work, but a test-suite rename feels out of place in a plain internal-linkage cleanup, so I've put those four back to their state on main and left them out of this batch. That takes the PR down to 20 files with the limit at 278/288. I'll pick the four up separately, either renaming the fixtures or hoisting a shared one into a header, whichever you'd rather see. I didn't catch this locally because I was verifying with the CMake clang-tidy build, which links each test into its own binary and never exercises the combined target. I've added a duplicate-fixture-name check across the batch so it won't slip through again. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4217 +/- ##
=======================================
Coverage 82.83% 82.83%
=======================================
Files 415 415
Lines 17423 17423
=======================================
Hits 14431 14431
Misses 2992 2992 🚀 New features to boost your workflow:
|
Changes
Part of #4196 (and #2053). Wraps file-local test helper classes in an anonymous namespace to enforce internal linkage, resolving the
misc-use-internal-linkagewarnings across 20 files underapi/testandsdk/test. This follows the same approach as #4199 and #4200.To keep the review manageable, this is the first batch. The remaining files (under
exporters,ext, andfunctional, plus a few that need manual handling due to existing or nested namespaces) will follow in later batches. The files that overlap with my other open code-health PRs (#4215, #4216) are also deferred to avoid conflicts.Four metrics tests that share the
WritableMetricStorageTestFixturefixture (async_metric_storage_test and the sync_metric_storage counter/gauge/up_down_counter tests) are also deferred. They are linked together into//sdk/test/metrics:all_tests, and moving same-named fixtures into per-file anonymous namespaces makes gtest treat them as a redefinition of one test suite. They will be handled in a follow-up that renames the fixtures or shares one via a header.Verification
warning_limitlowered from 309/319 to 278/288 (the current baseline minus the 31 resolved here).Note: this touches the same
warning_limitline as #4215 and #4216. Whichever of these merges first, I will rebase the others accordingly (the final limit after all three is lower).