Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: runtime/observatory/tests/service/awaiter_async_stack_contents_test.dart

Issue 2815863002: Detect unhandled exceptions in async functions without an awaiter (Closed)
Patch Set: rmacnak review Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --asyn c_debugger
5 5
6 import 'dart:developer'; 6 import 'dart:developer';
7 import 'package:observatory/models.dart' as M; 7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/service_io.dart'; 8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'service_test_common.dart'; 10 import 'service_test_common.dart';
11 import 'test_helper.dart'; 11 import 'test_helper.dart';
12 12
13 const LINE_C = 19; 13 const LINE_C = 19;
14 const LINE_A = 24; 14 const LINE_A = 24;
(...skipping 19 matching lines...) Expand all
34 hasStoppedAtBreakpoint, 34 hasStoppedAtBreakpoint,
35 stoppedAtLine(LINE_B), 35 stoppedAtLine(LINE_B),
36 (Isolate isolate) async { 36 (Isolate isolate) async {
37 ServiceMap stack = await isolate.getStack(); 37 ServiceMap stack = await isolate.getStack();
38 // No awaiter frames because we are in a completely synchronous stack. 38 // No awaiter frames because we are in a completely synchronous stack.
39 expect(stack['awaiterFrames'], isNull); 39 expect(stack['awaiterFrames'], isNull);
40 }, 40 },
41 resumeIsolate, 41 resumeIsolate,
42 hasStoppedAtBreakpoint, 42 hasStoppedAtBreakpoint,
43 stoppedAtLine(LINE_A), 43 stoppedAtLine(LINE_A),
44 (Isolate isolate) async {
45 ServiceMap stack = await isolate.getStack();
46 // No awaiter frames because there is no awaiter.
47 expect(stack['awaiterFrames'], isNull);
48 },
49 resumeIsolate, 44 resumeIsolate,
50 hasStoppedAtBreakpoint, 45 hasStoppedAtBreakpoint,
51 stoppedAtLine(LINE_C), 46 stoppedAtLine(LINE_C),
52 (Isolate isolate) async { 47 (Isolate isolate) async {
53 // Verify awaiter stack trace is the current frame + the awaiter. 48 // Verify awaiter stack trace is the current frame + the awaiter.
54 ServiceMap stack = await isolate.getStack(); 49 ServiceMap stack = await isolate.getStack();
55 expect(stack['awaiterFrames'], isNotNull); 50 expect(stack['awaiterFrames'], isNotNull);
56 List awaiterFrames = stack['awaiterFrames']; 51 List awaiterFrames = stack['awaiterFrames'];
57 expect(awaiterFrames.length, greaterThanOrEqualTo(4)); 52 expect(awaiterFrames.length, greaterThanOrEqualTo(4));
58 // Awaiter frame. 53 // Awaiter frame.
59 expect(await awaiterFrames[0].toUserString(), 54 expect(await awaiterFrames[0].toUserString(),
60 stringContainsInOrder(['foobar', '.dart:19'])); 55 stringContainsInOrder(['foobar', '.dart:19']));
61 // Awaiter frame. 56 // Awaiter frame.
62 expect(await awaiterFrames[1].toUserString(), 57 expect(await awaiterFrames[1].toUserString(),
63 stringContainsInOrder(['helper', '.dart:25'])); 58 stringContainsInOrder(['helper', '.dart:25']));
64 // Suspension point. 59 // Suspension point.
65 expect(awaiterFrames[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); 60 expect(awaiterFrames[2].kind, equals(M.FrameKind.asyncSuspensionMarker));
66 // Causal frame. 61 // Causal frame.
67 expect(await awaiterFrames[3].toUserString(), 62 expect(await awaiterFrames[3].toUserString(),
68 stringContainsInOrder(['testMain', '.dart:30'])); 63 stringContainsInOrder(['testMain', '.dart:30']));
69 }, 64 },
70 ]; 65 ];
71 66
72 main(args) => 67 main(args) =>
73 runIsolateTestsSynchronous(args, tests, testeeConcurrent: testMain); 68 runIsolateTestsSynchronous(args, tests, testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698