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

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

Issue 2680303002: Kernel debugging; service tests (Closed)
Patch Set: New failing test 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) 2015, the Dart project authors. Please see the AUTHORS file
Kevin Millikin (Google) 2017/02/08 15:37:51 2017
jensj 2017/02/13 14:04:15 Done.
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
5
6 import 'package:observatory/service_io.dart';
7 import 'package:unittest/unittest.dart';
8 import 'service_test_common.dart';
9 import 'test_helper.dart';
10
11 import 'dart:async';
12
13 const int LINE_A = 24;
14 const int LINE_B = 26;
15
16 int value = 0;
17
18 int incValue(int amount) {
19 value += amount;
20 return amount;
21 }
22
23 Future testMain() async {
24 incValue(incValue(1)); // line A.
25
26 incValue(incValue(1)); // line B.
27 }
28
29 var tests = [
30 hasPausedAtStart,
31
32 // Test future breakpoints.
33 (Isolate isolate) async {
34 var rootLib = isolate.rootLibrary;
35 await rootLib.load();
36 var script = rootLib.scripts[0];
37
38 // Future breakpoint.
39 var futureBpt1 = await isolate.addBreakpoint(script, LINE_A);
40 expect(futureBpt1.number, equals(1));
41 expect(futureBpt1.resolved, isFalse);
42 expect(await futureBpt1.location.getLine(), equals(LINE_A));
43 expect(await futureBpt1.location.getColumn(), equals(null));
44
45 // Future breakpoint with specific column.
46 var futureBpt2 = await isolate.addBreakpoint(script, LINE_A, 3);
47 expect(futureBpt2.number, equals(2));
48 expect(futureBpt2.resolved, isFalse);
49 expect(await futureBpt2.location.getLine(), equals(LINE_A));
50 expect(await futureBpt2.location.getColumn(), equals(3));
51
52 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
Cutch 2017/02/08 16:48:19 Please factor this code into a helper method.
jensj 2017/02/13 14:04:15 Done.
53 Completer completer = new Completer();
54 var subscription;
55 var resolvedCount = 0;
56 subscription = stream.listen((ServiceEvent event) async {
57 if (event.kind == ServiceEvent.kBreakpointResolved) {
58 resolvedCount++;
59 }
60 if (event.kind == ServiceEvent.kPauseBreakpoint) {
Cutch 2017/02/08 16:48:19 this is hasStoppedAtBreakpoint
jensj 2017/02/13 14:04:15 Acknowledged.
61 subscription.cancel();
62 completer.complete(null);
63 }
64 });
65 await isolate.resume();
66 await completer.future;
67
68 // After resolution the breakpoints have assigned line & column.
69 expect(resolvedCount, equals(2));
70 expect(futureBpt1.resolved, isTrue);
71 expect(await futureBpt1.location.getLine(), equals(LINE_A));
72 expect(await futureBpt1.location.getColumn(), equals(12));
73 expect(futureBpt2.resolved, isTrue);
74 expect(await futureBpt2.location.getLine(), equals(LINE_A));
75 expect(await futureBpt2.location.getColumn(), equals(3));
76
77 // The first breakpoint hits before value is modified.
78 expect((await rootLib.evaluate('value')).valueAsString, equals('0'));
79
80 stream = await isolate.vm.getEventStream(VM.kDebugStream);
81 completer = new Completer();
Cutch 2017/02/08 16:48:20 (here and elsewhere) Please use the helper: hasSto
jensj 2017/02/13 14:04:15 I've refactored this file and the file it was copi
82 subscription = stream.listen((ServiceEvent event) async {
83 if (event.kind == ServiceEvent.kPauseBreakpoint) {
84 subscription.cancel();
85 completer.complete(null);
86 }
87 });
88 await isolate.resume();
89 await completer.future;
90
91 // The second breakpoint hits after value has been modified once.
92 expect((await rootLib.evaluate('value')).valueAsString, equals('1'));
93
94 // Remove the breakpoints.
95 expect((await isolate.removeBreakpoint(futureBpt1)).type,
96 equals('Success'));
97 expect((await isolate.removeBreakpoint(futureBpt2)).type,
98 equals('Success'));
99 },
100
101 // Test resolution of column breakpoints.
102 (Isolate isolate) async {
103 var script = isolate.rootLibrary.scripts[0];
104 // Try all columns, including some columns that are too big.
105 for (int col = 1; col <= 50; col++) {
106 var bpt = await isolate.addBreakpoint(script, LINE_A, col);
107 expect(bpt.resolved, isTrue);
108 int resolvedLine = await bpt.location.getLine();
109 int resolvedCol = await bpt.location.getColumn();
110 print('$LINE_A:${col} -> ${resolvedLine}:${resolvedCol}');
111 if (col <= 10) {
112 expect(resolvedLine, equals(LINE_A));
113 expect(resolvedCol, equals(3));
114 } else if (col <= 19) {
115 expect(resolvedLine, equals(LINE_A));
116 expect(resolvedCol, equals(12));
117 } else {
118 expect(resolvedLine, equals(LINE_B));
119 expect(resolvedCol, equals(12));
120 }
121 expect((await isolate.removeBreakpoint(bpt)).type, equals('Success'));
122 }
123
124 // Make sure that a zero column is an error.
125 var caughtException = false;
126 try {
127 await isolate.addBreakpoint(script, 20, 0);
128 expect(false, isTrue, reason:'Unreachable');
129 } on ServerRpcException catch(e) {
130 caughtException = true;
131 expect(e.code, equals(ServerRpcException.kInvalidParams));
132 expect(e.message,
133 "addBreakpoint: invalid 'column' parameter: 0");
134 }
135 expect(caughtException, isTrue);
136 },
137 ];
138
139 main(args) => runIsolateTests(args, tests,
140 testeeConcurrent: testMain,
141 pause_on_start: true);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698