From a7db3591cb25ae23bd4acbbf7bc8ee14e03adb36 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 24 Jul 2020 15:17:39 -0700 Subject: [PATCH] [flutter_tools] deflake fastReassemble test (#62152) --- .../integration.shard/hot_reload_test.dart | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart index bd2f36dd8e5..1146603b408 100644 --- a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart +++ b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart @@ -84,12 +84,25 @@ void main() { }); test('fastReassemble behavior triggers hot reload behavior with evaluation of expression', () async { - final StringBuffer stdout = StringBuffer(); - final StreamSubscription subscription = flutter.stdout.listen(stdout.writeln); + final Completer tick1 = Completer(); + final Completer tick2 = Completer(); + final Completer tick3 = Completer(); + final StreamSubscription subscription = flutter.stdout.listen((String line) { + if (line.contains('TICK 1')) { + tick1.complete(); + } + if (line.contains('TICK 2')) { + tick2.complete(); + } + if (line.contains('TICK 3')) { + tick3.complete(); + } + }); await flutter.run(withDebugger: true); final int port = flutter.vmServicePort; final VmService vmService = await vmServiceConnectUri('ws://localhost:$port/ws'); + await tick1.future; try { // Since the single-widget reload feature is not yet implemented, manually // evaluate the expression for the reload. @@ -108,7 +121,7 @@ void main() { // _extensionType indicates success. expect(fastReassemble1.type, '_extensionType'); - expect(stdout.toString(), contains('(((TICK 2))))')); + await tick2.future; // verify evaluation did not produce invalidat type by checking with dart:core // type. @@ -123,7 +136,9 @@ void main() { // _extensionType indicates success. expect(fastReassemble2.type, '_extensionType'); - expect(stdout.toString(), isNot(contains('(((TICK 3))))'))); + unawaited(tick3.future.whenComplete(() { + fail('Should not complete'); + })); // Invocation without evaluation leads to runtime error. expect(vmService