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:
|
…namespaces Nine misc-use-internal-linkage sites, the last of three batches after open-telemetry#4301 and open-telemetry#4302. tracer_test.cc had an anonymous namespace holding only initTracer(), with the three mock classes above it, so that namespace is extended over them rather than joined by a second one. measurements_benchmark.cc is the same shape, with MockMetricExporter pulled into the existing namespace. The other three get a namespace around the test body. batch_span_processor_test.cc already sits inside a named namespace via OPENTELEMETRY_BEGIN_NAMESPACE; the anonymous namespace nests inside it and covers every class and TEST in the file. Its BatchSpanProcessorTestPeer and the metrics file's AlignedHistogramBucketExemplarReservoirTestPeer are the only TEST_F suite names here, and each is unique to its file, so this does not repeat the all_tests redefinition from open-telemetry#4217. The warning limit drops by nine on both presets, 151 to 142 and 161 to 152. None of these are ABI gated. This branch is cut from main. If open-telemetry#4301 or open-telemetry#4302 merge first, the limit needs recomputing down by their counts as well. Part of open-telemetry#4196 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Six misc-use-internal-linkage sites, continuing from open-telemetry#4217 and open-telemetry#4286. logger_test.cc had an anonymous namespace already, with TestLogger just above it and TestProvider just below, so the existing namespace is extended to cover both rather than adding two more. string_test.cc is the same shape: its namespace closed immediately before SplitStringTestFixture, so the closing brace moves to the end of the file. The two provider_test.cc files get a namespace around the test body. In the logs one that puts the deprecated-declaration pragma push and pop pair inside the namespace, which is fine since both ends stay on the same side of the boundary. Worth noting that api/test/logs holds two different classes both named TestProvider, in logger_test.cc and provider_test.cc. They are in the same Bazel package, so giving them internal linkage also removes a latent one definition rule hazard. Part of open-telemetry#4196 Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
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).