-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to display *why* a predicate failed #60
Conversation
@nastevens my main concern with having this reviewed is regarding vision
Luckily, I was able to avoid |
@nastevens btw for time table, the goal is to have this PR in, #30 in, and assert_fs / assert_cmd switched over to these changes by the end of the month in preparation for the next 2018 Edition preview. |
a9647cd
to
188a847
Compare
Predicates can now report parameter details that don't show up in `Display` as well as what children they have. The expectation is that this will be used by the solution for assert-rs#7. BREAKING CHANGE: `Predicate`s must also implement `reflection::PredicateReflection`.
This also saw an audit of predicates to ensure their `Display` would most likely remain as one line of text. Anything in a `Display` that seemed likely to overflow was moved to a `Parameter`.
This is the last of the foundation for resolving assert-rs#7.
A non-default implementation is provided for all predicates that can add additional information than what `eval` / `Display` provide. Exceptions - `eq_file`: I want to re-work this predicate - `BoxPredicate`: The where clause is causing problems This is the information needed for resolving assert-rs#7. Now, rendering is the only thing left.
Apparently, a provided function can't downcast `&self` but I can if I spread the implementation around. Overall, trying to meet the goal of making it simple to write a Predicate. Anyone besides us will need to copy `default_find_case` if they want the reference. Not sure what would be a good way to make that good enough for being stable.
Finnaly, Fixes assert-rs#7. Inspired by the work in assert-rs#39. Created softprops/treeline#3 for trying to find ways to make this more efficient.
Output of
case_tree
example:An extension trait is added to make a
Display
able struct that will print out the above tree.find_case
which will find theCase
that prove whether thePredicate
succeeds or fails.Case
only owns by-Product
s of thePredicate
evaluation,parameters
are made available as references on thePredicateReflection
traitCase
API becauseParameter
andProduct
have different ownership requirements.PredicateReflection
is also use to homogenize the predicate treePredicate<[u8]>
,Predicate<str>
, etc.Once this is in, to reduce API breaks from impacting the assert-ecosystem, #30 will be implemented and this repo will be turned into a workspace for
predicate-core
:core.rs
,reflection.rs
predicate-tree
:tree.rs
predicates
predicate-core
aka the only change to most end-users will be
predicate-tree
being removed from the API while the assert-ecosystem will usepredicate_core::Predicate
in its public API.This supersedes #39 due to having an API that we are more comfortable moving to 1.0
item
in theDisplay
, allowing us to avoid requiringItem: Debug
. Instead we just rely on everyPredicate
implementingDisplay
, usually doing so by having anItem: Debug
requirement but clients are free to bypass that by creating their ownPredicate
.BREAKING CHANGES
PredicateReflection
. Provided methods make this aimpl PredicateReflection for X {}