Turn Dart 2 mode by default. (#15565)
diff --git a/.travis.yml b/.travis.yml
index fcc3330..4480a85 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,6 @@
env:
- SHARD=analyze
- SHARD=tests
- - SHARD=tests_dart2
- SHARD=docs
- SHARD=build_and_deploy_gallery
matrix:
diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt
index 3a1c4c5..4c0fb6e 100644
--- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt
+++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt
@@ -8,8 +8,7 @@
<asynchronous suspension>
#1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\)
<<skip until matching line>>
-^\(elided [0-9]+ .+[^)]$
-^.+\)$
+^\(elided [0-9]+ .+\)$
The test description was:
Exception handling in test harness - string
@@ -28,8 +27,7 @@
<asynchronous suspension>
#1 .+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\)
<<skip until matching line>>
-^\(elided [0-9]+ .+[^)]$
-^.+\)$
+^\(elided [0-9]+ .+\)$
The test description was:
Exception handling in test harness - FlutterError
@@ -45,11 +43,10 @@
When the exception was thrown, this was the stack:
#[0-9]+ +main.<anonymous closure> \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:16:9\)
-#[0-9]+ +main.<anonymous closure> \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:105\)
+#[0-9]+ +main.<anonymous closure> \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:77\)
#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\)
<<skip until matching line>>
-^\(elided [0-9]+ .+[^)]$
-^.+\)$
+^\(elided [0-9]+ .+\)$
The test description was:
Exception handling in test harness - uncaught Future error
diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index 78d53a3..337df20 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -29,7 +29,6 @@
'docs': _generateDocs,
'analyze': _analyzeRepo,
'tests': _runTests,
- 'tests_dart2': _runTestsDart2,
'coverage': _runCoverage,
};
@@ -130,15 +129,6 @@
print('${bold}DONE: Analysis successful.$reset');
}
-Future<Null> _runTestsDart2() async {
- if (Platform.isWindows) {
- // AppVeyor platform is overloaded, won't be able to handle additional
- // load of dart2 testing.
- return;
- }
- _runTests(options: <String>['--preview-dart-2']);
-}
-
Future<Null> _runTests({List<String> options: const <String>[]}) async {
// Verify that the tests actually return failure on failure and success on success.
final String automatedTests = path.join(flutterRoot, 'dev', 'automated_tests');
@@ -631,4 +621,4 @@
print('$red━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━$reset');
exit(1);
}
-}
\ No newline at end of file
+}
diff --git a/packages/flutter/test/foundation/error_reporting_test.dart b/packages/flutter/test/foundation/error_reporting_test.dart
index 6406738..1ffe759 100644
--- a/packages/flutter/test/foundation/error_reporting_test.dart
+++ b/packages/flutter/test/foundation/error_reporting_test.dart
@@ -7,8 +7,6 @@
import 'package:flutter/foundation.dart';
import 'package:test/test.dart';
-import 'platform_helper.dart';
-
dynamic getAssertionErrorWithMessage() {
try {
assert(false, 'Message goes here.');
@@ -45,8 +43,6 @@
final StackTrace sampleStack = await getSampleStack();
- final String dividerRegExp = pathSeparatorForRegExp;
-
test('Error reporting - pretest', () async {
expect(debugPrint, equals(debugPrintThrottled));
debugPrint = (String message, { int wrapWidth }) {
@@ -70,7 +66,7 @@
'^══╡ EXCEPTION CAUGHT BY ERROR HANDLING TEST ╞═══════════════════════════════════════════════════════\n'
'The following assertion was thrown testing the error handling logic:\n'
'Message goes here\\.\n'
- '\'[^\']+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
+ '\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
'\n'
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
'more information in this error message to help you determine and fix the underlying cause\\.\n'
@@ -78,10 +74,10 @@
' https://github\\.com/flutter/flutter/issues/new\n'
'\n'
'When the exception was thrown, this was the stack:\n'
- '#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
- '#2 getSampleStack \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
'<asynchronous suspension>\n' // TODO(ianh): https://github.com/flutter/flutter/issues/4021
- '#3 main \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#3 main \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
'\\(elided [0-9]+ frames from package dart:async\\)\n'
'\n'
@@ -111,7 +107,7 @@
'word word word word word word word word word word word word word word word word word word word word '
'word word word word word word word word word word word word word word word word word word word word '
'word word word word word word word word word word word word word word word word word word word word\n'
- '\'[^\']+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
+ '\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
'\n'
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
'more information in this error message to help you determine and fix the underlying cause\\.\n'
@@ -151,7 +147,7 @@
expect(console.join('\n'), matches(
'^══╡ EXCEPTION CAUGHT BY ERROR HANDLING TEST ╞═══════════════════════════════════════════════════════\n'
'The following assertion was thrown testing the error handling logic:\n'
- '\'[^\']+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.\n'
+ '\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.\n'
'\n'
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
'more information in this error message to help you determine and fix the underlying cause\\.\n'
@@ -159,10 +155,10 @@
' https://github\\.com/flutter/flutter/issues/new\n'
'\n'
'When the exception was thrown, this was the stack:\n'
- '#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
- '#2 getSampleStack \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
'<asynchronous suspension>\n' // TODO(ianh): https://github.com/flutter/flutter/issues/4021
- '#3 main \\([^)]+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
+ '#3 main \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
'\\(elided [0-9]+ frames from package dart:async\\)\n'
'\n'
@@ -174,7 +170,7 @@
FlutterError.dumpErrorToConsole(new FlutterErrorDetails(
exception: getAssertionErrorWithoutMessage(),
));
- expect(console.join('\n'), matches('Another exception was thrown: \'[^\']+flutter${dividerRegExp}test${dividerRegExp}foundation${dividerRegExp}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.'));
+ expect(console.join('\n'), matches('Another exception was thrown: \'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.'));
console.clear();
FlutterError.resetErrorCount();
});
diff --git a/packages/flutter/test/foundation/stack_trace_test.dart b/packages/flutter/test/foundation/stack_trace_test.dart
index ed6e53c..e4c9aa6 100644
--- a/packages/flutter/test/foundation/stack_trace_test.dart
+++ b/packages/flutter/test/foundation/stack_trace_test.dart
@@ -5,18 +5,14 @@
import 'package:flutter/foundation.dart';
import 'package:test/test.dart';
-import 'platform_helper.dart';
-
void main() {
// TODO(8128): These tests and the filtering mechanism should be revisited to account for causal async stack traces.
- final String dividerRegExp = pathSeparatorForRegExp;
-
test('FlutterError.defaultStackFilter', () {
final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
expect(filtered.length, greaterThanOrEqualTo(4));
expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
- expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure>.<anonymous closure> \(package:test' + dividerRegExp + r'.+:[0-9]+:[0-9]+\)$'));
+ expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure>.<anonymous closure> \(package:test/.+:[0-9]+:[0-9]+\)$'));
expect(filtered[2], equals('<asynchronous suspension>'));
expect(filtered.last, matches(r'^\(elided [1-9][0-9]+ frames from package dart:async(, package dart:async-patch,)? and package stack_trace\)$'));
});
diff --git a/packages/flutter_tools/bin/xcode_backend.sh b/packages/flutter_tools/bin/xcode_backend.sh
index 2dae766..11130d3 100755
--- a/packages/flutter_tools/bin/xcode_backend.sh
+++ b/packages/flutter_tools/bin/xcode_backend.sh
@@ -101,6 +101,8 @@
local preview_dart_2_flag=""
if [[ -n "$PREVIEW_DART_2" ]]; then
preview_dart_2_flag="--preview-dart-2"
+ else
+ preview_dart_2_flag="--no-preview-dart-2"
fi
if [[ "$CURRENT_ARCH" != "x86_64" ]]; then
diff --git a/packages/flutter_tools/gradle/flutter.gradle b/packages/flutter_tools/gradle/flutter.gradle
index c421a64..3416132 100644
--- a/packages/flutter_tools/gradle/flutter.gradle
+++ b/packages/flutter_tools/gradle/flutter.gradle
@@ -400,7 +400,9 @@
args "--output-dir", "${intermediateDir}"
if (previewDart2) {
args "--preview-dart-2"
- }
+ } else {
+ args "--no-preview-dart-2"
+ }
if (trackWidgetCreation) {
args "--track-widget-creation"
}
@@ -432,7 +434,9 @@
args "--target", targetPath
if (previewDart2) {
args "--preview-dart-2"
- }
+ } else {
+ args "--no-preview-dart-2"
+ }
if (trackWidgetCreation) {
args "--track-widget-creation"
}
diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart
index 963db27..0f4969e 100644
--- a/packages/flutter_tools/lib/src/commands/analyze.dart
+++ b/packages/flutter_tools/lib/src/commands/analyze.dart
@@ -19,7 +19,7 @@
argParser.addFlag('current-package', help: 'Include the lib/main.dart file from the current directory, if any.', defaultsTo: true);
argParser.addFlag('dartdocs', help: 'List every public member that is lacking documentation (only works with --flutter-repo and without --watch).', defaultsTo: false, hide: !verboseHelp);
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
- argParser.addFlag('preview-dart-2', help: 'Preview Dart 2.0 functionality.');
+ argParser.addFlag('preview-dart-2', defaultsTo: true, help: 'Preview Dart 2.0 functionality.');
argParser.addOption('write', valueHelp: 'file', help: 'Also output the results to a file. This is useful with --watch if you want a file to always contain the latest results.');
argParser.addOption('dart-sdk', valueHelp: 'path-to-sdk', help: 'The path to the Dart SDK.', hide: !verboseHelp);
diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart
index 3884e3a..65e41c6 100644
--- a/packages/flutter_tools/lib/src/commands/build_aot.dart
+++ b/packages/flutter_tools/lib/src/commands/build_aot.dart
@@ -39,7 +39,11 @@
)
..addFlag('interpreter')
..addFlag('quiet', defaultsTo: false)
- ..addFlag('preview-dart-2', negatable: false, hide: !verboseHelp)
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
+ hide: !verboseHelp,
+ help: 'Preview Dart 2.0 functionality.',
+ )
..addMultiOption(FlutterOptions.kExtraFrontEndOptions,
splitCommas: true,
hide: true,
@@ -48,8 +52,9 @@
splitCommas: true,
hide: true,
)
- ..addFlag('prefer-shared-library', negatable: false,
- help: 'Whether to prefer compiling to a *.so file (android only).');
+ ..addFlag('prefer-shared-library',
+ negatable: false,
+ help: 'Whether to prefer compiling to a *.so file (android only).');
}
@override
diff --git a/packages/flutter_tools/lib/src/commands/build_apk.dart b/packages/flutter_tools/lib/src/commands/build_apk.dart
index e384097..6e70e3f 100644
--- a/packages/flutter_tools/lib/src/commands/build_apk.dart
+++ b/packages/flutter_tools/lib/src/commands/build_apk.dart
@@ -15,10 +15,16 @@
usesPubOption();
argParser
- ..addFlag('preview-dart-2', negatable: false, hide: !verboseHelp)
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
+ hide: !verboseHelp,
+ help: 'Preview Dart 2.0 functionality.',
+ )
..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp)
- ..addFlag('prefer-shared-library', negatable: false,
- help: 'Whether to prefer compiling to a *.so file (android only).')
+ ..addFlag('prefer-shared-library',
+ negatable: false,
+ help: 'Whether to prefer compiling to a *.so file (android only).',
+ )
..addOption('target-platform',
defaultsTo: 'android-arm',
allowed: <String>['android-arm', 'android-arm64']);
diff --git a/packages/flutter_tools/lib/src/commands/build_flx.dart b/packages/flutter_tools/lib/src/commands/build_flx.dart
index b7fbfdc..c763369 100644
--- a/packages/flutter_tools/lib/src/commands/build_flx.dart
+++ b/packages/flutter_tools/lib/src/commands/build_flx.dart
@@ -11,24 +11,31 @@
class BuildFlxCommand extends BuildSubCommand {
BuildFlxCommand({bool verboseHelp: false}) {
usesTargetOption();
- argParser.addFlag('precompiled', negatable: false);
- // This option is still referenced by the iOS build scripts. We should
- // remove it once we've updated those build scripts.
- argParser.addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp);
- argParser.addOption('manifest', defaultsTo: defaultManifestPath);
- argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
- argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
- argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
- argParser.addOption('depfile', defaultsTo: defaultDepfilePath);
- argParser.addOption('kernel-file', defaultsTo: defaultApplicationKernelPath);
- argParser.addFlag('preview-dart-2', negatable: false, hide: !verboseHelp);
- argParser.addFlag(
- 'track-widget-creation',
- hide: !verboseHelp,
- help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
- );
- argParser.addOption('working-dir', defaultsTo: getAssetBuildDirectory());
- argParser.addFlag('report-licensed-packages', help: 'Whether to report the names of all the packages that are included in the application\'s LICENSE file.', defaultsTo: false);
+ argParser
+ ..addFlag('precompiled', negatable: false)
+ // This option is still referenced by the iOS build scripts. We should
+ // remove it once we've updated those build scripts.
+ ..addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp)
+ ..addOption('manifest', defaultsTo: defaultManifestPath)
+ ..addOption('private-key', defaultsTo: defaultPrivateKeyPath)
+ ..addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath)
+ ..addOption('snapshot', defaultsTo: defaultSnapshotPath)
+ ..addOption('depfile', defaultsTo: defaultDepfilePath)
+ ..addOption('kernel-file', defaultsTo: defaultApplicationKernelPath)
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
+ hide: !verboseHelp,
+ help: 'Preview Dart 2.0 functionality.',
+ )
+ ..addFlag('track-widget-creation',
+ hide: !verboseHelp,
+ help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
+ )
+ ..addOption('working-dir', defaultsTo: getAssetBuildDirectory())
+ ..addFlag('report-licensed-packages',
+ help: 'Whether to report the names of all the packages that are included '
+ 'in the application\'s LICENSE file.',
+ defaultsTo: false);
usesPubOption();
}
diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart
index 3055567..5983690 100644
--- a/packages/flutter_tools/lib/src/commands/build_ios.dart
+++ b/packages/flutter_tools/lib/src/commands/build_ios.dart
@@ -17,20 +17,30 @@
usesTargetOption();
usesFlavorOption();
usesPubOption();
- argParser.addFlag('debug',
- negatable: false,
- help: 'Build a debug version of your app (default mode for iOS simulator builds).');
- argParser.addFlag('profile',
- negatable: false,
- help: 'Build a version of your app specialized for performance profiling.');
- argParser.addFlag('release',
- negatable: false,
- help: 'Build a release version of your app (default mode for device builds).');
- argParser.addFlag('simulator', help: 'Build for the iOS simulator instead of the device.');
- argParser.addFlag('codesign', negatable: true, defaultsTo: true,
- help: 'Codesign the application bundle (only available on device builds).');
- argParser.addFlag('preview-dart-2', negatable: false,
- hide: !verboseHelp);
+ argParser
+ ..addFlag('debug',
+ negatable: false,
+ help: 'Build a debug version of your app (default mode for iOS simulator builds).',
+ )
+ ..addFlag('profile',
+ negatable: false,
+ help: 'Build a version of your app specialized for performance profiling.',
+ )
+ ..addFlag('release',
+ negatable: false,
+ help: 'Build a release version of your app (default mode for device builds).',
+ )
+ ..addFlag('simulator',
+ help: 'Build for the iOS simulator instead of the device.',
+ )
+ ..addFlag('codesign',
+ defaultsTo: true,
+ help: 'Codesign the application bundle (only available on device builds).',
+ )
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
+ hide: !verboseHelp,
+ help: 'Preview Dart 2.0 functionality.');
}
@override
diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart
index 4c01040..9713b19 100644
--- a/packages/flutter_tools/lib/src/commands/drive.dart
+++ b/packages/flutter_tools/lib/src/commands/drive.dart
@@ -40,42 +40,31 @@
DriveCommand() {
requiresPubspecYaml();
- argParser.addFlag(
- 'keep-app-running',
- defaultsTo: null,
- negatable: true,
- help:
- 'Will keep the Flutter application running when done testing.\n'
- 'By default, "flutter drive" stops the application after tests are finished,\n'
- 'and --keep-app-running overrides this. On the other hand, if --use-existing-app\n'
- 'is specified, then "flutter drive" instead defaults to leaving the application\n'
- 'running, and --no-keep-app-running overrides it.'
- );
-
- argParser.addOption(
- 'use-existing-app',
- help:
- 'Connect to an already running instance via the given observatory URL.\n'
- 'If this option is given, the application will not be automatically started,\n'
- 'and it will only be stopped if --no-keep-app-running is explicitly set.',
- valueHelp:
- 'url'
- );
-
- argParser.addOption(
- 'driver',
- help:
- 'The test file to run on the host (as opposed to the target file to run on\n'
- 'the device). By default, this file has the same base name as the target\n'
- 'file, but in the "test_driver/" directory instead, and with "_test" inserted\n'
- 'just before the extension, so e.g. if the target is "lib/main.dart", the\n'
- 'driver will be "test_driver/main_test.dart".',
- valueHelp:
- 'path'
- );
-
- argParser.addFlag('preview-dart-2',
- defaultsTo: false,
+ argParser
+ ..addFlag('keep-app-running',
+ defaultsTo: null,
+ help: 'Will keep the Flutter application running when done testing.\n'
+ 'By default, "flutter drive" stops the application after tests are finished,\n'
+ 'and --keep-app-running overrides this. On the other hand, if --use-existing-app\n'
+ 'is specified, then "flutter drive" instead defaults to leaving the application\n'
+ 'running, and --no-keep-app-running overrides it.',
+ )
+ ..addOption('use-existing-app',
+ help: 'Connect to an already running instance via the given observatory URL.\n'
+ 'If this option is given, the application will not be automatically started,\n'
+ 'and it will only be stopped if --no-keep-app-running is explicitly set.',
+ valueHelp: 'url',
+ )
+ ..addOption('driver',
+ help: 'The test file to run on the host (as opposed to the target file to run on\n'
+ 'the device). By default, this file has the same base name as the target\n'
+ 'file, but in the "test_driver/" directory instead, and with "_test" inserted\n'
+ 'just before the extension, so e.g. if the target is "lib/main.dart", the\n'
+ 'driver will be "test_driver/main_test.dart".',
+ valueHelp: 'path',
+ )
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
help: 'Preview Dart 2.0 functionality.');
}
@@ -301,6 +290,8 @@
..add('-rexpanded');
if (previewDart2) {
args.add('--preview-dart-2');
+ } else {
+ args.add('--no-preview-dart-2');
}
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart
index ac697c0..f4eebbd 100644
--- a/packages/flutter_tools/lib/src/commands/run.dart
+++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -24,17 +24,21 @@
RunCommandBase() {
addBuildModeFlags(defaultToRelease: false);
usesFlavorOption();
- argParser.addFlag('trace-startup',
+ argParser
+ ..addFlag('trace-startup',
negatable: false,
- help: 'Start tracing during startup.');
- argParser.addFlag('ipv6',
+ help: 'Start tracing during startup.',
+ )
+ ..addFlag('ipv6',
hide: true,
negatable: false,
help: 'Binds to IPv6 localhost instead of IPv4 when the flutter tool\n'
- 'forwards the host port to a device port.');
- argParser.addOption('route',
- help: 'Which route to load when running the app.');
- argParser.addOption('target-platform',
+ 'forwards the host port to a device port.',
+ )
+ ..addOption('route',
+ help: 'Which route to load when running the app.',
+ )
+ ..addOption('target-platform',
defaultsTo: 'default',
allowed: <String>['default', 'android-arm', 'android-arm64'],
help: 'Specify the target platform when building the app for an '
@@ -78,81 +82,97 @@
RunCommand({ bool verboseHelp: false }) {
requiresPubspecYaml();
- argParser.addFlag('full-restart',
+ argParser
+ ..addFlag('full-restart',
defaultsTo: true,
- help: 'Stop any currently running application process before running the app.');
- argParser.addFlag('start-paused',
+ help: 'Stop any currently running application process before running the app.',
+ )
+ ..addFlag('start-paused',
negatable: false,
- help: 'Start in a paused mode and wait for a debugger to connect.');
- argParser.addFlag('enable-software-rendering',
+ help: 'Start in a paused mode and wait for a debugger to connect.',
+ )
+ ..addFlag('enable-software-rendering',
negatable: false,
help: 'Enable rendering using the Skia software backend. This is useful\n'
'when testing Flutter on emulators. By default, Flutter will\n'
'attempt to either use OpenGL or Vulkan and fall back to software\n'
- 'when neither is available.');
- argParser.addFlag('skia-deterministic-rendering',
+ 'when neither is available.',
+ )
+ ..addFlag('skia-deterministic-rendering',
negatable: false,
help: 'When combined with --enable-software-rendering, provides 100%\n'
- 'deterministic Skia rendering.');
- argParser.addFlag('trace-skia',
+ 'deterministic Skia rendering.',
+ )
+ ..addFlag('trace-skia',
negatable: false,
help: 'Enable tracing of Skia code. This is useful when debugging\n'
- 'the GPU thread. By default, Flutter will not log skia code.');
- argParser.addFlag('use-test-fonts',
+ 'the GPU thread. By default, Flutter will not log skia code.',
+ )
+ ..addFlag('use-test-fonts',
negatable: true,
help: 'Enable (and default to) the "Ahem" font. This is a special font\n'
'used in tests to remove any dependencies on the font metrics. It\n'
'is enabled when you use "flutter test". Set this flag when running\n'
'a test using "flutter run" for debugging purposes. This flag is\n'
- 'only available when running in debug mode.');
- argParser.addFlag('build',
+ 'only available when running in debug mode.',
+ )
+ ..addFlag('build',
defaultsTo: true,
- help: 'If necessary, build the app before running.');
- argParser.addOption('use-application-binary',
+ help: 'If necessary, build the app before running.',
+ )
+ ..addOption('use-application-binary',
hide: !verboseHelp,
- help: 'Specify a pre-built application binary to use when running.');
- argParser.addFlag('preview-dart-2',
+ help: 'Specify a pre-built application binary to use when running.',
+ )
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
hide: !verboseHelp,
- help: 'Preview Dart 2.0 functionality.');
- argParser.addFlag('track-widget-creation',
+ help: 'Preview Dart 2.0 functionality.',
+ )
+ ..addFlag('track-widget-creation',
hide: !verboseHelp,
- help: 'Track widget creation locations. Requires Dart 2.0 functionality.');
- argParser.addOption('project-root',
+ help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
+ )
+ ..addOption('project-root',
hide: !verboseHelp,
- help: 'Specify the project root directory.');
- argParser.addFlag('machine',
+ help: 'Specify the project root directory.',
+ )
+ ..addFlag('machine',
hide: !verboseHelp,
negatable: false,
help: 'Handle machine structured JSON command input and provide output\n'
- 'and progress in machine friendly format.');
- argParser.addFlag('hot',
+ 'and progress in machine friendly format.',
+ )
+ ..addFlag('hot',
negatable: true,
defaultsTo: kHotReloadDefault,
- help: 'Run with support for hot reloading.');
- argParser.addOption('pid-file',
+ help: 'Run with support for hot reloading.',
+ )
+ ..addOption('pid-file',
help: 'Specify a file to write the process id to.\n'
'You can send SIGUSR1 to trigger a hot reload\n'
- 'and SIGUSR2 to trigger a full restart.');
- argParser.addFlag('resident',
+ 'and SIGUSR2 to trigger a full restart.',
+ )
+ ..addFlag('resident',
negatable: true,
defaultsTo: true,
hide: !verboseHelp,
- help: 'Stay resident after launching the application.');
-
- argParser.addFlag('benchmark',
- negatable: false,
- hide: !verboseHelp,
- help: 'Enable a benchmarking mode. This will run the given application,\n'
- 'measure the startup time and the app restart time, write the\n'
- 'results out to "refresh_benchmark.json", and exit. This flag is\n'
- 'intended for use in generating automated flutter benchmarks.');
-
- argParser.addOption('output-dill',
+ help: 'Stay resident after launching the application.',
+ )
+ ..addFlag('benchmark',
+ negatable: false,
hide: !verboseHelp,
- help: 'Specify the path to frontend server output kernel file.');
-
- argParser.addOption(FlutterOptions.kExtraFrontEndOptions, hide: true);
- argParser.addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true);
+ help: 'Enable a benchmarking mode. This will run the given application,\n'
+ 'measure the startup time and the app restart time, write the\n'
+ 'results out to "refresh_benchmark.json", and exit. This flag is\n'
+ 'intended for use in generating automated flutter benchmarks.',
+ )
+ ..addOption('output-dill',
+ hide: !verboseHelp,
+ help: 'Specify the path to frontend server output kernel file.',
+ )
+ ..addOption(FlutterOptions.kExtraFrontEndOptions, hide: true)
+ ..addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true);
}
List<Device> devices;
diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart
index 630bd7e..bf78e74 100644
--- a/packages/flutter_tools/lib/src/commands/test.dart
+++ b/packages/flutter_tools/lib/src/commands/test.dart
@@ -23,70 +23,62 @@
TestCommand({ bool verboseHelp: false }) {
requiresPubspecYaml();
usesPubOption();
- argParser.addMultiOption(
- 'name',
- help: 'A regular expression matching substrings of the names of tests to run.',
- valueHelp: 'regexp',
- splitCommas: false,
- );
- argParser.addMultiOption(
- 'plain-name',
- help: 'A plain-text substring of the names of tests to run.',
- valueHelp: 'substring',
- splitCommas: false,
- );
- argParser.addFlag(
- 'start-paused',
- defaultsTo: false,
- negatable: false,
- help: 'Start in a paused mode and wait for a debugger to connect.\n'
- 'You must specify a single test file to run, explicitly.\n'
- 'Instructions for connecting with a debugger and printed to the\n'
- 'console once the test has started.',
- );
- argParser.addFlag(
- 'coverage',
- defaultsTo: false,
- negatable: false,
- help: 'Whether to collect coverage information.',
- );
- argParser.addFlag(
- 'merge-coverage',
- defaultsTo: false,
- negatable: false,
- help: 'Whether to merge coverage data with "coverage/lcov.base.info".\n'
- 'Implies collecting coverage data. (Requires lcov)',
- );
- argParser.addFlag(
- 'ipv6',
- negatable: false,
- hide: true,
- help: 'Whether to use IPv6 for the test harness server socket.',
- );
- argParser.addOption(
- 'coverage-path',
- defaultsTo: 'coverage/lcov.info',
- help: 'Where to store coverage information (if coverage is enabled).',
- );
- argParser.addFlag(
- 'machine',
- hide: !verboseHelp,
- 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.',
- );
- argParser.addFlag(
- 'track-widget-creation',
- negatable: false,
- hide: !verboseHelp,
- help: 'Track widget creation locations.\n'
- 'This enables testing of features such as the widget inspector.',
- );
+ argParser
+ ..addMultiOption('name',
+ help: 'A regular expression matching substrings of the names of tests to run.',
+ valueHelp: 'regexp',
+ splitCommas: false,
+ )
+ ..addMultiOption('plain-name',
+ help: 'A plain-text substring of the names of tests to run.',
+ valueHelp: 'substring',
+ splitCommas: false,
+ )
+ ..addFlag('start-paused',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Start in a paused mode and wait for a debugger to connect.\n'
+ 'You must specify a single test file to run, explicitly.\n'
+ 'Instructions for connecting with a debugger and printed to the\n'
+ 'console once the test has started.',
+ )
+ ..addFlag('coverage',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Whether to collect coverage information.',
+ )
+ ..addFlag('merge-coverage',
+ defaultsTo: false,
+ negatable: false,
+ help: 'Whether to merge coverage data with "coverage/lcov.base.info".\n'
+ 'Implies collecting coverage data. (Requires lcov)',
+ )
+ ..addFlag('ipv6',
+ negatable: false,
+ hide: true,
+ help: 'Whether to use IPv6 for the test harness server socket.',
+ )
+ ..addOption('coverage-path',
+ defaultsTo: 'coverage/lcov.info',
+ help: 'Where to store coverage information (if coverage is enabled).',
+ )
+ ..addFlag('machine',
+ hide: !verboseHelp,
+ negatable: false,
+ help: 'Handle machine structured JSON command input\n'
+ 'and provide output and progress in machine friendly format.',
+ )
+ ..addFlag('preview-dart-2',
+ defaultsTo: true,
+ hide: !verboseHelp,
+ help: 'Preview Dart 2.0 functionality.',
+ )
+ ..addFlag('track-widget-creation',
+ negatable: false,
+ hide: !verboseHelp,
+ help: 'Track widget creation locations.\n'
+ 'This enables testing of features such as the widget inspector.',
+ );
}
@override
diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart
index 70a3304..7c15e91 100644
--- a/packages/flutter_tools/lib/src/compile.dart
+++ b/packages/flutter_tools/lib/src/compile.dart
@@ -12,11 +12,14 @@
import 'base/process_manager.dart';
import 'globals.dart';
+typedef void CompilerMessageConsumer(String message);
+
class _StdoutHandler {
- _StdoutHandler() {
+ _StdoutHandler({this.consumer: printError}) {
reset();
}
+ final CompilerMessageConsumer consumer;
String boundaryKey;
Completer<String> outputFilename;
@@ -30,7 +33,7 @@
? string.substring(boundaryKey.length + 1)
: null);
else
- printError('compiler message: $string');
+ consumer('compiler message: $string');
}
// This is needed to get ready to process next compilation result output,
@@ -124,10 +127,11 @@
/// restarts the Flutter app.
class ResidentCompiler {
ResidentCompiler(this._sdkRoot, {bool trackWidgetCreation: false,
- String packagesPath})
+ String packagesPath, CompilerMessageConsumer compilerMessageConsumer: printError})
: assert(_sdkRoot != null),
_trackWidgetCreation = trackWidgetCreation,
- _packagesPath = packagesPath {
+ _packagesPath = packagesPath,
+ stdoutHandler = new _StdoutHandler(consumer: compilerMessageConsumer) {
// This is a URI, not a file path, so the forward slash is correct even on Windows.
if (!_sdkRoot.endsWith('/'))
_sdkRoot = '$_sdkRoot/';
@@ -137,7 +141,7 @@
final String _packagesPath;
String _sdkRoot;
Process _server;
- final _StdoutHandler stdoutHandler = new _StdoutHandler();
+ final _StdoutHandler stdoutHandler;
/// If invoked for the first time, it compiles Dart script identified by
/// [mainPath], [invalidatedFiles] list is ignored.
@@ -233,4 +237,9 @@
void reset() {
_server.stdin.writeln('reset');
}
+
+ Future<dynamic> shutdown() {
+ _server.kill();
+ return _server.exitCode;
+ }
}
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index ca48a1a..cd50e61 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -163,7 +163,7 @@
BuildInfo getBuildInfo() {
final bool previewDart2 = argParser.options.containsKey('preview-dart-2')
? argResults['preview-dart-2']
- : false;
+ : true;
TargetPlatform targetPlatform;
if (argParser.options.containsKey('target-platform') &&
diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart
index e3e5da0..a9b2738 100644
--- a/packages/flutter_tools/lib/src/test/flutter_platform.dart
+++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart
@@ -108,6 +108,30 @@
.createTempSync('output_dill');
final File outputDill = outputDillDirectory.childFile('output.dill');
+ bool suppressOutput = false;
+ void reportCompilerMessage(String message) {
+ if (suppressOutput)
+ return;
+
+ if (message.startsWith('compiler message: Error: Could not resolve the package \'test\'')) {
+ printTrace(message);
+ printError('\n\nFailed to load test harness. Are you missing a dependency on flutter_test?\n');
+ suppressOutput = true;
+ return;
+ }
+
+ printError('$message');
+ }
+
+ ResidentCompiler createCompiler() {
+ return new ResidentCompiler(
+ artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
+ packagesPath: PackageMap.globalPackagesPath,
+ trackWidgetCreation: trackWidgetCreation,
+ compilerMessageConsumer: reportCompilerMessage,
+ );
+ }
+
compilerController.stream.listen((_CompilationRequest request) async {
final bool isEmpty = compilationQueue.isEmpty;
compilationQueue.add(request);
@@ -118,16 +142,27 @@
while (compilationQueue.isNotEmpty) {
final _CompilationRequest request = compilationQueue.first;
printTrace('Compiling ${request.path}');
+ compiler ??= createCompiler();
+ suppressOutput = false;
final String outputPath = await compiler.recompile(request.path,
<String>[request.path],
outputPath: outputDill.path,
);
- // Copy output dill next to the source file.
- final File kernelReadyToRun = await fs.file(outputPath).copy(
- request.path + '.dill');
- compiler.accept();
- compiler.reset();
- request.result.complete(kernelReadyToRun.path);
+
+ // Check if the compiler produced the output. If it failed then
+ // outputPath would be null. In this case pass null upwards to the
+ // consumer and shutdown the compiler to avoid reusing compiler
+ // that might have gotten into a weird state.
+ if (outputPath == null) {
+ request.result.complete(null);
+ await shutdown();
+ } else {
+ final File kernelReadyToRun =
+ await fs.file(outputPath).copy('${request.path}.dill');
+ request.result.complete(kernelReadyToRun.path);
+ compiler.accept();
+ compiler.reset();
+ }
// Only remove now when we finished processing the element
compilationQueue.removeAt(0);
}
@@ -135,11 +170,6 @@
}, onDone: () {
outputDillDirectory.deleteSync(recursive: true);
});
-
- compiler = new ResidentCompiler(
- artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
- packagesPath: PackageMap.globalPackagesPath,
- trackWidgetCreation: trackWidgetCreation);
}
final StreamController<_CompilationRequest> compilerController =
@@ -152,6 +182,11 @@
compilerController.add(new _CompilationRequest(mainDart, completer));
return completer.future;
}
+
+ Future<dynamic> shutdown() async {
+ await compiler.shutdown();
+ compiler = null;
+ }
}
class _FlutterPlatform extends PlatformPlugin {
@@ -596,6 +631,14 @@
File _cachedFontConfig;
+ @override
+ Future<dynamic> close() async {
+ if (compiler != null) {
+ await compiler.shutdown();
+ compiler = null;
+ }
+ }
+
/// Returns a Fontconfig config file that limits font fallback to the
/// artifact cache directory.
File get _fontConfigFile {
diff --git a/packages/flutter_tools/templates/plugin/lib/projectName.dart.tmpl b/packages/flutter_tools/templates/plugin/lib/projectName.dart.tmpl
index b61b95f..f7b9f56 100644
--- a/packages/flutter_tools/templates/plugin/lib/projectName.dart.tmpl
+++ b/packages/flutter_tools/templates/plugin/lib/projectName.dart.tmpl
@@ -6,6 +6,8 @@
static const MethodChannel _channel =
const MethodChannel('{{projectName}}');
- static Future<String> get platformVersion =>
- _channel.invokeMethod('getPlatformVersion');
+ static Future<String> get platformVersion async {
+ final String version = await _channel.invokeMethod('getPlatformVersion');
+ return version;
+ }
}
diff --git a/packages/flutter_tools/test/commands/analyze_once_test.dart b/packages/flutter_tools/test/commands/analyze_once_test.dart
index dbf7626..7de75b8 100644
--- a/packages/flutter_tools/test/commands/analyze_once_test.dart
+++ b/packages/flutter_tools/test/commands/analyze_once_test.dart
@@ -223,7 +223,7 @@
try {
await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
- arguments: <String>['analyze'],
+ arguments: <String>['analyze', '--no-preview-dart-2'],
statusTextContains: <String>['1 issue found.'],
toolExit: true,
);