A framework for building native applications using React
Better source locations for EXPECT_CALL failures (#54129)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54129 Changelog: [Internal] The team maintaining gmock is [uninterested, as a matter of principle,](https://github.com/google/googletest/issues/2646#issuecomment-630919122) in improving the ergonomics of writing helper functions around `EXPECT_CALL`. However, such helpers have proven very useful for the `jsinspector-modern` C++ test suite. The out-of-the-box ergonomics *are* pretty bad, though, so this diff tries to improve the situation. The biggest offender in our test suite is the `expectMessageFromPage` helper function - if a test fails because an expectation isn't met, the error message points to the `EXPECT_CALL` line inside `expectMessageFromPage`, which is utterly useless compared to the line of test code that *called* `expectMessageFromPage`. Here, we reach into gmock's internals slightly to create a variant of the `EXPECT_CALL` macro that allows passing in a [`std::source_location`](https://en.cppreference.com/w/cpp/utility/source_location.html) (thanks, C++20!). We then teach `expectMessageFromPage` and other such helpers to capture a source location at the call site (using a parameter with a default value to `source_location::current()`) and use the modified macro to pass it into gmock. Reviewed By: huntie Differential Revision: D84368993 fbshipit-source-id: 62f64b6c5f626a54bc3da7143d84ee2d75d16ac6
M
Moti Zilberman committed
74d3472e2fb8577f5180257f33d9d6e3d6f40f95
Parent: f7cc2e5
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 10/21/2025, 3:19:02 PM