-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Allow developers to run flutter driver web test directly #51084
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
Conversation
| import '../base/file_system.dart'; | ||
| import '../base/process.dart'; | ||
| import '../build_info.dart'; | ||
| import '../build_runner/devfs_web.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cant let this implementation leak into the rest of the tool. There is an interface that flutter run uses, this needs to go through the same indirection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. Have this fixed by creating a getter on ResidentRunner.
| // TODO(angjieli): remove this once running against | ||
| // target under test_driver in debug mode is supported | ||
| throwToolExit( | ||
| 'Flutter Driver web does not support running in debug mode.\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: align and indent 2 spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| if (result != 0) { | ||
| throwToolExit(null, exitCode: result); | ||
| } | ||
| final WebDevFS webDevFS = (runner as ResidentWebRunner).device.devFS as WebDevFS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a better way to surface this URI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| bool get isRunningRelease => debuggingOptions.buildInfo.isRelease; | ||
| bool get supportsServiceProtocol => isRunningDebug || isRunningProfile; | ||
|
|
||
| Uri get uri => flutterDevices.first.devFS.baseUri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: document as the URI of the first connected device for mobile, and only connected device for web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also when it will be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
|
||
| @override | ||
| Uri get baseUri => null; | ||
| Uri get baseUri => _baseUri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a simple unit test for the run_hot tests and the resident web runner tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| entrypoint, | ||
| ); | ||
| return Uri.parse('http://$hostname:$port'); | ||
| _baseUri = Uri.parse('http://$hostname:$port'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be the correct information depending on what you need to connect to. For example, hostname might be something like a corp workstation hostname that needs to be resolved to an actual network address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our use case, the application and test will be on the same machine so this should be fine.
|
Thanks a lot @angjieli /cc @yjbanov I also added a new repository which has code for downloading the drivers: flutter/web_installers#1 I'll combine these in a smoke test so that we will have flutter web engine end to end tested: #51003 |
| ResidentRunner runner; | ||
| final FlutterProject flutterProject = FlutterProject.current(); | ||
| final FlutterDevice flutterDevice = await FlutterDevice.create( | ||
| device, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 2 space indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| // need to know about analytics. | ||
| // | ||
| // Do not add more operations to the future. | ||
| final Completer<void> appStartedTimeRecorder = Completer<void>.sync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you be awaiting this so that you're sure runner.uri is not null? Also, make it a regular completer and rename to reflect its current purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| urlTunneller: null, | ||
| ); | ||
|
|
||
| // Sync completer so the completing agent attaching to the resident doesn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment isn't relevant to this code anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code is not updated yet..Seems like there are something wrong with Github.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code updated.
| } | ||
|
|
||
| @override | ||
| Future<void> exitApp() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I just noticed these changes here. Shutting down a web app is a bit complicated - does this change modify the behavior of flutter run -d chrome or flutter run -d chrome --release when quiting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it does not. We got the same behavior.
jonahwilliams
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
This pull request is not suitable for automatic merging in its current state.
|
| 'Flutter Driver web does not support running in debug mode.\n' | ||
| '\n' | ||
| 'Use --profile mode for testing application performance.\n' | ||
| 'Use --release mode for testing correctness (with assertions).' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to address this in the next PRs?
As a team we are also have usecase for the driver tests in the debug mode as well. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a driver bug so @jonahwilliams probably knows more about it.
Currently, you will also get an error when running flutter run --target=test_driver/scroll_perf_web.dart --debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this should probably work at ToT
|
|
||
| if (webUri != null) { | ||
| platformArgs['uri'] = webUri.toString(); | ||
| // For web device, startApp will be triggered twice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think --start-paused only works in debug mode, so this only needs to happen in profile/release mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
… app. Clean flutter run command from cirrus.yml
* smoke test for web * fix comments and remove logs * addressing reviewer comments * fix analyzer issue * running the test on cirrus * cirrus yaml syntax error * pub get for web_drivers * go to the examples directory before running the flutter app * cirrus is not able to find chromedriver. add a sleep to see if timing is the issue. * run chrome driver in the background * After PR #51084, flutter drive command can build and run a web app. Clean flutter run command from cirrus.yml * enable web
Description
Previously, running
flutter drivecommand against web devices would require developer to runflutter runto start the application first and specify--use-existing-appargument.This PR is going to support running
flutter drivecommand against web platform without starting the application.For example, you can run
flutter drive --target=test_driver/scroll_perf_web.dart -d web-server --release --browser-name=firefoxunderexamples/flutter_gallery.Note that it does not support
debugmode for now (due to compiler error).Related Issues
#51083
Tests
I added the following tests:
Updated test flutter_tools/test/commands.shard/hermetic/drive_test.dart.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.