Repository navigation
allow golden tests to specify epsilon tolerance - #77703
lukepighetti wants to merge 3 commits into
Conversation
|
Hey @lukepighetti thanks for the contribution! I looked at doing this in #76545 but found some issues with it. Changing the signature of I am planning on adding some sample code that shows how to do that, I think flutter/cocoon creates their own comparator where we'll be doing something similar. :) |
|
Closing due to #76337 (comment) and above comment, thanks Kate! |
|
It looks like the easiest path forward is to copy-paste LocalFileComparator and change this line if (!result.passed) {
final String error = await generateFailureOutput(result, golden, basedir);
throw FlutterError(error);
}to this line final acceptableDiffPercent = 0.01;
if (!result.diffPercent < acceptableDiffPercent) {
final String error = await generateFailureOutput(result, golden, basedir);
throw FlutterError(error);
}is that about right? |
|
After #77825, it's possible to do it this way: flutter/cocoon#1106 :) |
|
@Piinks Gotcha, that's super helpful. How does one feed |
There are a couple of ways to do it. The But the and here:
So, we don't really want to make this easy to do. 😜 We don't want to recommend relying on setting a tolerance level for golden files. Adding a
I believe the cocoon implementation affords a unique comparator for each test, while the flutter_goldens approach creates a comparator for each test file. You can use either one and modify to your preference. :) |
|
It's true that the desire for golden tolerance is due to something that I would consider broken (if you run goldens on different operating systems you get different results), but we've needed relief from this for the last three years so I'm very happy to be able to make use of it until that issue can be resolved. Thanks for your efforts in this area and I look forward to using golden tests again soon with toleranced comparisons. |
This PR adds the ability to specify an epsilon tolerance on any golden test.
Closes issues:
#76337
May close issue:
#56383 (comment)
Related PR:
#76545
No migration steps are necessary.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.