Repository navigation
Conversation
CaseyHillers
left a comment
There was a problem hiding this comment.
LGTM, thank you for the quick turn around!
| double _tolerance = 0.0; | ||
|
|
||
| @override | ||
| void setPrecisionTolerance(double precisionTolerance) { |
There was a problem hiding this comment.
Could the base class "GoldenFileComparator" just have a getter/setter for this?
| throw 'must provide a Finder, Image, or Future<Image>'; | ||
| } | ||
|
|
||
| goldenFileComparator.setPrecisionTolerance(precisionTolerance); |
There was a problem hiding this comment.
Instead of modifying the global state of the goldenFileComparator (which could be a surprising side effect), could the tolerance just be passed in below to the compare method?
There was a problem hiding this comment.
I thought of going that route, but it might be more breaking that way. Still evaluating. The comparator class (and therefore compare function) is extended/implemented/overridden by many customers.
| double get precisionTolerance => _precisionTolerance; | ||
| double _precisionTolerance = 0.0; | ||
| /// Sets an allowable percentage of difference between golden file images. | ||
| set precisionTolerance(double value) { |
There was a problem hiding this comment.
@goderbauer I made this getter/setter instead, it has ramifications for subclasses like the regular and web Trivial* comparators.. Not sure which is better.
|
I am not convinced adding this is a good idea yet, especially after conversation in #76831 @CaseyHillers what if this was just reduced to exposing the calculated diff in |
Either SGTM. In flutter/cocoon, the tests use a cocoon wrapper util for golden tests, so it's a one line change. As another data point, not surfacing this as a parameter should have an example of constructing a comparator that can be used for enabling a diff tolerance. |
|
I am going to close this and open a new PR to expose the ComparisonResult.diff, it'll be easier to start fresh than revert here. :) |
|
@Piinks I tried #77014 and I have some feedback. I put it in here because the discussion in here is most pertinent to my feedback.
I'm trying this out now and I'm not sure how to proceed. There are private methods we don't have access to. Once you start unraveling that you're better off doing a copy-paste from what I can tell. From #76545 (comment)
I know the ship has sailed, but IMHO that's a non-issue because you can make a curried version of |
|
Hey @lukepighetti! Thanks for the feedback. While implementing a custom comparator for flutter/cocoon (flutter/cocoon#1106), I too found this difficult. I just made some changes the other day to make this easier in #77825 |

This adds the ability to specify a tolerance level for golden file comparison.

A good example of this use would be golden files that fail due to very small imperceptible changes, like from Skia rolls.
Here is one such case:
This image fails due to a realllly small diff.
Fixes #76337
Related to #71437
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.