@@ -57,8 +57,8 @@ void runTests({
5757 await recompile (hasEdits: true );
5858 }
5959
60- /// Wait for `expectedStrings` to be printed in the console.
61- Future <void > expectLogs (List <String > expectedStrings) async {
60+ // Wait for `expectedStrings` to be printed to the console.
61+ Future <void > waitForLogs (List <String > expectedStrings) async {
6262 final expectations = List <String >.from (expectedStrings);
6363 final completer = Completer <void >();
6464 final subscription = context.webkitDebugger.onConsoleAPICalled.listen ((e) {
@@ -70,7 +70,14 @@ void runTests({
7070 }
7171 }
7272 });
73- await completer.future;
73+ await completer.future.timeout (
74+ const Duration (minutes: 1 ),
75+ onTimeout: () {
76+ throw TimeoutException (
77+ 'Failed to find logs: $expectedStrings in console.' ,
78+ );
79+ },
80+ );
7481 await subscription.cancel ();
7582 }
7683
@@ -96,9 +103,9 @@ void runTests({
96103
97104 test ('can live reload changes ' , () async {
98105 // A full reload should clear the state.
99- final logExpectation = expectLogs ([newString]);
106+ final logFuture = waitForLogs ([newString]);
100107 await makeEditAndRecompile ();
101- await logExpectation ;
108+ await logFuture ;
102109 });
103110 });
104111
@@ -124,9 +131,9 @@ void runTests({
124131
125132 test ('can live reload changes ' , () async {
126133 // A full reload should clear the state.
127- final logExpectation = expectLogs ([newString]);
134+ final logFuture = waitForLogs ([newString]);
128135 await makeEditAndRecompile ();
129- await logExpectation ;
136+ await logFuture ;
130137 });
131138 });
132139
@@ -153,9 +160,9 @@ void runTests({
153160
154161 test ('can live reload changes ' , () async {
155162 // A full reload should clear the state.
156- final logExpectation = expectLogs ([newString]);
163+ final logFuture = waitForLogs ([newString]);
157164 await makeEditAndRecompile ();
158- await logExpectation ;
165+ await logFuture ;
159166 });
160167 });
161168 },
@@ -292,15 +299,15 @@ void runTests({
292299 ),
293300 );
294301 // Main is re-invoked which shouldn't clear the state.
295- final logExpectation = expectLogs (['$originalString $newString ' ]);
302+ final logFuture = waitForLogs (['$originalString $newString ' ]);
296303 final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
297304 expect (
298305 await fakeClient.callServiceExtension (hotRestart! ),
299306 const TypeMatcher <Success >(),
300307 );
301308
302309 await eventsDone;
303- await logExpectation ;
310+ await logFuture ;
304311 });
305312
306313 test ('can send events before and after hot restart' , () async {
@@ -334,7 +341,7 @@ void runTests({
334341
335342 await recompile ();
336343 // Main is re-invoked which shouldn't clear the state.
337- final logExpectation = expectLogs (['$originalString $originalString ' ]);
344+ final logFuture = waitForLogs (['$originalString $originalString ' ]);
338345 final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
339346 expect (
340347 await fakeClient.callServiceExtension (hotRestart! ),
@@ -353,7 +360,7 @@ void runTests({
353360 );
354361
355362 await eventsDone;
356- await logExpectation ;
363+ await logFuture ;
357364 });
358365
359366 test ('can refresh the page via the fullReload service extension' , () async {
@@ -372,15 +379,15 @@ void runTests({
372379 ),
373380 );
374381 // Should see only the new text.
375- final logExpectation = expectLogs ([newString]);
382+ final logFuture = waitForLogs ([newString]);
376383 final fullReload = context.getRegisteredServiceExtension ('fullReload' );
377384 expect (
378385 await fakeClient.callServiceExtension (fullReload! ),
379386 isA <Success >(),
380387 );
381388
382389 await eventsDone;
383- await logExpectation ;
390+ await logFuture ;
384391 });
385392
386393 test ('can hot restart while paused' , () async {
@@ -405,10 +412,10 @@ void runTests({
405412
406413 await makeEditAndRecompile ();
407414 // Main is re-invoked which shouldn't clear the state.
408- final logExpectation = expectLogs (['$originalString $newString ' ]);
415+ final logFuture = waitForLogs (['$originalString $newString ' ]);
409416 final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
410417 await fakeClient.callServiceExtension (hotRestart! );
411- await logExpectation ;
418+ await logFuture ;
412419
413420 vm = await client.getVM ();
414421 isolateId = vm.isolates! .first.id! ;
@@ -445,27 +452,25 @@ void runTests({
445452 test ('can hot restart with no changes, hot restart with changes, and '
446453 'hot restart again with no changes' , () async {
447454 // Empty hot restart.
448- var logExpectation = expectLogs (['$originalString $originalString ' ]);
455+ var logFuture = waitForLogs (['$originalString $originalString ' ]);
449456 await recompile ();
450457 final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
451458 await fakeClient.callServiceExtension (hotRestart! );
452- await logExpectation ;
459+ await logFuture ;
453460
454461 // Hot restart.
455- logExpectation = expectLogs ([
456- '$originalString $originalString $newString ' ,
457- ]);
462+ logFuture = waitForLogs (['$originalString $originalString $newString ' ]);
458463 await makeEditAndRecompile ();
459464 await fakeClient.callServiceExtension (hotRestart);
460- await logExpectation ;
465+ await logFuture ;
461466
462467 // Empty hot restart.
463- logExpectation = expectLogs ([
468+ logFuture = waitForLogs ([
464469 '$originalString $originalString $newString $newString ' ,
465470 ]);
466471 await recompile ();
467472 await fakeClient.callServiceExtension (hotRestart);
468- await logExpectation ;
473+ await logFuture ;
469474 });
470475 }, timeout: Timeout .factor (2 ));
471476
@@ -491,14 +496,14 @@ void runTests({
491496
492497 test ('can hot restart changes ' , () async {
493498 // Main is re-invoked which shouldn't clear the state.
494- final logExpectations = expectLogs ([
499+ final logFutures = waitForLogs ([
495500 '$originalString $newString ' ,
496501 // The ext.flutter.disassemble callback is invoked and waited for.
497502 'start disassemble' ,
498503 'end disassemble' ,
499504 ]);
500505 await makeEditAndRecompile ();
501- await logExpectations ;
506+ await logFutures ;
502507 });
503508
504509 test (
@@ -547,14 +552,14 @@ void runTests({
547552
548553 test ('can hot restart changes ' , () async {
549554 // Main is re-invoked which shouldn't clear the state.
550- final logExpectations = expectLogs ([
555+ final logFutures = waitForLogs ([
551556 '$originalString $newString ' ,
552557 // The ext.flutter.disassemble callback is invoked and waited for.
553558 'start disassemble' ,
554559 'end disassemble' ,
555560 ]);
556561 await makeEditAndRecompile ();
557- await logExpectations ;
562+ await logFutures ;
558563 });
559564 });
560565 },
@@ -604,7 +609,7 @@ void runTests({
604609 );
605610
606611 // Main is re-invoked which shouldn't clear the state.
607- final logExpectation = expectLogs (['$originalString $newString ' ]);
612+ final logFuture = waitForLogs (['$originalString $newString ' ]);
608613 final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
609614 expect (
610615 await fakeClient.callServiceExtension (hotRestart! ),
@@ -617,14 +622,14 @@ void runTests({
617622 final isolateId = vm.isolates! .first.id! ;
618623 await client.resume (isolateId);
619624
620- await logExpectation ;
625+ await logFuture ;
621626 },
622627 );
623628
624629 test (
625630 'after page refresh, does not run app until there is a resume event' ,
626631 () async {
627- final logExpectation = expectLogs ([newString]);
632+ final logFuture = waitForLogs ([newString]);
628633 await makeEditAndRecompile ();
629634 await context.webDriver.driver.refresh ();
630635
@@ -645,7 +650,7 @@ void runTests({
645650 final isolateId = vm.isolates! .first.id! ;
646651 await client.resume (isolateId);
647652
648- await logExpectation ;
653+ await logFuture ;
649654 },
650655 );
651656 });
0 commit comments