Reimplement CHECK_IS_TEST() on top of CHECK()
This lets us inherit various NOMERGE tags and inline the CHECK_IS_TEST()
into the caller. This should help prevent all CHECK_IS_TEST() from
merging which makes them hard to debug.
Bug: 378957522
Change-Id: I8422423096edb502b0f59b71b5e49616df519cd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6021864
Commit-Queue: Peter Boström <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Reviewed-by: Maksim Ivanov <[email protected]>
Reviewed-by: Roland Bock <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1385259}
diff --git a/base/check_is_test.h b/base/check_is_test.h
index 074b7022..b2c5780a 100644
--- a/base/check_is_test.h
+++ b/base/check_is_test.h
@@ -9,10 +9,6 @@
#include "base/check.h"
#include "base/not_fatal_until.h"
-namespace web_app {
-class OsIntegrationTestOverride;
-}
-
// Code paths taken in tests are sometimes different from those taken in
// production. This might be because the respective tests do not initialize some
// objects that would be required for the "normal" code path.
@@ -44,24 +40,14 @@
// instance non-fatal (dumps without crashing) before a provided milestone.
// See base/check.h for details.
-#define CHECK_IS_TEST(...) base::internal::check_is_test_impl(__VA_ARGS__)
-
namespace base::internal {
-BASE_EXPORT void check_is_test_impl(
- base::NotFatalUntil fatal_milestone =
- base::NotFatalUntil::NoSpecifiedMilestoneInternal);
-
-// This class facilitates an allow-list for GetIsInTest(), helping prevent
-// possible misuse.
-class BASE_EXPORT IsInTest {
- private:
- friend class web_app::OsIntegrationTestOverride;
- static bool Get();
-};
+BASE_EXPORT bool get_is_test_impl();
} // namespace base::internal
-// In special cases, code should not execute in a test. This functionality is
-// protected by the list of friends in `IsInTest`.
-#define CHECK_IS_NOT_TEST() CHECK(!base::internal::IsInTest::Get())
+#define CHECK_IS_TEST(...) \
+ CHECK(base::internal::get_is_test_impl() __VA_OPT__(, ) __VA_ARGS__)
+
+// In special cases, code should not execute in a test.
+#define CHECK_IS_NOT_TEST() CHECK(!base::internal::get_is_test_impl())
#endif // BASE_CHECK_IS_TEST_H_