abseil-cpp
abseil-cpp copied to clipboard
absl::Status matchers in googletest
This may be more of a question for googletest. Now that absl::Status is available, I was wondering if the community should expect a corresponding set of matchers such as EXPECT_OK. It would make testing code that returns absl::Status nicer.
Some of the maintainers of Abseil also maintain GoogleTest :-)
The answer is that we do plan on releasing the absl::Status matchers, though the plan is to release them in Abseil, not GoogleTest.
There are some things that we have to figure out how to deal with though. Abseil doesn't release forks of code, though sometimes we do strip out features. It would be easy if we just forked them, but it would make maintenance harder. We do have a plan to deal with the issues, but it will take some time. I can't give you an estimate of when this might happen.
If you need them in the short term, you might be able to copy a simple implementation from https://github.com/abseil/abseil-cpp/blob/bcc11a8918f8cc9b43c9a0dc5da7b52d48452bd3/absl/status/statusor_test.cc#L46-L161
Awesome, thanks! Looking forward to it!
Also, I'm happy to contribute to abseil the RETURN_IF_ERROR and ASSIGN_OR_RETURN macros as seen elsewhere on the web if the project finds them useful (and if plans aren't already underway).
It would be great to have RETURN_IF_ERROR and ASSIGN_OR_RETURN macros in the public API, since these help a lot to write concise yet fairly readable code IMHO.
Just wanted to bubble this back up now that GoogleTest has officially announced plans to take on abseil as a dependency :).
Until RETURN_IF_ERROR and ASSIGN_OR_RETURN become part of abseil, I've posted a bazel target for them here.
Are there any updates to this? Currently, there are various versions of these matchers floating around in various OSS projects. Having an officially-supported version of the macros, as well as matchers like IsStatus, will be greatly helpful.
Are there any updates to this? Currently, there are various versions of these matchers floating around in various OSS projects. Having an officially-supported version of the macros, as well as matchers like IsStatus, will be greatly helpful.
Someone (not me) is actively working on this. There is a surprising amount of work though.
The absl::Status GoogleTest matchers are now published: https://github.com/abseil/abseil-cpp/blob/master/absl/status/status_matchers.h
Note that EXPECT_OK is intentionally not included. Use EXPECT_THAT(status, IsOk()) instead.
The macros like RETURN_IF_ERROR are probably a few months away. We currently believe that there are some performance wins we can get by changing their current interface, so we want to investigate making that change before releasing them.
Woot! Thanks @derekmauro!