Skip to content

test: Use color checks that tolerate floating-point errors - #949

Merged
gnprice merged 3 commits into
zulip:mainfrom
chrisbobbe:pr-colors-checks
Sep 18, 2024
Merged

gnprice merged 3 commits into
zulip:mainfrom
chrisbobbe:pr-colors-checks

Conversation

@chrisbobbe

Copy link
Copy Markdown
Member

Done to follow a draft migration guide:
https://github.com/flutter/website/blob/997c893ccec5fb15dd085a4d23fe8c43870c631b/src/content/release/breaking-changes/wide-gamut-framework.md
for the proposed breaking change that raised
flutter/flutter#155113

Some other work was needed outside what's described in that draft;
see:
flutter/flutter#155113 (comment)
flutter/flutter#155113 (comment)

@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Sep 17, 2024
@chrisbobbe
chrisbobbe requested a review from gnprice September 17, 2024 22:43
@chrisbobbe
chrisbobbe marked this pull request as ready for review September 17, 2024 22:43

@gnprice gnprice left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this!

The changes all look good, except that I think a Flutter deps bump is needed before adding the references to isSameColorSwatchAs. (The analyzer is failing for me locally because I have a Flutter tree from a few days ago.)

Some other work was needed outside what's described in that draft;
see:
  https://github.com/flutter/flutter/issues/155113#issuecomment-2347374468
  https://github.com/flutter/flutter/issues/155113#issuecomment-2356356254

I think this work just meant (a) using package:flutter_checks, and (b) those few lines adding a wrapper for isSameColorSwatchAs. Is that right or is there another piece I'm missing?

To ensure `isSameColorSwatchAs` is present; we'll use that in an
upcoming commit. From flutter/flutter#155272.
Thanks lishaduck for creating these with us in mind! Discussion:
  zulip#232 (comment)
Done to follow a draft migration guide:
  https://github.com/flutter/website/blob/997c893ccec5fb15dd085a4d23fe8c43870c631b/src/content/release/breaking-changes/wide-gamut-framework.md
for the proposed breaking change that raised
  flutter/flutter#155113

In our case we also needed to use `package:flutter_checks` and
`package:legacy_checks` to wrap the legacy `Matcher`s
`isSameColorAs` and `isSameColorSwatchAs` from
`package:flutter_test`; see discussion of those:
  flutter/flutter#155113 (comment)
  flutter/flutter#155113 (comment)
@chrisbobbe

Copy link
Copy Markdown
Member Author

Yep! Revision pushed, PTAL.

@gnprice
gnprice merged commit cdbe141 into zulip:main Sep 18, 2024
@gnprice

gnprice commented Sep 18, 2024

Copy link
Copy Markdown
Member

Thanks! Looks good — merging.

Comment on lines +6 to +11
extension ColorSwatchChecks<T> on Subject<ColorSwatch<T>> {
/// package:checks-style wrapper for [flutter_matcher.isSameColorSwatchAs].
void isSameColorSwatchAs(ColorSwatch<T> colorSwatch) {
legacyMatcher(flutter_matcher.isSameColorSwatchAs(colorSwatch));
}
}

@lishaduck lishaduck Sep 19, 2024 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'm glad legacy_checks was useful!
I was worried I'd missed one for a second before I realized it was new. I know y'all follow the master channel, so, as I don't think I wrote down a flutter version support policy anywhere, I guess I'll just note here that I don't want to publish anything that makes it unnecessarily require a "nightly". I'm happy to accept PRs once they land in stable, but you'll probably still need to maintain a few of these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that approach makes sense.

Thanks to legacyMatcher, any individual wrappers like this one should be pretty cheap to write, like this one was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants