@@ -190,6 +190,9 @@ Future futureThen() {
190
190
191
191
// Helpers:
192
192
193
+ // Marker to tell the matcher to ignore the rest of the stack.
194
+ const IGNORE_REMAINING_STACK = '#@ IGNORE_REMAINING_STACK #@' ;
195
+
193
196
// We want lines that either start with a frame index or an async gap marker.
194
197
final _lineRE = RegExp (r'^(?:#(?<number>\d+)|<asynchronous suspension>)' );
195
198
@@ -236,6 +239,10 @@ Future<void> assertStack(List<String> expects, StackTrace stackTrace,
236
239
print ('Expected line ${i + 1 } to be ${expects [i ]} but was missing' );
237
240
rethrow ;
238
241
}
242
+ // If we encounter this special marker we ignore the rest of the stack.
243
+ if (expects[i] == IGNORE_REMAINING_STACK ) {
244
+ return ;
245
+ }
239
246
try {
240
247
Expect .isTrue (RegExp (expects[i]).hasMatch (frames[i]));
241
248
} on ExpectException {
@@ -301,16 +308,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
301
308
final expected = const < String > [
302
309
r'^#0 throwSync \(.*/utils.dart:16(:3)?\)$' ,
303
310
r'^#1 allYield3 \(.*/utils.dart:39(:3)?\)$' ,
304
- r'^#2 _RootZone.runUnary ' ,
305
- r'^#3 _FutureListener.handleValue ' ,
306
- r'^#4 Future._propagateToListeners.handleValueCallback ' ,
307
- r'^#5 Future._propagateToListeners ' ,
308
- // TODO(dart-vm): Figure out why this is inconsistent:
309
- r'^#6 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
310
- r'^#7 _microtaskLoop ' ,
311
- r'^#8 _startMicrotaskLoop ' ,
312
- r'^#9 _runPendingImmediateCallback ' ,
313
- r'^#10 _RawReceivePortImpl._handleMessage ' ,
311
+ r'^#2 _RootZone.runUnary \(.+\)$' ,
312
+ // The rest are internal frames which we don't really care about.
313
+ IGNORE_REMAINING_STACK ,
314
314
];
315
315
await doTestAwait (allYield, expected, debugInfoFilename);
316
316
await doTestAwaitThen (allYield, expected, debugInfoFilename);
@@ -329,15 +329,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
329
329
];
330
330
final postfix = const < String > [
331
331
r'^#9 doTestsNoCausalNoLazy ' ,
332
- r'^#10 _RootZone.runUnary ' ,
333
- r'^#11 _FutureListener.handleValue ' ,
334
- r'^#12 Future._propagateToListeners.handleValueCallback ' ,
335
- r'^#13 Future._propagateToListeners ' ,
336
- r'^#14 Future._addListener.<anonymous closure> ' ,
337
- r'^#15 _microtaskLoop ' ,
338
- r'^#16 _startMicrotaskLoop ' ,
339
- r'^#17 _runPendingImmediateCallback ' ,
340
- r'^#18 _RawReceivePortImpl._handleMessage ' ,
332
+ r'^#10 _RootZone.runUnary \(.+\)$' ,
333
+ // The rest are internal frames which we don't really care about.
334
+ IGNORE_REMAINING_STACK ,
341
335
];
342
336
await 0 ; // Don't let the `await do..`s chain together.
343
337
await doTestAwait (
@@ -374,16 +368,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
374
368
{
375
369
final expected = const < String > [
376
370
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
377
- r'^#1 _RootZone.runUnary ' ,
378
- r'^#2 _FutureListener.handleValue ' ,
379
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
380
- r'^#4 Future._propagateToListeners ' ,
381
- // TODO(dart-vm): Figure out why this is inconsistent:
382
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
383
- r'^#6 _microtaskLoop ' ,
384
- r'^#7 _startMicrotaskLoop ' ,
385
- r'^#8 _runPendingImmediateCallback ' ,
386
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
371
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
372
+ // The rest are internal frames which we don't really care about.
373
+ IGNORE_REMAINING_STACK ,
387
374
];
388
375
await doTestAwait (mixedYields, expected, debugInfoFilename);
389
376
await doTestAwaitThen (mixedYields, expected, debugInfoFilename);
@@ -393,16 +380,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
393
380
{
394
381
final expected = const < String > [
395
382
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
396
- r'^#1 _RootZone.runUnary ' ,
397
- r'^#2 _FutureListener.handleValue ' ,
398
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
399
- r'^#4 Future._propagateToListeners ' ,
400
- // TODO(dart-vm): Figure out why this is inconsistent:
401
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
402
- r'^#6 _microtaskLoop ' ,
403
- r'^#7 _startMicrotaskLoop ' ,
404
- r'^#8 _runPendingImmediateCallback ' ,
405
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
383
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
384
+ // The rest are internal frames which we don't really care about.
385
+ IGNORE_REMAINING_STACK ,
406
386
];
407
387
await doTestAwait (syncSuffix, expected, debugInfoFilename);
408
388
await doTestAwaitThen (syncSuffix, expected, debugInfoFilename);
@@ -412,16 +392,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
412
392
{
413
393
final expected = const < String > [
414
394
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
415
- r'^#1 _RootZone.runUnary ' ,
416
- r'^#2 _FutureListener.handleValue ' ,
417
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
418
- r'^#4 Future._propagateToListeners ' ,
419
- // TODO(dart-vm): Figure out why this is inconsistent:
420
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
421
- r'^#6 _microtaskLoop ' ,
422
- r'^#7 _startMicrotaskLoop ' ,
423
- r'^#8 _runPendingImmediateCallback ' ,
424
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
395
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
396
+ // The rest are internal frames which we don't really care about.
397
+ IGNORE_REMAINING_STACK ,
425
398
];
426
399
await doTestAwait (nonAsyncNoStack, expected, debugInfoFilename);
427
400
await doTestAwaitThen (nonAsyncNoStack, expected, debugInfoFilename);
@@ -433,15 +406,8 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
433
406
r'^#0 throwSync \(.+/utils.dart:16(:3)?\)$' ,
434
407
r'^#1 asyncStarThrowSync \(.+/utils.dart:112(:11)?\)$' ,
435
408
r'^#2 _RootZone.runUnary \(.+\)$' ,
436
- r'^#3 _FutureListener.handleValue \(.+\)$' ,
437
- r'^#4 Future._propagateToListeners.handleValueCallback \(.+\)$' ,
438
- r'^#5 Future._propagateToListeners \(.+\)$' ,
439
- // TODO(dart-vm): Figure out why this is inconsistent:
440
- r'^#6 Future.(_addListener|_prependListeners).<anonymous closure> \(.+\)$' ,
441
- r'^#7 _microtaskLoop \(.+\)$' ,
442
- r'^#8 _startMicrotaskLoop \(.+\)$' ,
443
- r'^#9 _runPendingImmediateCallback \(.+\)$' ,
444
- r'^#10 _RawReceivePortImpl._handleMessage \(.+\)$' ,
409
+ // The rest are internal frames which we don't really care about.
410
+ IGNORE_REMAINING_STACK ,
445
411
];
446
412
await doTestAwait (
447
413
awaitEveryAsyncStarThrowSync, expected, debugInfoFilename);
@@ -454,16 +420,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
454
420
{
455
421
final expected = const < String > [
456
422
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
457
- r'^#1 _RootZone.runUnary ' ,
458
- r'^#2 _FutureListener.handleValue ' ,
459
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
460
- r'^#4 Future._propagateToListeners ' ,
461
- // TODO(dart-vm): Figure out why this is inconsistent:
462
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
463
- r'^#6 _microtaskLoop ' ,
464
- r'^#7 _startMicrotaskLoop ' ,
465
- r'^#8 _runPendingImmediateCallback ' ,
466
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
423
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
424
+ // The rest are internal frames which we don't really care about.
425
+ IGNORE_REMAINING_STACK ,
467
426
];
468
427
await doTestAwait (
469
428
awaitEveryAsyncStarThrowAsync, expected, debugInfoFilename);
@@ -476,16 +435,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
476
435
{
477
436
final expected = const < String > [
478
437
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
479
- r'^#1 _RootZone.runUnary ' ,
480
- r'^#2 _FutureListener.handleValue ' ,
481
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
482
- r'^#4 Future._propagateToListeners ' ,
483
- // TODO(dart-vm): Figure out why this is inconsistent:
484
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
485
- r'^#6 _microtaskLoop ' ,
486
- r'^#7 _startMicrotaskLoop ' ,
487
- r'^#8 _runPendingImmediateCallback ' ,
488
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
438
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
439
+ // The rest are internal frames which we don't really care about.
440
+ IGNORE_REMAINING_STACK ,
489
441
];
490
442
await doTestAwait (listenAsyncStarThrowAsync, expected, debugInfoFilename);
491
443
await doTestAwaitThen (
@@ -498,20 +450,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
498
450
final expected = const < String > [
499
451
r'#0 throwSync \(.*/utils.dart:16(:3)?\)$' ,
500
452
r'#1 allYield3 \(.*/utils.dart:39(:3)?\)$' ,
501
- r'#2 _rootRunUnary ' ,
502
- r'#3 _CustomZone.runUnary ' ,
503
- r'#4 _FutureListener.handleValue ' ,
504
- r'#5 Future._propagateToListeners.handleValueCallback ' ,
505
- r'#6 Future._propagateToListeners ' ,
506
- r'#7 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
507
- r'#8 _rootRun ' ,
508
- r'#9 _CustomZone.run ' ,
509
- r'#10 _CustomZone.runGuarded ' ,
510
- r'#11 _CustomZone.bindCallbackGuarded.<anonymous closure> ' ,
511
- r'#12 _microtaskLoop ' ,
512
- r'#13 _startMicrotaskLoop ' ,
513
- r'#14 _runPendingImmediateCallback ' ,
514
- r'#15 _RawReceivePortImpl._handleMessage ' ,
453
+ r'#2 _rootRunUnary \(.+\)$' ,
454
+ // The rest are internal frames which we don't really care about.
455
+ IGNORE_REMAINING_STACK ,
515
456
];
516
457
await doTestAwait (customErrorZone, expected, debugInfoFilename);
517
458
await doTestAwaitThen (customErrorZone, expected, debugInfoFilename);
@@ -521,15 +462,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
521
462
{
522
463
final expected = const < String > [
523
464
r'#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
524
- r'^#1 _RootZone.runUnary ' ,
525
- r'^#2 _FutureListener.handleValue ' ,
526
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
527
- r'^#4 Future._propagateToListeners ' ,
528
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
529
- r'^#6 _microtaskLoop ' ,
530
- r'^#7 _startMicrotaskLoop ' ,
531
- r'^#8 _runPendingImmediateCallback ' ,
532
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
465
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
466
+ // The rest are internal frames which we don't really care about.
467
+ IGNORE_REMAINING_STACK ,
533
468
];
534
469
await doTestAwait (awaitTimeout, expected, debugInfoFilename);
535
470
await doTestAwaitThen (awaitTimeout, expected, debugInfoFilename);
@@ -539,15 +474,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
539
474
{
540
475
final expected = const < String > [
541
476
r'#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
542
- r'^#1 _RootZone.runUnary ' ,
543
- r'^#2 _FutureListener.handleValue ' ,
544
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
545
- r'^#4 Future._propagateToListeners ' ,
546
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
547
- r'^#6 _microtaskLoop ' ,
548
- r'^#7 _startMicrotaskLoop ' ,
549
- r'^#8 _runPendingImmediateCallback ' ,
550
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
477
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
478
+ // The rest are internal frames which we don't really care about.
479
+ IGNORE_REMAINING_STACK ,
551
480
];
552
481
await doTestAwait (awaitWait, expected, debugInfoFilename);
553
482
await doTestAwaitThen (awaitWait, expected, debugInfoFilename);
@@ -557,15 +486,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
557
486
{
558
487
final expected = const < String > [
559
488
r'^#0 throwAsync \(.*/utils.dart:21(:3)?\)$' ,
560
- r'^#1 _RootZone.runUnary ' ,
561
- r'^#2 _FutureListener.handleValue ' ,
562
- r'^#3 Future._propagateToListeners.handleValueCallback ' ,
563
- r'^#4 Future._propagateToListeners ' ,
564
- r'^#5 Future.(_addListener|_prependListeners).<anonymous closure> ' ,
565
- r'^#6 _microtaskLoop ' ,
566
- r'^#7 _startMicrotaskLoop ' ,
567
- r'^#8 _runPendingImmediateCallback ' ,
568
- r'^#9 _RawReceivePortImpl._handleMessage ' ,
489
+ r'^#1 _RootZone.runUnary \(.+\)$' ,
490
+ // The rest are internal frames which we don't really care about.
491
+ IGNORE_REMAINING_STACK ,
569
492
];
570
493
await doTestAwait (futureSyncWhenComplete, expected, debugInfoFilename);
571
494
await doTestAwaitThen (futureSyncWhenComplete, expected, debugInfoFilename);
@@ -577,16 +500,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
577
500
final expected = const < String > [
578
501
r'^#0 throwSync \(.*/utils.dart:16(:3)?\)$' ,
579
502
r'^#1 futureThen.<anonymous closure> \(.*/utils.dart:187(:5)?\)$' ,
580
- r'^#2 _RootZone.runUnary ' ,
581
- r'^#3 _FutureListener.handleValue ' ,
582
- r'^#4 Future._propagateToListeners.handleValueCallback ' ,
583
- r'^#5 Future._propagateToListeners ' ,
584
- r'^#6 Future._completeWithValue ' ,
585
- r'^#7 Future._asyncCompleteWithValue.<anonymous closure> ' ,
586
- r'^#8 _microtaskLoop ' ,
587
- r'^#9 _startMicrotaskLoop ' ,
588
- r'^#10 _runPendingImmediateCallback ' ,
589
- r'^#11 _RawReceivePortImpl._handleMessage ' ,
503
+ r'^#2 _RootZone.runUnary \(.+\)$' ,
504
+ // The rest are internal frames which we don't really care about.
505
+ IGNORE_REMAINING_STACK ,
590
506
];
591
507
await doTestAwait (futureThen, expected, debugInfoFilename);
592
508
await doTestAwaitThen (futureThen, expected, debugInfoFilename);
0 commit comments