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

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

Issue 2521413002: Revert "Implement rewind: drop one or more frames from the debugger." (Closed)
Patch Set: Created 4 years 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 4
5 library test_helper; 5 library test_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'package:observatory/service_io.dart'; 10 import 'package:observatory/service_io.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 final List<String> args; 83 final List<String> args;
84 bool killedByTester = false; 84 bool killedByTester = false;
85 85
86 _ServiceTesteeLauncher() : 86 _ServiceTesteeLauncher() :
87 args = [Platform.script.toFilePath()] {} 87 args = [Platform.script.toFilePath()] {}
88 88
89 // Spawn the testee process. 89 // Spawn the testee process.
90 Future<Process> _spawnProcess(bool pause_on_start, 90 Future<Process> _spawnProcess(bool pause_on_start,
91 bool pause_on_exit, 91 bool pause_on_exit,
92 bool pause_on_unhandled_exceptions, 92 bool pause_on_unhandled_exceptions,
93 bool trace_service,
94 bool trace_compiler,
93 bool testeeControlsServer, 95 bool testeeControlsServer,
94 bool useAuthToken, 96 bool useAuthToken) {
95 List<String> extraArgs) {
96 assert(pause_on_start != null); 97 assert(pause_on_start != null);
97 assert(pause_on_exit != null); 98 assert(pause_on_exit != null);
98 assert(pause_on_unhandled_exceptions != null); 99 assert(pause_on_unhandled_exceptions != null);
100 assert(trace_service != null);
101 assert(trace_compiler != null);
99 assert(testeeControlsServer != null); 102 assert(testeeControlsServer != null);
100 assert(useAuthToken != null); 103 assert(useAuthToken != null);
101 104
102 if (_shouldLaunchSkyShell()) { 105 if (_shouldLaunchSkyShell()) {
103 return _spawnSkyProcess(pause_on_start, 106 return _spawnSkyProcess(pause_on_start,
104 pause_on_exit, 107 pause_on_exit,
105 pause_on_unhandled_exceptions, 108 pause_on_unhandled_exceptions,
106 testeeControlsServer, 109 trace_service,
107 extraArgs); 110 trace_compiler,
111 testeeControlsServer);
108 } else { 112 } else {
109 return _spawnDartProcess(pause_on_start, 113 return _spawnDartProcess(pause_on_start,
110 pause_on_exit, 114 pause_on_exit,
111 pause_on_unhandled_exceptions, 115 pause_on_unhandled_exceptions,
116 trace_service,
117 trace_compiler,
112 testeeControlsServer, 118 testeeControlsServer,
113 useAuthToken, 119 useAuthToken);
114 extraArgs);
115 } 120 }
116 } 121 }
117 122
118 Future<Process> _spawnDartProcess(bool pause_on_start, 123 Future<Process> _spawnDartProcess(bool pause_on_start,
119 bool pause_on_exit, 124 bool pause_on_exit,
120 bool pause_on_unhandled_exceptions, 125 bool pause_on_unhandled_exceptions,
126 bool trace_service,
127 bool trace_compiler,
121 bool testeeControlsServer, 128 bool testeeControlsServer,
122 bool useAuthToken, 129 bool useAuthToken) {
123 List<String> extraArgs) {
124 assert(!_shouldLaunchSkyShell()); 130 assert(!_shouldLaunchSkyShell());
125 131
126 String dartExecutable = Platform.executable; 132 String dartExecutable = Platform.executable;
127 133
128 var fullArgs = []; 134 var fullArgs = [];
135 if (trace_service) {
136 fullArgs.add('--trace-service');
137 fullArgs.add('--trace-service-verbose');
138 }
139 if (trace_compiler) {
140 fullArgs.add('--trace-compiler');
141 }
129 if (pause_on_start) { 142 if (pause_on_start) {
130 fullArgs.add('--pause-isolates-on-start'); 143 fullArgs.add('--pause-isolates-on-start');
131 } 144 }
132 if (pause_on_exit) { 145 if (pause_on_exit) {
133 fullArgs.add('--pause-isolates-on-exit'); 146 fullArgs.add('--pause-isolates-on-exit');
134 } 147 }
135 if (pause_on_unhandled_exceptions) { 148 if (pause_on_unhandled_exceptions) {
136 fullArgs.add('--pause-isolates-on-unhandled-exceptions'); 149 fullArgs.add('--pause-isolates-on-unhandled-exceptions');
137 } 150 }
138 if (extraArgs != null) {
139 fullArgs.addAll(extraArgs);
140 }
141 151
142 fullArgs.addAll(Platform.executableArguments); 152 fullArgs.addAll(Platform.executableArguments);
143 if (!testeeControlsServer) { 153 if (!testeeControlsServer) {
144 fullArgs.add('--enable-vm-service:0'); 154 fullArgs.add('--enable-vm-service:0');
145 } 155 }
146 fullArgs.addAll(args); 156 fullArgs.addAll(args);
147 157
148 return _spawnCommon( 158 return _spawnCommon(
149 dartExecutable, 159 dartExecutable,
150 fullArgs, 160 fullArgs,
151 <String, String>{ 161 <String, String>{
152 'DART_SERVICE_USE_AUTH': '$useAuthToken' 162 'DART_SERVICE_USE_AUTH': '$useAuthToken'
153 }); 163 });
154 } 164 }
155 165
156 Future<Process> _spawnSkyProcess(bool pause_on_start, 166 Future<Process> _spawnSkyProcess(bool pause_on_start,
157 bool pause_on_exit, 167 bool pause_on_exit,
158 bool pause_on_unhandled_exceptions, 168 bool pause_on_unhandled_exceptions,
159 bool testeeControlsServer, 169 bool trace_service,
160 List<String> extraArgs) { 170 bool trace_compiler,
171 bool testeeControlsServer) {
161 assert(_shouldLaunchSkyShell()); 172 assert(_shouldLaunchSkyShell());
162 173
163 String dartExecutable = _skyShellPath(); 174 String dartExecutable = _skyShellPath();
164 175
165 var dartFlags = []; 176 var dartFlags = [];
166 var fullArgs = []; 177 var fullArgs = [];
178 if (trace_service) {
179 dartFlags.add('--trace_service');
180 dartFlags.add('--trace_service_verbose');
181 }
182 if (trace_compiler) {
183 dartFlags.add('--trace_compiler');
184 }
167 if (pause_on_start) { 185 if (pause_on_start) {
168 dartFlags.add('--pause_isolates_on_start'); 186 dartFlags.add('--pause_isolates_on_start');
169 fullArgs.add('--start-paused'); 187 fullArgs.add('--start-paused');
170 } 188 }
171 if (pause_on_exit) { 189 if (pause_on_exit) {
172 dartFlags.add('--pause_isolates_on_exit'); 190 dartFlags.add('--pause_isolates_on_exit');
173 } 191 }
174 if (pause_on_unhandled_exceptions) { 192 if (pause_on_unhandled_exceptions) {
175 dartFlags.add('--pause_isolates_on_unhandled_exceptions'); 193 dartFlags.add('--pause_isolates_on_unhandled_exceptions');
176 } 194 }
177 // Override mirrors. 195 // Override mirrors.
178 dartFlags.add('--enable_mirrors=true'); 196 dartFlags.add('--enable_mirrors=true');
179 if (extraArgs != null) {
180 fullArgs.addAll(extraArgs);
181 }
182 197
183 fullArgs.addAll(Platform.executableArguments); 198 fullArgs.addAll(Platform.executableArguments);
184 if (!testeeControlsServer) { 199 if (!testeeControlsServer) {
185 fullArgs.add('--observatory-port=0'); 200 fullArgs.add('--observatory-port=0');
186 } 201 }
187 fullArgs.add('--dart-flags=${dartFlags.join(' ')}'); 202 fullArgs.add('--dart-flags=${dartFlags.join(' ')}');
188 fullArgs.addAll(args); 203 fullArgs.addAll(args);
189 204
190 return _spawnCommon(dartExecutable, fullArgs, <String, String>{}); 205 return _spawnCommon(dartExecutable, fullArgs, <String, String>{});
191 } 206 }
192 207
193 Future<Process> _spawnCommon(String executable, 208 Future<Process> _spawnCommon(String executable,
194 List<String> arguments, 209 List<String> arguments,
195 Map<String, String> dartEnvironment) { 210 Map<String, String> dartEnvironment) {
196 var environment = _TESTEE_SPAWN_ENV; 211 var environment = _TESTEE_SPAWN_ENV;
197 var bashEnvironment = new StringBuffer(); 212 var bashEnvironment = new StringBuffer();
198 environment.forEach((k, v) => bashEnvironment.write("$k=$v ")); 213 environment.forEach((k, v) => bashEnvironment.write("$k=$v "));
199 if (dartEnvironment != null) { 214 if (dartEnvironment != null) {
200 dartEnvironment.forEach((k, v) { 215 dartEnvironment.forEach((k, v) {
201 arguments.insert(0, '-D$k=$v'); 216 arguments.insert(0, '-D$k=$v');
202 }); 217 });
203 } 218 }
204 print('** Launching $bashEnvironment$executable ${arguments.join(' ')}'); 219 print('** Launching $bashEnvironment$executable ${arguments.join(' ')}');
205 return Process.start(executable, arguments, environment: environment); 220 return Process.start(executable, arguments, environment: environment);
206 } 221 }
207 222
208 Future<Uri> launch(bool pause_on_start, 223 Future<Uri> launch(bool pause_on_start,
209 bool pause_on_exit, 224 bool pause_on_exit,
210 bool pause_on_unhandled_exceptions, 225 bool pause_on_unhandled_exceptions,
226 bool trace_service,
227 bool trace_compiler,
211 bool testeeControlsServer, 228 bool testeeControlsServer,
212 bool useAuthToken, 229 bool useAuthToken) {
213 List<String> extraArgs) {
214 return _spawnProcess(pause_on_start, 230 return _spawnProcess(pause_on_start,
215 pause_on_exit, 231 pause_on_exit,
216 pause_on_unhandled_exceptions, 232 pause_on_unhandled_exceptions,
233 trace_service,
234 trace_compiler,
217 testeeControlsServer, 235 testeeControlsServer,
218 useAuthToken, 236 useAuthToken).then((p) {
219 extraArgs).then((p) {
220 Completer<Uri> completer = new Completer<Uri>(); 237 Completer<Uri> completer = new Completer<Uri>();
221 process = p; 238 process = p;
222 Uri uri; 239 Uri uri;
223 var blank; 240 var blank;
224 var first = true; 241 var first = true;
225 process.stdout.transform(UTF8.decoder) 242 process.stdout.transform(UTF8.decoder)
226 .transform(new LineSplitter()).listen((line) { 243 .transform(new LineSplitter()).listen((line) {
227 const kObservatoryListening = 'Observatory listening on '; 244 const kObservatoryListening = 'Observatory listening on ';
228 if (line.startsWith(kObservatoryListening)) { 245 if (line.startsWith(kObservatoryListening)) {
229 uri = Uri.parse(line.substring(kObservatoryListening.length)); 246 uri = Uri.parse(line.substring(kObservatoryListening.length));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 281
265 void setupAddresses(Uri serverAddress) { 282 void setupAddresses(Uri serverAddress) {
266 serviceWebsocketAddress = 283 serviceWebsocketAddress =
267 'ws://${serverAddress.authority}${serverAddress.path}ws'; 284 'ws://${serverAddress.authority}${serverAddress.path}ws';
268 serviceHttpAddress = 285 serviceHttpAddress =
269 'http://${serverAddress.authority}${serverAddress.path}'; 286 'http://${serverAddress.authority}${serverAddress.path}';
270 } 287 }
271 288
272 class _ServiceTesterRunner { 289 class _ServiceTesterRunner {
273 void run({List<String> mainArgs, 290 void run({List<String> mainArgs,
274 List<String> extraArgs,
275 List<VMTest> vmTests, 291 List<VMTest> vmTests,
276 List<IsolateTest> isolateTests, 292 List<IsolateTest> isolateTests,
277 bool pause_on_start: false, 293 bool pause_on_start: false,
278 bool pause_on_exit: false, 294 bool pause_on_exit: false,
295 bool trace_service: false,
296 bool trace_compiler: false,
279 bool verbose_vm: false, 297 bool verbose_vm: false,
280 bool pause_on_unhandled_exceptions: false, 298 bool pause_on_unhandled_exceptions: false,
281 bool testeeControlsServer: false, 299 bool testeeControlsServer: false,
282 bool useAuthToken: false}) { 300 bool useAuthToken: false}) {
283 var process = new _ServiceTesteeLauncher(); 301 var process = new _ServiceTesteeLauncher();
284 process.launch(pause_on_start, pause_on_exit, 302 process.launch(pause_on_start, pause_on_exit,
285 pause_on_unhandled_exceptions, 303 pause_on_unhandled_exceptions,
304 trace_service, trace_compiler,
286 testeeControlsServer, 305 testeeControlsServer,
287 useAuthToken, extraArgs).then((Uri serverAddress) async { 306 useAuthToken).then((Uri serverAddress) async {
288 if (mainArgs.contains("--gdb")) { 307 if (mainArgs.contains("--gdb")) {
289 var pid = process.process.pid; 308 var pid = process.process.pid;
290 var wait = new Duration(seconds: 10); 309 var wait = new Duration(seconds: 10);
291 print("Testee has pid $pid, waiting $wait before continuing"); 310 print("Testee has pid $pid, waiting $wait before continuing");
292 sleep(wait); 311 sleep(wait);
293 } 312 }
294 setupAddresses(serverAddress); 313 setupAddresses(serverAddress);
295 var name = Platform.script.pathSegments.last; 314 var name = Platform.script.pathSegments.last;
296 Chain.capture(() async { 315 Chain.capture(() async {
297 var vm = 316 var vm =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 /// Runs [tests] in sequence, each of which should take an [Isolate] and 357 /// Runs [tests] in sequence, each of which should take an [Isolate] and
339 /// return a [Future]. Code for setting up state can run before and/or 358 /// return a [Future]. Code for setting up state can run before and/or
340 /// concurrently with the tests. Uses [mainArgs] to determine whether 359 /// concurrently with the tests. Uses [mainArgs] to determine whether
341 /// to run tests or testee in this invokation of the script. 360 /// to run tests or testee in this invokation of the script.
342 Future runIsolateTests(List<String> mainArgs, 361 Future runIsolateTests(List<String> mainArgs,
343 List<IsolateTest> tests, 362 List<IsolateTest> tests,
344 {testeeBefore(), 363 {testeeBefore(),
345 testeeConcurrent(), 364 testeeConcurrent(),
346 bool pause_on_start: false, 365 bool pause_on_start: false,
347 bool pause_on_exit: false, 366 bool pause_on_exit: false,
367 bool trace_service: false,
368 bool trace_compiler: false,
348 bool verbose_vm: false, 369 bool verbose_vm: false,
349 bool pause_on_unhandled_exceptions: false, 370 bool pause_on_unhandled_exceptions: false,
350 bool testeeControlsServer: false, 371 bool testeeControlsServer: false,
351 bool useAuthToken: false, 372 bool useAuthToken: false}) async {
352 List<String> extraArgs}) async {
353 assert(!pause_on_start || testeeBefore == null); 373 assert(!pause_on_start || testeeBefore == null);
354 if (_isTestee()) { 374 if (_isTestee()) {
355 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore, 375 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore,
356 testeeConcurrent: testeeConcurrent, 376 testeeConcurrent: testeeConcurrent,
357 pause_on_start: pause_on_start, 377 pause_on_start: pause_on_start,
358 pause_on_exit: pause_on_exit); 378 pause_on_exit: pause_on_exit);
359 } else { 379 } else {
360 new _ServiceTesterRunner().run( 380 new _ServiceTesterRunner().run(
361 mainArgs: mainArgs, 381 mainArgs: mainArgs,
362 extraArgs: extraArgs,
363 isolateTests: tests, 382 isolateTests: tests,
364 pause_on_start: pause_on_start, 383 pause_on_start: pause_on_start,
365 pause_on_exit: pause_on_exit, 384 pause_on_exit: pause_on_exit,
385 trace_service: trace_service,
386 trace_compiler: trace_compiler,
366 verbose_vm: verbose_vm, 387 verbose_vm: verbose_vm,
367 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions, 388 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions,
368 testeeControlsServer: testeeControlsServer, 389 testeeControlsServer: testeeControlsServer,
369 useAuthToken: useAuthToken); 390 useAuthToken: useAuthToken);
370 } 391 }
371 } 392 }
372 393
373 /// Runs [tests] in sequence, each of which should take an [Isolate] and 394 /// Runs [tests] in sequence, each of which should take an [Isolate] and
374 /// return a [Future]. Code for setting up state can run before and/or 395 /// return a [Future]. Code for setting up state can run before and/or
375 /// concurrently with the tests. Uses [mainArgs] to determine whether 396 /// concurrently with the tests. Uses [mainArgs] to determine whether
376 /// to run tests or testee in this invokation of the script. 397 /// to run tests or testee in this invokation of the script.
377 /// 398 ///
378 /// This is a special version of this test harness specifically for the 399 /// This is a special version of this test harness specifically for the
379 /// pause_on_unhandled_exceptions_test, which cannot properly function 400 /// pause_on_unhandled_exceptions_test, which cannot properly function
380 /// in an async context (because exceptions are *always* handled in async 401 /// in an async context (because exceptions are *always* handled in async
381 /// functions). 402 /// functions).
382 void runIsolateTestsSynchronous(List<String> mainArgs, 403 void runIsolateTestsSynchronous(List<String> mainArgs,
383 List<IsolateTest> tests, 404 List<IsolateTest> tests,
384 {void testeeBefore(), 405 {void testeeBefore(),
385 void testeeConcurrent(), 406 void testeeConcurrent(),
386 bool pause_on_start: false, 407 bool pause_on_start: false,
387 bool pause_on_exit: false, 408 bool pause_on_exit: false,
409 bool trace_service: false,
410 bool trace_compiler: false,
388 bool verbose_vm: false, 411 bool verbose_vm: false,
389 bool pause_on_unhandled_exceptions: false, 412 bool pause_on_unhandled_exceptions: false}) {
390 List<String> extraArgs}) {
391 assert(!pause_on_start || testeeBefore == null); 413 assert(!pause_on_start || testeeBefore == null);
392 if (_isTestee()) { 414 if (_isTestee()) {
393 new _ServiceTesteeRunner().runSync(testeeBeforeSync: testeeBefore, 415 new _ServiceTesteeRunner().runSync(testeeBeforeSync: testeeBefore,
394 testeeConcurrentSync: testeeConcurrent, 416 testeeConcurrentSync: testeeConcurrent,
395 pause_on_start: pause_on_start, 417 pause_on_start: pause_on_start,
396 pause_on_exit: pause_on_exit); 418 pause_on_exit: pause_on_exit);
397 } else { 419 } else {
398 new _ServiceTesterRunner().run( 420 new _ServiceTesterRunner().run(
399 mainArgs: mainArgs, 421 mainArgs: mainArgs,
400 extraArgs: extraArgs,
401 isolateTests: tests, 422 isolateTests: tests,
402 pause_on_start: pause_on_start, 423 pause_on_start: pause_on_start,
403 pause_on_exit: pause_on_exit, 424 pause_on_exit: pause_on_exit,
425 trace_service: trace_service,
426 trace_compiler: trace_compiler,
404 verbose_vm: verbose_vm, 427 verbose_vm: verbose_vm,
405 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); 428 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions);
406 } 429 }
407 } 430 }
408 431
409 432
410 /// Runs [tests] in sequence, each of which should take an [Isolate] and 433 /// Runs [tests] in sequence, each of which should take an [Isolate] and
411 /// return a [Future]. Code for setting up state can run before and/or 434 /// return a [Future]. Code for setting up state can run before and/or
412 /// concurrently with the tests. Uses [mainArgs] to determine whether 435 /// concurrently with the tests. Uses [mainArgs] to determine whether
413 /// to run tests or testee in this invokation of the script. 436 /// to run tests or testee in this invokation of the script.
414 Future runVMTests(List<String> mainArgs, 437 Future runVMTests(List<String> mainArgs,
415 List<VMTest> tests, 438 List<VMTest> tests,
416 {testeeBefore(), 439 {testeeBefore(),
417 testeeConcurrent(), 440 testeeConcurrent(),
418 bool pause_on_start: false, 441 bool pause_on_start: false,
419 bool pause_on_exit: false, 442 bool pause_on_exit: false,
443 bool trace_service: false,
444 bool trace_compiler: false,
420 bool verbose_vm: false, 445 bool verbose_vm: false,
421 bool pause_on_unhandled_exceptions: false, 446 bool pause_on_unhandled_exceptions: false}) async {
422 List<String> extraArgs}) async {
423 if (_isTestee()) { 447 if (_isTestee()) {
424 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore, 448 new _ServiceTesteeRunner().run(testeeBefore: testeeBefore,
425 testeeConcurrent: testeeConcurrent, 449 testeeConcurrent: testeeConcurrent,
426 pause_on_start: pause_on_start, 450 pause_on_start: pause_on_start,
427 pause_on_exit: pause_on_exit); 451 pause_on_exit: pause_on_exit);
428 } else { 452 } else {
429 new _ServiceTesterRunner().run( 453 new _ServiceTesterRunner().run(
430 mainArgs: mainArgs, 454 mainArgs: mainArgs,
431 extraArgs: extraArgs,
432 vmTests: tests, 455 vmTests: tests,
433 pause_on_start: pause_on_start, 456 pause_on_start: pause_on_start,
434 pause_on_exit: pause_on_exit, 457 pause_on_exit: pause_on_exit,
458 trace_service: trace_service,
459 trace_compiler: trace_compiler,
435 verbose_vm: verbose_vm, 460 verbose_vm: verbose_vm,
436 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions); 461 pause_on_unhandled_exceptions: pause_on_unhandled_exceptions);
437 } 462 }
438 } 463 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/step_over_await_test.dart ('k') | runtime/vm/code_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698