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

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

Issue 2646443005: Track async causal stack traces (Closed)
Patch Set: rebase Created 3 years, 10 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug
5
6 import 'dart:developer';
7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/service_io.dart';
9 import 'package:unittest/unittest.dart';
10 import 'service_test_common.dart';
11 import 'test_helper.dart';
12
13 const LINE_C = 19;
14 const LINE_A = 24;
15 const LINE_B = 30;
16
17 foobar() {
18 debugger();
19 print('foobar'); // LINE_C.
20 }
21
22 helper() async {
23 debugger();
24 print('helper'); // LINE_A.
25 foobar();
26 }
27
28 testMain() {
29 debugger();
30 helper(); // LINE_B.
31 }
32
33 var tests = [
34 hasStoppedAtBreakpoint,
35 stoppedAtLine(LINE_B),
36 (Isolate isolate) async {
37 ServiceMap stack = await isolate.getStack();
38 // No causal frames because we are in a completely synchronous stack.
39 expect(stack['asyncCausalFrames'], isNull);
40 },
41 resumeIsolate,
42 hasStoppedAtBreakpoint,
43 stoppedAtLine(LINE_A),
44
45 (Isolate isolate) async {
46 ServiceMap stack = await isolate.getStack();
47 // Has causal frames (we are inside an async function)
48 expect(stack['asyncCausalFrames'], isNotNull);
49 var asyncStack = stack['asyncCausalFrames'];
50 expect(asyncStack[0].toString(), contains('helper_async_body'));
51 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
52 expect(asyncStack[2].toString(), contains('helper'));
53 expect(asyncStack[3].toString(), contains('testMain'));
54 },
55
56 resumeIsolate,
57 hasStoppedAtBreakpoint,
58 stoppedAtLine(LINE_C),
59
60 (Isolate isolate) async {
61 ServiceMap stack = await isolate.getStack();
62 // Has causal frames (we are inside a function called by an async function)
63 expect(stack['asyncCausalFrames'], isNotNull);
64 var asyncStack = stack['asyncCausalFrames'];
65 expect(asyncStack[0].toString(), contains('foobar'));
66 expect(asyncStack[1].toString(), contains('helper_async_body'));
67 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker));
68 expect(asyncStack[3].toString(), contains('helper'));
69 },
70 ];
71
72 main(args) => runIsolateTestsSynchronous(args,
73 tests,
74 testeeConcurrent: testMain);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698