From 39d7f22a966b2de74565a3f6811cfa28234cba78 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 24 May 2018 19:26:44 +0200 Subject: [PATCH] Enable --sync-async in Flutter. (#17866) --- .../flutter_test/exception_handling_expectation.txt | 5 ++++- .../flutter_test/test_async_utils_guarded_test.dart | 5 ++++- packages/flutter_test/lib/src/binding.dart | 6 ++++++ packages/flutter_tools/lib/src/compile.dart | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt index 4c0fb6e523..346aa983bc 100644 --- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt +++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt @@ -43,7 +43,10 @@ Who lives, who dies, who tells your story\? When the exception was thrown, this was the stack: #[0-9]+ +main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:16:9\) -#[0-9]+ +main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:77\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) +#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]widget_tester\.dart:[0-9]+:[0-9]+\) <> ^\(elided [0-9]+ .+\)$ diff --git a/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart b/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart index f04a139954..d709a3f0b3 100644 --- a/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart +++ b/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart @@ -14,7 +14,10 @@ class TestTestBinding extends AutomatedTestWidgetsFlutterBinding { Future guardedHelper(WidgetTester tester) { return TestAsyncUtils.guard(() async { - await tester.pumpWidget(const Text('Hello')); + await tester.pumpWidget(const Directionality( + textDirection: TextDirection.ltr, + child: const Text('Hello'), + )); }); } diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index 9630449ef7..792eb7602c 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -767,6 +767,12 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { }); return new Future.microtask(() async { + // Run all queued microtasks. + await new Future.microtask(() {}); + // When the test had an exception, the test-framework already + // ran the teardown functions, removing the _fakeAsync function. + if (_fakeAsync == null) + return null; // Resolve interplay between fake async and real async calls. _fakeAsync.flushMicrotasks(); while (_pendingAsyncTasks != null) { diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index dc065d6d0c..8c204a8734 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -120,6 +120,7 @@ class KernelCompiler { '--sdk-root', sdkRoot, '--strong', + '--sync-async', '--target=flutter', ]; if (trackWidgetCreation) @@ -252,6 +253,7 @@ class ResidentCompiler { _sdkRoot, '--incremental', '--strong', + '--sync-async', '--target=flutter', ]; if (outputPath != null) {