pw_unit_test: Disable non-const global variable warnings for TestInfo
TestInfo objects are not const in order to support the
PW_UNIT_TEST_LINK_FILE_CONTAINING_TEST() macro. Disable clang-tidy
warnings related to non-const globals.
Change-Id: I89ac45df0d6fffc374406adf7027cb9a54be1f88
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/109719
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Bjorn Mellem <mellem@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/pw_unit_test/public/pw_unit_test/internal/framework.h b/pw_unit_test/public/pw_unit_test/internal/framework.h
index 5fa73b2..237ea87 100644
--- a/pw_unit_test/public/pw_unit_test/internal/framework.h
+++ b/pw_unit_test/public/pw_unit_test/internal/framework.h
@@ -490,22 +490,25 @@
test_suite_name##_##test_name##_Test, \
parent_class)
-#define _PW_TEST_CLASS(suite, name, class_name, parent_class) \
- class class_name final : public parent_class { \
- private: \
- void PigweedTestBody() override; \
- }; \
- \
- extern "C" { \
- \
- ::pw::unit_test::internal::TestInfo _pw_unit_test_Info_##suite##_##name( \
- #suite, \
- #name, \
- __FILE__, \
- ::pw::unit_test::internal::Framework::CreateAndRunTest<class_name>); \
- \
- } /* extern "C" */ \
- \
+#define _PW_TEST_CLASS(suite, name, class_name, parent_class) \
+ class class_name final : public parent_class { \
+ private: \
+ void PigweedTestBody() override; \
+ }; \
+ \
+ extern "C" { \
+ \
+ /* Declare the TestInfo as non-const since const variables do not work */ \
+ /* with the PW_UNIT_TEST_LINK_FILE_CONTAINING_TEST macro. */ \
+ /* NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) */ \
+ ::pw::unit_test::internal::TestInfo _pw_unit_test_Info_##suite##_##name( \
+ #suite, \
+ #name, \
+ __FILE__, \
+ ::pw::unit_test::internal::Framework::CreateAndRunTest<class_name>); \
+ \
+ } /* extern "C" */ \
+ \
void class_name::PigweedTestBody()
#define _PW_TEST_ASSERT(expectation) \