-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Add --preview-dart-2 to 'flutter test' #14135
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| import 'dart:async'; | ||
| import 'dart:convert'; | ||
|
|
||
| import 'package:flutter_tools/src/artifacts.dart'; | ||
| import 'package:flutter_tools/src/compile.dart'; | ||
| import 'package:meta/meta.dart'; | ||
| import 'package:stream_channel/stream_channel.dart'; | ||
|
|
||
|
|
@@ -56,6 +58,7 @@ void installHook({ | |
| bool enableObservatory: false, | ||
| bool machine: false, | ||
| bool startPaused: false, | ||
| bool previewDart2: false, | ||
| int observatoryPort, | ||
| InternetAddressType serverType: InternetAddressType.IP_V4, | ||
| }) { | ||
|
|
@@ -71,6 +74,7 @@ void installHook({ | |
| startPaused: startPaused, | ||
| explicitObservatoryPort: observatoryPort, | ||
| host: _kHosts[serverType], | ||
| previewDart2: previewDart2, | ||
| ), | ||
| ); | ||
| } | ||
|
|
@@ -88,6 +92,7 @@ class _FlutterPlatform extends PlatformPlugin { | |
| this.startPaused, | ||
| this.explicitObservatoryPort, | ||
| this.host, | ||
| this.previewDart2, | ||
| }) : assert(shellPath != null); | ||
|
|
||
| final String shellPath; | ||
|
|
@@ -97,6 +102,7 @@ class _FlutterPlatform extends PlatformPlugin { | |
| final bool startPaused; | ||
| final int explicitObservatoryPort; | ||
| final InternetAddress host; | ||
| final bool previewDart2; | ||
|
|
||
| // Each time loadChannel() is called, we spin up a local WebSocket server, | ||
| // then spin up the engine in a subprocess. We pass the engine a Dart file | ||
|
|
@@ -191,14 +197,28 @@ class _FlutterPlatform extends PlatformPlugin { | |
| )); | ||
|
|
||
| // Start the engine subprocess. | ||
| printTrace('test $ourTestCount: starting shell process'); | ||
| printTrace('test $ourTestCount: starting shell process${previewDart2? " in preview-dart-2 mode":""}'); | ||
|
|
||
| final String mainDart = previewDart2 | ||
| ? await compile( | ||
| sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), | ||
| incrementalCompilerByteStorePath: '' /* not null is enough */, | ||
| mainPath: listenerFile.path, | ||
| packagesPath: PackageMap.globalPackagesPath | ||
| ) | ||
| : listenerFile.path; | ||
|
|
||
| // bundlePath needs to point to a folder with `platform.dill` file. | ||
| final String bundlePath = previewDart2 ? artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) : null; | ||
|
|
||
| final Process process = await _startProcess( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The --strong option needs to be passed to the engine being invoked also as we will want to also test the runtime strong mode checks. |
||
| shellPath, | ||
| listenerFile.path, | ||
| mainDart, | ||
| packages: PackageMap.globalPackagesPath, | ||
| enableObservatory: enableObservatory, | ||
| startPaused: startPaused, | ||
| observatoryPort: explicitObservatoryPort, | ||
| bundlePath: bundlePath, | ||
| ); | ||
| subprocessActive = true; | ||
| finalizers.add(() async { | ||
|
|
@@ -466,6 +486,7 @@ void main() { | |
| String executable, | ||
| String testPath, { | ||
| String packages, | ||
| String bundlePath, | ||
| bool enableObservatory: false, | ||
| bool startPaused: false, | ||
| int observatoryPort, | ||
|
|
@@ -492,6 +513,9 @@ void main() { | |
| } | ||
| if (host.type == InternetAddressType.IP_V6) | ||
| command.add('--ipv6'); | ||
| if (bundlePath != null) { | ||
| command.add('--flutter-assets-dir=$bundlePath'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aam Do you recall why this was needed? It is a bit odd that we are passing the SDK path as the asset dir.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that option is the way how bundle path(that should have platform.dill) is passed to flutter tester(per accompanying flutter/engine#4564).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implies all assets to be used by tester needs to be put in the sdk path. That's quite odd. In platform packaging the dill files are not found in the asset directory. Would it make sense to separate these concerns and change the way the dill files are located in the tester? [probably a new flag]?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it does make sense.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tvolkert FYI I will attempt this if you don't have any objection. The request is to change tester to locate dill files w/o needing the asset flag so we can safely remove this particular line of code in flutter_platform.dart. When we add proper asset support [a separate param to installHook?], we can add it back. If you disagree with the methodology, let me know.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No objection. I agree that a new flag to separate these things for |
||
| } | ||
| command.addAll(<String>[ | ||
| '--enable-dart-profiling', | ||
| '--non-interactive', | ||
|
|
||
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 add parameter strongMode: true
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.
The test fails in strongMode, we won't be able to confirm the flow until flutter and frontend is strong mode clean. Given that I would prefer to add strong mode separately in follow up PR.
Uh oh!
There was an error while loading. Please reload this page.
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.
Ok as discussed off line you will land this PR, follow it up with a PR to make it work on linux too and another PR to add the strong mode option.
It is important to get the strong mode option in as we want to get to the errors quickly.