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

This commit is contained in:
Alexander Aprelev 2018-01-19 06:17:28 -08:00 committed by GitHub
parent bed71b9a15
commit a50b465c99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 8 deletions

View file

@ -68,6 +68,9 @@ class TestCommand extends FlutterCommand {
negatable: false,
help: 'Handle machine structured JSON command input\n'
'and provide output and progress in machine friendly format.');
argParser.addFlag('preview-dart-2',
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.');
}
@override
@ -206,6 +209,7 @@ class TestCommand extends FlutterCommand {
startPaused: startPaused,
ipv6: argResults['ipv6'],
machine: machine,
previewDart2: argResults['preview-dart-2'],
);
if (collector != null) {

View file

@ -62,7 +62,8 @@ Future<String> compile(
bool aot : false,
bool strongMode : false,
List<String> extraFrontEndOptions,
String incrementalCompilerByteStorePath}) async {
String incrementalCompilerByteStorePath,
String packagesPath}) async {
final String frontendServer = artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk
);
@ -85,12 +86,12 @@ Future<String> compile(
command.add('--strong');
}
if (incrementalCompilerByteStorePath != null) {
command.addAll(<String>[
'--incremental',
'--byte-store',
incrementalCompilerByteStorePath]);
fs.directory(incrementalCompilerByteStorePath).createSync(recursive: true);
command.add('--incremental');
}
if (packagesPath != null) {
command.addAll(<String>['--packages', packagesPath]);
}
if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions);
command.add(mainPath);

View file

@ -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(
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');
}
command.addAll(<String>[
'--enable-dart-profiling',
'--non-interactive',

View file

@ -28,6 +28,7 @@ Future<int> runTests(
bool startPaused: false,
bool ipv6: false,
bool machine: false,
bool previewDart2: false,
TestWatcher watcher,
}) async {
// Compute the command-line arguments for package:test.
@ -75,6 +76,7 @@ Future<int> runTests(
machine: machine,
startPaused: startPaused,
serverType: serverType,
previewDart2: previewDart2,
);
// Make the global packages path absolute.