Skip to content

Commit 18483f3

Browse files
Clement Skaucommit-bot@chromium.org
Clement Skau
authored andcommitted
[test] Makes async_throws_stack_*_test more lenient
TEST=runtime/tests/vm/dart{,_2}/causal_stacks/utils.dart Bug: #44709 Change-Id: I33d6cd82dac99eb43e58ad16026447f14a9740c8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199425 Commit-Queue: Clement Skau <[email protected]> Reviewed-by: Lasse R.H. Nielsen <[email protected]>
1 parent 7daec44 commit 18483f3

File tree

2 files changed

+89
-257
lines changed

2 files changed

+89
-257
lines changed

runtime/tests/vm/dart/causal_stacks/utils.dart

Lines changed: 45 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ Future futureThen() {
190190

191191
// Helpers:
192192

193+
// Marker to tell the matcher to ignore the rest of the stack.
194+
const IGNORE_REMAINING_STACK = '#@ IGNORE_REMAINING_STACK #@';
195+
193196
// We want lines that either start with a frame index or an async gap marker.
194197
final _lineRE = RegExp(r'^(?:#(?<number>\d+)|<asynchronous suspension>)');
195198

@@ -236,6 +239,10 @@ Future<void> assertStack(List<String> expects, StackTrace stackTrace,
236239
print('Expected line ${i + 1} to be ${expects[i]} but was missing');
237240
rethrow;
238241
}
242+
// If we encounter this special marker we ignore the rest of the stack.
243+
if (expects[i] == IGNORE_REMAINING_STACK) {
244+
return;
245+
}
239246
try {
240247
Expect.isTrue(RegExp(expects[i]).hasMatch(frames[i]));
241248
} on ExpectException {
@@ -301,16 +308,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
301308
final expected = const <String>[
302309
r'^#0 throwSync \(.*/utils.dart:16(:3)?\)$',
303310
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,
314314
];
315315
await doTestAwait(allYield, expected, debugInfoFilename);
316316
await doTestAwaitThen(allYield, expected, debugInfoFilename);
@@ -329,15 +329,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
329329
];
330330
final postfix = const <String>[
331331
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,
341335
];
342336
await 0; // Don't let the `await do..`s chain together.
343337
await doTestAwait(
@@ -374,16 +368,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
374368
{
375369
final expected = const <String>[
376370
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,
387374
];
388375
await doTestAwait(mixedYields, expected, debugInfoFilename);
389376
await doTestAwaitThen(mixedYields, expected, debugInfoFilename);
@@ -393,16 +380,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
393380
{
394381
final expected = const <String>[
395382
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,
406386
];
407387
await doTestAwait(syncSuffix, expected, debugInfoFilename);
408388
await doTestAwaitThen(syncSuffix, expected, debugInfoFilename);
@@ -412,16 +392,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
412392
{
413393
final expected = const <String>[
414394
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,
425398
];
426399
await doTestAwait(nonAsyncNoStack, expected, debugInfoFilename);
427400
await doTestAwaitThen(nonAsyncNoStack, expected, debugInfoFilename);
@@ -433,15 +406,8 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
433406
r'^#0 throwSync \(.+/utils.dart:16(:3)?\)$',
434407
r'^#1 asyncStarThrowSync \(.+/utils.dart:112(:11)?\)$',
435408
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,
445411
];
446412
await doTestAwait(
447413
awaitEveryAsyncStarThrowSync, expected, debugInfoFilename);
@@ -454,16 +420,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
454420
{
455421
final expected = const <String>[
456422
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,
467426
];
468427
await doTestAwait(
469428
awaitEveryAsyncStarThrowAsync, expected, debugInfoFilename);
@@ -476,16 +435,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
476435
{
477436
final expected = const <String>[
478437
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,
489441
];
490442
await doTestAwait(listenAsyncStarThrowAsync, expected, debugInfoFilename);
491443
await doTestAwaitThen(
@@ -498,20 +450,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
498450
final expected = const <String>[
499451
r'#0 throwSync \(.*/utils.dart:16(:3)?\)$',
500452
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,
515456
];
516457
await doTestAwait(customErrorZone, expected, debugInfoFilename);
517458
await doTestAwaitThen(customErrorZone, expected, debugInfoFilename);
@@ -521,15 +462,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
521462
{
522463
final expected = const <String>[
523464
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,
533468
];
534469
await doTestAwait(awaitTimeout, expected, debugInfoFilename);
535470
await doTestAwaitThen(awaitTimeout, expected, debugInfoFilename);
@@ -539,15 +474,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
539474
{
540475
final expected = const <String>[
541476
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,
551480
];
552481
await doTestAwait(awaitWait, expected, debugInfoFilename);
553482
await doTestAwaitThen(awaitWait, expected, debugInfoFilename);
@@ -557,15 +486,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
557486
{
558487
final expected = const <String>[
559488
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,
569492
];
570493
await doTestAwait(futureSyncWhenComplete, expected, debugInfoFilename);
571494
await doTestAwaitThen(futureSyncWhenComplete, expected, debugInfoFilename);
@@ -577,16 +500,9 @@ Future<void> doTestsNoCausalNoLazy([String? debugInfoFilename]) async {
577500
final expected = const <String>[
578501
r'^#0 throwSync \(.*/utils.dart:16(:3)?\)$',
579502
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,
590506
];
591507
await doTestAwait(futureThen, expected, debugInfoFilename);
592508
await doTestAwaitThen(futureThen, expected, debugInfoFilename);

0 commit comments

Comments
 (0)