Unverified Commit a50b465c authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Add --preview-dart-2 to 'flutter test' (#14135)

parent bed71b9a
...@@ -68,6 +68,9 @@ class TestCommand extends FlutterCommand { ...@@ -68,6 +68,9 @@ class TestCommand extends FlutterCommand {
negatable: false, negatable: false,
help: 'Handle machine structured JSON command input\n' help: 'Handle machine structured JSON command input\n'
'and provide output and progress in machine friendly format.'); 'and provide output and progress in machine friendly format.');
argParser.addFlag('preview-dart-2',
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.');
} }
@override @override
...@@ -206,6 +209,7 @@ class TestCommand extends FlutterCommand { ...@@ -206,6 +209,7 @@ class TestCommand extends FlutterCommand {
startPaused: startPaused, startPaused: startPaused,
ipv6: argResults['ipv6'], ipv6: argResults['ipv6'],
machine: machine, machine: machine,
previewDart2: argResults['preview-dart-2'],
); );
if (collector != null) { if (collector != null) {
......
...@@ -62,7 +62,8 @@ Future<String> compile( ...@@ -62,7 +62,8 @@ Future<String> compile(
bool aot : false, bool aot : false,
bool strongMode : false, bool strongMode : false,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
String incrementalCompilerByteStorePath}) async { String incrementalCompilerByteStorePath,
String packagesPath}) async {
final String frontendServer = artifacts.getArtifactPath( final String frontendServer = artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk Artifact.frontendServerSnapshotForEngineDartSdk
); );
...@@ -85,12 +86,12 @@ Future<String> compile( ...@@ -85,12 +86,12 @@ Future<String> compile(
command.add('--strong'); command.add('--strong');
} }
if (incrementalCompilerByteStorePath != null) { if (incrementalCompilerByteStorePath != null) {
command.addAll(<String>[ command.add('--incremental');
'--incremental',
'--byte-store',
incrementalCompilerByteStorePath]);
fs.directory(incrementalCompilerByteStorePath).createSync(recursive: true);
} }
if (packagesPath != null) {
command.addAll(<String>['--packages', packagesPath]);
}
if (extraFrontEndOptions != null) if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions); command.addAll(extraFrontEndOptions);
command.add(mainPath); command.add(mainPath);
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:stream_channel/stream_channel.dart'; import 'package:stream_channel/stream_channel.dart';
...@@ -56,6 +58,7 @@ void installHook({ ...@@ -56,6 +58,7 @@ void installHook({
bool enableObservatory: false, bool enableObservatory: false,
bool machine: false, bool machine: false,
bool startPaused: false, bool startPaused: false,
bool previewDart2: false,
int observatoryPort, int observatoryPort,
InternetAddressType serverType: InternetAddressType.IP_V4, InternetAddressType serverType: InternetAddressType.IP_V4,
}) { }) {
...@@ -71,6 +74,7 @@ void installHook({ ...@@ -71,6 +74,7 @@ void installHook({
startPaused: startPaused, startPaused: startPaused,
explicitObservatoryPort: observatoryPort, explicitObservatoryPort: observatoryPort,
host: _kHosts[serverType], host: _kHosts[serverType],
previewDart2: previewDart2,
), ),
); );
} }
...@@ -88,6 +92,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -88,6 +92,7 @@ class _FlutterPlatform extends PlatformPlugin {
this.startPaused, this.startPaused,
this.explicitObservatoryPort, this.explicitObservatoryPort,
this.host, this.host,
this.previewDart2,
}) : assert(shellPath != null); }) : assert(shellPath != null);
final String shellPath; final String shellPath;
...@@ -97,6 +102,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -97,6 +102,7 @@ class _FlutterPlatform extends PlatformPlugin {
final bool startPaused; final bool startPaused;
final int explicitObservatoryPort; final int explicitObservatoryPort;
final InternetAddress host; final InternetAddress host;
final bool previewDart2;
// Each time loadChannel() is called, we spin up a local WebSocket server, // 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 // then spin up the engine in a subprocess. We pass the engine a Dart file
...@@ -191,14 +197,28 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -191,14 +197,28 @@ class _FlutterPlatform extends PlatformPlugin {
)); ));
// Start the engine subprocess. // 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( final Process process = await _startProcess(
shellPath, shellPath,
listenerFile.path, mainDart,
packages: PackageMap.globalPackagesPath, packages: PackageMap.globalPackagesPath,
enableObservatory: enableObservatory, enableObservatory: enableObservatory,
startPaused: startPaused, startPaused: startPaused,
observatoryPort: explicitObservatoryPort, observatoryPort: explicitObservatoryPort,
bundlePath: bundlePath,
); );
subprocessActive = true; subprocessActive = true;
finalizers.add(() async { finalizers.add(() async {
...@@ -466,6 +486,7 @@ void main() { ...@@ -466,6 +486,7 @@ void main() {
String executable, String executable,
String testPath, { String testPath, {
String packages, String packages,
String bundlePath,
bool enableObservatory: false, bool enableObservatory: false,
bool startPaused: false, bool startPaused: false,
int observatoryPort, int observatoryPort,
...@@ -492,6 +513,9 @@ void main() { ...@@ -492,6 +513,9 @@ void main() {
} }
if (host.type == InternetAddressType.IP_V6) if (host.type == InternetAddressType.IP_V6)
command.add('--ipv6'); command.add('--ipv6');
if (bundlePath != null) {
command.add('--flutter-assets-dir=$bundlePath');
}
command.addAll(<String>[ command.addAll(<String>[
'--enable-dart-profiling', '--enable-dart-profiling',
'--non-interactive', '--non-interactive',
......
...@@ -28,6 +28,7 @@ Future<int> runTests( ...@@ -28,6 +28,7 @@ Future<int> runTests(
bool startPaused: false, bool startPaused: false,
bool ipv6: false, bool ipv6: false,
bool machine: false, bool machine: false,
bool previewDart2: false,
TestWatcher watcher, TestWatcher watcher,
}) async { }) async {
// Compute the command-line arguments for package:test. // Compute the command-line arguments for package:test.
...@@ -75,6 +76,7 @@ Future<int> runTests( ...@@ -75,6 +76,7 @@ Future<int> runTests(
machine: machine, machine: machine,
startPaused: startPaused, startPaused: startPaused,
serverType: serverType, serverType: serverType,
previewDart2: previewDart2,
); );
// Make the global packages path absolute. // Make the global packages path absolute.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment