[PATCH] D44925: [Testing/Support]: Better matching of Error failure states

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 27 06:24:05 PDT 2018


labath created this revision.
labath added reviewers: zturner, lhames.

The existing Failed() matcher only allowed asserting that the operation
failed, but it was not possible to verify any details of the returned
error.

This patch adds two new matchers, which make this possible:

- Failed<InfoT>() verifies that the operation failed with a single error of a given type.
- Failed<InfoT>(M) additionally check that the contained error info object is matched by the nested matcher M.

To make these work, I've changed the implementation of the ErrorHolder
class. Now, instead of just storing the string representation of the
Error, it fetches the ErrorInfo objects and stores then as a list of
shared pointers. This way, ErrorHolder remains copyable, while still
retaining the full information contained in the Error object.

In case the Error object contains two or more errors, the new matchers
will fail to match, instead of trying to match all (or any) of the
individual ErrorInfo objects. This seemed to be the most sensible
behavior for when one wants to match exact error details, but I could be
convinced otherwise...


Repository:
  rL LLVM

https://reviews.llvm.org/D44925

Files:
  include/llvm/Testing/Support/Error.h
  include/llvm/Testing/Support/SupportHelpers.h
  lib/Testing/Support/Error.cpp
  unittests/Support/ErrorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44925.139911.patch
Type: text/x-patch
Size: 6329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180327/8acd0f52/attachment.bin>


More information about the llvm-commits mailing list