Skip to content

Conversation

@matanlurey
Copy link
Contributor

@matanlurey matanlurey commented Dec 18, 2024

Work towards #143299.
Work towards #160043.


This PR implements, end-to-end, support for matchesGoldenFile when (a) running with package:integration_test (b) on a device, such as an Android emulator, Android device, iOS simulator, or iOS device, where the runner of a test file does not have process and local-file system access.

There are multiple parts to this PR; I could make it smaller than 1K lines, but the bulk of that is tests, and it would mean landing PRs that are incomplete and unused, which does not seem useful - so instead here is a quick overview of the PR's contents - questions/feedback welcome, and I am willing to break code out or land incremental refactors if requested.

  1. Augmented flutter_platform.dart (used for iOS and Android), similar to flutter_web_platform.dart, now creates and uses test_golden_comparator.dart to proxy calls (coming from the VM service protocol) for golden-file updates and comparisons to a flutter_tester process. A full explanation of how (or why) it works this way is too hard to include here, but see Refactor TestGoldenComparator to be useful for non-web (Android, iOS) integration tests #160215 for more details.
  2. Added VmServiceProxyGoldenFileComparator, which is a currently unused (outside of a single e2e test) comparator that forwards calls to compare and update to the VM service protocol (of which, the other side of this is implemented above, in flutter_platform.dart. The idea is that this comparator would be used automatically when running in an integration test on a device that requires it (similar to how web works today), but that is not wired up yet and requires additional work in flutter_tools.
  3. Added two unit tests (of both the client and server), and a full e2e-test using it to run matchesGoldenFile.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests tool Affects the "flutter" command-line tool. See also t: labels. framework flutter/packages/flutter repository. See also f: labels. f: integration_test The flutter/packages/integration_test plugin labels Dec 18, 2024
@matanlurey matanlurey marked this pull request as ready for review December 19, 2024 21:39
Copy link
Contributor

@andrewkolos andrewkolos left a comment

Choose a reason for hiding this comment

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

LGTM

final IsolateRef testAppIsolate = await vmService.findExtensionIsolate(_kExtension);
await vmService.service.streamListen(_kEventName);
vmService.service.onEvent(_kEventName).listen((Event e) async {
if (e.extensionKind != 'compare' && e.extensionKind != 'update') {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: !['compare', 'update'].contains(e.extensionKind) might read a little better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// <String, Object?>{
/// 'result': true /* or possibly false, in the case of 'compare' calls */
/// }
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the details of the message/response public API? Not sure why these need to be under ///. Maybe make them //?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not clear to me what is/isn't public API here - for example, another package (flutter_tools) needs to fulfill this API for the feature to work.

I am going to keep it as-is for now.

if (kIsWeb) {
return false;
}
return !io.Platform.isAndroid && !io.Platform.isIOS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these the only platforms that separate device from host?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, yes.


static void _assertNotRunningOnFuchsia() {
if (!kIsWeb && io.Platform.isFuchsia) {
throw UnsupportedError('Fuchsia is not supported');
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider a more specific error message, e.g. "integration_test golden testing does not support Fuchsia".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 27, 2024

auto label is removed for flutter/flutter/160484, due to - The status or check suite Merge Queue Guard has failed. Please fix the issues identified (or deflake) before re-applying this label.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 27, 2024

auto label is removed for flutter/flutter/160484, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 27, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
cbracken added a commit to cbracken/flutter that referenced this pull request Jan 9, 2025
Ignore the golden file associated with
packages/integration_test/example/integration_test/integration_test_matches_golden_file.png

Test (and functionality) introduced in flutter#160484.
github-merge-queue bot pushed a commit that referenced this pull request Jan 10, 2025
Ignore the golden file associated with

packages/integration_test/example/integration_test/integration_test_matches_golden_file.png

Test (and functionality) introduced in #160484.

Related issues:
* #143299.
* #160043.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [X] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests f: integration_test The flutter/packages/integration_test plugin framework flutter/packages/flutter repository. See also f: labels. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants