@@ -149,6 +149,14 @@ Future<void> customErrorZone() async {
149
149
return completer.future;
150
150
}
151
151
152
+ // ----
153
+ // Scenario: Future.timeout:
154
+ // ----
155
+
156
+ Future awaitTimeout () async {
157
+ await (throwAsync ().timeout (Duration (seconds: 1 )));
158
+ }
159
+
152
160
// Helpers:
153
161
154
162
// We want lines that either start with a frame index or an async gap marker.
@@ -587,6 +595,7 @@ Future<void> doTestsCausal([String? debugInfoFilename]) async {
587
595
r'^#7 _RawReceivePortImpl._handleMessage \(.+\)$' ,
588
596
],
589
597
debugInfoFilename);
598
+
590
599
final customErrorZoneExpected = const < String > [
591
600
r'#0 throwSync \(.*/utils.dart:16(:3)?\)$' ,
592
601
r'#1 allYield3 \(.*/utils.dart:39(:3)?\)$' ,
@@ -638,6 +647,48 @@ Future<void> doTestsCausal([String? debugInfoFilename]) async {
638
647
r'#14 _RawReceivePortImpl._handleMessage ' ,
639
648
],
640
649
debugInfoFilename);
650
+
651
+ final awaitTimeoutExpected = const < String > [
652
+ r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
653
+ r'^^<asynchronous suspension>$' ,
654
+ r'^#1 awaitTimeout ' ,
655
+ ];
656
+ await doTestAwait (
657
+ awaitTimeout,
658
+ awaitTimeoutExpected +
659
+ const < String > [
660
+ r'^#2 doTestAwait ' ,
661
+ r'^#3 doTestsCausal ' ,
662
+ r'^<asynchronous suspension>$' ,
663
+ r'^#4 main \(.+\)$' ,
664
+ r'^#5 _startIsolate.<anonymous closure> ' ,
665
+ r'^#6 _RawReceivePortImpl._handleMessage ' ,
666
+ ],
667
+ debugInfoFilename);
668
+ await doTestAwaitThen (
669
+ awaitTimeout,
670
+ awaitTimeoutExpected +
671
+ const < String > [
672
+ r'^#2 doTestAwaitThen ' ,
673
+ r'^#3 doTestsCausal ' ,
674
+ r'^<asynchronous suspension>$' ,
675
+ r'^#4 main \(.+\)$' ,
676
+ r'^#5 _startIsolate.<anonymous closure> ' ,
677
+ r'^#6 _RawReceivePortImpl._handleMessage ' ,
678
+ ],
679
+ debugInfoFilename);
680
+ await doTestAwaitCatchError (
681
+ awaitTimeout,
682
+ awaitTimeoutExpected +
683
+ const < String > [
684
+ r'^#2 doTestAwaitCatchError ' ,
685
+ r'^#3 doTestsCausal ' ,
686
+ r'^<asynchronous suspension>$' ,
687
+ r'^#4 main \(.+\)$' ,
688
+ r'^#5 _startIsolate.<anonymous closure> ' ,
689
+ r'^#6 _RawReceivePortImpl._handleMessage ' ,
690
+ ],
691
+ debugInfoFilename);
641
692
}
642
693
643
694
// For: --no-causal-async-stacks --no-lazy-async-stacks
@@ -957,6 +1008,25 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
957
1008
customErrorZone, customErrorZoneExpected, debugInfoFilename);
958
1009
await doTestAwaitCatchError (
959
1010
customErrorZone, customErrorZoneExpected, debugInfoFilename);
1011
+
1012
+ final awaitTimeoutExpected = const < String > [
1013
+ r'#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
1014
+ r'^#1 _RootZone.runUnary ' ,
1015
+ r'^#2 _FutureListener.handleValue ' ,
1016
+ r'^#3 Future._propagateToListeners.handleValueCallback ' ,
1017
+ r'^#4 Future._propagateToListeners ' ,
1018
+ r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
1019
+ r'^#6 _microtaskLoop ' ,
1020
+ r'^#7 _startMicrotaskLoop ' ,
1021
+ r'^#8 _runPendingImmediateCallback ' ,
1022
+ r'^#9 _RawReceivePortImpl._handleMessage ' ,
1023
+ ];
1024
+ await doTestAwait (
1025
+ awaitTimeout, awaitTimeoutExpected + const < String > [], debugInfoFilename);
1026
+ await doTestAwaitThen (
1027
+ awaitTimeout, awaitTimeoutExpected + const < String > [], debugInfoFilename);
1028
+ await doTestAwaitCatchError (
1029
+ awaitTimeout, awaitTimeoutExpected + const < String > [], debugInfoFilename);
960
1030
}
961
1031
962
1032
// For: --lazy-async-stacks
@@ -1218,4 +1288,35 @@ Future<void> doTestsLazy([String? debugInfoFilename]) async {
1218
1288
customErrorZone, customErrorZoneExpected, debugInfoFilename);
1219
1289
await doTestAwaitCatchError (
1220
1290
customErrorZone, customErrorZoneExpected, debugInfoFilename);
1291
+
1292
+ final awaitTimeoutExpected = const < String > [
1293
+ r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
1294
+ r'^<asynchronous suspension>$' ,
1295
+ r'^#1 Future.timeout.<anonymous closure> \(dart:async/future_impl.dart\)$' ,
1296
+ r'^<asynchronous suspension>$' ,
1297
+ r'^#2 awaitTimeout ' ,
1298
+ r'^<asynchronous suspension>$' ,
1299
+ ];
1300
+ await doTestAwait (
1301
+ awaitTimeout,
1302
+ awaitTimeoutExpected +
1303
+ const < String > [
1304
+ r'^#3 doTestAwait ' ,
1305
+ r'^<asynchronous suspension>$' ,
1306
+ r'^#4 doTestsLazy ' ,
1307
+ r'^<asynchronous suspension>$' ,
1308
+ r'^#5 main ' ,
1309
+ r'^<asynchronous suspension>$' ,
1310
+ ],
1311
+ debugInfoFilename);
1312
+ await doTestAwaitThen (
1313
+ awaitTimeout,
1314
+ awaitTimeoutExpected +
1315
+ const < String > [
1316
+ r'^#3 doTestAwaitThen.<anonymous closure> ' ,
1317
+ r'^<asynchronous suspension>$' ,
1318
+ ],
1319
+ debugInfoFilename);
1320
+ await doTestAwaitCatchError (
1321
+ awaitTimeout, awaitTimeoutExpected + const < String > [], debugInfoFilename);
1221
1322
}
0 commit comments