@@ -57,8 +57,8 @@ void runTests({
57
57
await recompile (hasEdits: true );
58
58
}
59
59
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 {
62
62
final expectations = List <String >.from (expectedStrings);
63
63
final completer = Completer <void >();
64
64
final subscription = context.webkitDebugger.onConsoleAPICalled.listen ((e) {
@@ -70,7 +70,14 @@ void runTests({
70
70
}
71
71
}
72
72
});
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
+ );
74
81
await subscription.cancel ();
75
82
}
76
83
@@ -96,9 +103,9 @@ void runTests({
96
103
97
104
test ('can live reload changes ' , () async {
98
105
// A full reload should clear the state.
99
- final logExpectation = expectLogs ([newString]);
106
+ final logFuture = waitForLogs ([newString]);
100
107
await makeEditAndRecompile ();
101
- await logExpectation ;
108
+ await logFuture ;
102
109
});
103
110
});
104
111
@@ -124,9 +131,9 @@ void runTests({
124
131
125
132
test ('can live reload changes ' , () async {
126
133
// A full reload should clear the state.
127
- final logExpectation = expectLogs ([newString]);
134
+ final logFuture = waitForLogs ([newString]);
128
135
await makeEditAndRecompile ();
129
- await logExpectation ;
136
+ await logFuture ;
130
137
});
131
138
});
132
139
@@ -153,9 +160,9 @@ void runTests({
153
160
154
161
test ('can live reload changes ' , () async {
155
162
// A full reload should clear the state.
156
- final logExpectation = expectLogs ([newString]);
163
+ final logFuture = waitForLogs ([newString]);
157
164
await makeEditAndRecompile ();
158
- await logExpectation ;
165
+ await logFuture ;
159
166
});
160
167
});
161
168
},
@@ -292,15 +299,15 @@ void runTests({
292
299
),
293
300
);
294
301
// Main is re-invoked which shouldn't clear the state.
295
- final logExpectation = expectLogs (['$originalString $newString ' ]);
302
+ final logFuture = waitForLogs (['$originalString $newString ' ]);
296
303
final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
297
304
expect (
298
305
await fakeClient.callServiceExtension (hotRestart! ),
299
306
const TypeMatcher <Success >(),
300
307
);
301
308
302
309
await eventsDone;
303
- await logExpectation ;
310
+ await logFuture ;
304
311
});
305
312
306
313
test ('can send events before and after hot restart' , () async {
@@ -334,7 +341,7 @@ void runTests({
334
341
335
342
await recompile ();
336
343
// Main is re-invoked which shouldn't clear the state.
337
- final logExpectation = expectLogs (['$originalString $originalString ' ]);
344
+ final logFuture = waitForLogs (['$originalString $originalString ' ]);
338
345
final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
339
346
expect (
340
347
await fakeClient.callServiceExtension (hotRestart! ),
@@ -353,7 +360,7 @@ void runTests({
353
360
);
354
361
355
362
await eventsDone;
356
- await logExpectation ;
363
+ await logFuture ;
357
364
});
358
365
359
366
test ('can refresh the page via the fullReload service extension' , () async {
@@ -372,15 +379,15 @@ void runTests({
372
379
),
373
380
);
374
381
// Should see only the new text.
375
- final logExpectation = expectLogs ([newString]);
382
+ final logFuture = waitForLogs ([newString]);
376
383
final fullReload = context.getRegisteredServiceExtension ('fullReload' );
377
384
expect (
378
385
await fakeClient.callServiceExtension (fullReload! ),
379
386
isA <Success >(),
380
387
);
381
388
382
389
await eventsDone;
383
- await logExpectation ;
390
+ await logFuture ;
384
391
});
385
392
386
393
test ('can hot restart while paused' , () async {
@@ -405,10 +412,10 @@ void runTests({
405
412
406
413
await makeEditAndRecompile ();
407
414
// Main is re-invoked which shouldn't clear the state.
408
- final logExpectation = expectLogs (['$originalString $newString ' ]);
415
+ final logFuture = waitForLogs (['$originalString $newString ' ]);
409
416
final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
410
417
await fakeClient.callServiceExtension (hotRestart! );
411
- await logExpectation ;
418
+ await logFuture ;
412
419
413
420
vm = await client.getVM ();
414
421
isolateId = vm.isolates! .first.id! ;
@@ -445,27 +452,25 @@ void runTests({
445
452
test ('can hot restart with no changes, hot restart with changes, and '
446
453
'hot restart again with no changes' , () async {
447
454
// Empty hot restart.
448
- var logExpectation = expectLogs (['$originalString $originalString ' ]);
455
+ var logFuture = waitForLogs (['$originalString $originalString ' ]);
449
456
await recompile ();
450
457
final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
451
458
await fakeClient.callServiceExtension (hotRestart! );
452
- await logExpectation ;
459
+ await logFuture ;
453
460
454
461
// Hot restart.
455
- logExpectation = expectLogs ([
456
- '$originalString $originalString $newString ' ,
457
- ]);
462
+ logFuture = waitForLogs (['$originalString $originalString $newString ' ]);
458
463
await makeEditAndRecompile ();
459
464
await fakeClient.callServiceExtension (hotRestart);
460
- await logExpectation ;
465
+ await logFuture ;
461
466
462
467
// Empty hot restart.
463
- logExpectation = expectLogs ([
468
+ logFuture = waitForLogs ([
464
469
'$originalString $originalString $newString $newString ' ,
465
470
]);
466
471
await recompile ();
467
472
await fakeClient.callServiceExtension (hotRestart);
468
- await logExpectation ;
473
+ await logFuture ;
469
474
});
470
475
}, timeout: Timeout .factor (2 ));
471
476
@@ -491,14 +496,14 @@ void runTests({
491
496
492
497
test ('can hot restart changes ' , () async {
493
498
// Main is re-invoked which shouldn't clear the state.
494
- final logExpectations = expectLogs ([
499
+ final logFutures = waitForLogs ([
495
500
'$originalString $newString ' ,
496
501
// The ext.flutter.disassemble callback is invoked and waited for.
497
502
'start disassemble' ,
498
503
'end disassemble' ,
499
504
]);
500
505
await makeEditAndRecompile ();
501
- await logExpectations ;
506
+ await logFutures ;
502
507
});
503
508
504
509
test (
@@ -547,14 +552,14 @@ void runTests({
547
552
548
553
test ('can hot restart changes ' , () async {
549
554
// Main is re-invoked which shouldn't clear the state.
550
- final logExpectations = expectLogs ([
555
+ final logFutures = waitForLogs ([
551
556
'$originalString $newString ' ,
552
557
// The ext.flutter.disassemble callback is invoked and waited for.
553
558
'start disassemble' ,
554
559
'end disassemble' ,
555
560
]);
556
561
await makeEditAndRecompile ();
557
- await logExpectations ;
562
+ await logFutures ;
558
563
});
559
564
});
560
565
},
@@ -604,7 +609,7 @@ void runTests({
604
609
);
605
610
606
611
// Main is re-invoked which shouldn't clear the state.
607
- final logExpectation = expectLogs (['$originalString $newString ' ]);
612
+ final logFuture = waitForLogs (['$originalString $newString ' ]);
608
613
final hotRestart = context.getRegisteredServiceExtension ('hotRestart' );
609
614
expect (
610
615
await fakeClient.callServiceExtension (hotRestart! ),
@@ -617,14 +622,14 @@ void runTests({
617
622
final isolateId = vm.isolates! .first.id! ;
618
623
await client.resume (isolateId);
619
624
620
- await logExpectation ;
625
+ await logFuture ;
621
626
},
622
627
);
623
628
624
629
test (
625
630
'after page refresh, does not run app until there is a resume event' ,
626
631
() async {
627
- final logExpectation = expectLogs ([newString]);
632
+ final logFuture = waitForLogs ([newString]);
628
633
await makeEditAndRecompile ();
629
634
await context.webDriver.driver.refresh ();
630
635
@@ -645,7 +650,7 @@ void runTests({
645
650
final isolateId = vm.isolates! .first.id! ;
646
651
await client.resume (isolateId);
647
652
648
- await logExpectation ;
653
+ await logFuture ;
649
654
},
650
655
);
651
656
});
0 commit comments