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

Side by Side Diff: pkg/scheduled_test/lib/scheduled_process.dart

Issue 12637020: Display metadata about out-of-band callbacks in scheduled test errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: mege Created 7 years, 9 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 | Annotate | Revision Log
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 scheduled_process; 5 library scheduled_process;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'scheduled_test.dart'; 10 import 'scheduled_test.dart';
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // to complete and pump the event queue so that _endExpected will be 165 // to complete and pump the event queue so that _endExpected will be
166 // set. 166 // set.
167 return _taskBeforeEnd.result.then((_) => pumpEventQueue()); 167 return _taskBeforeEnd.result.then((_) => pumpEventQueue());
168 }).then((_) { 168 }).then((_) {
169 exitCodeCompleter.complete(exitCode); 169 exitCodeCompleter.complete(exitCode);
170 170
171 if (!_endExpected) { 171 if (!_endExpected) {
172 throw "Process '${this.description}' ended earlier than scheduled " 172 throw "Process '${this.description}' ended earlier than scheduled "
173 "with exit code $exitCode."; 173 "with exit code $exitCode.";
174 } 174 }
175 })); 175 }), "waiting to reach shouldExit() or kill() for process "
176 "'${this.description}'");
Bob Nystrom 2013/03/12 20:08:51 Is "this." still needed here (and above)?
nweiz 2013/03/12 20:56:51 Nope. Done.
176 }); 177 });
177 } 178 }
178 179
179 /// Converts a stream of bytes to a stream of lines and returns that along 180 /// Converts a stream of bytes to a stream of lines and returns that along
180 /// with a [StreamCanceller] controlling it. 181 /// with a [StreamCanceller] controlling it.
181 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( 182 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller(
182 Future<Stream<int>> streamFuture) { 183 Future<Stream<int>> streamFuture) {
183 return streamWithCanceller(futureStream(streamFuture) 184 return streamWithCanceller(futureStream(streamFuture)
184 .handleError((e) => currentSchedule.signalError(e)) 185 .handleError((e) => currentSchedule.signalError(e))
185 .transform(new StringDecoder(_encoding)) 186 .transform(new StringDecoder(_encoding))
186 .transform(new LineTransformer())); 187 .transform(new LineTransformer()));
187 } 188 }
188 189
189 /// Schedule an exception handler that will clean up the process and provide 190 /// Schedule an exception handler that will clean up the process and provide
190 /// debug information if an error occurs. 191 /// debug information if an error occurs.
191 void _scheduleExceptionCleanup() { 192 void _scheduleExceptionCleanup() {
192 currentSchedule.onException.schedule(() { 193 currentSchedule.onException.schedule(() {
193 _stdoutCanceller(); 194 _stdoutCanceller();
194 _stderrCanceller(); 195 _stderrCanceller();
195 196
196 if (!_process.hasValue) return; 197 if (!_process.hasValue) return;
197 198
198 var killedPrematurely = false; 199 var killedPrematurely = false;
199 if (!_exitCode.hasValue) { 200 if (!_exitCode.hasValue) {
200 killedPrematurely = true; 201 killedPrematurely = true;
201 _endExpected = true; 202 _endExpected = true;
202 _process.value.kill(); 203 _process.value.kill();
203 // Ensure that the onException queue waits for the process to actually 204 // Ensure that the onException queue waits for the process to actually
204 // exit after being killed. 205 // exit after being killed.
205 wrapFuture(_process.value.exitCode); 206 wrapFuture(_process.value.exitCode, "waiting for process "
207 "'${this.description}' to die");
Bob Nystrom 2013/03/12 20:08:51 Ditto.
nweiz 2013/03/12 20:56:51 Done.
206 } 208 }
207 209
208 return Future.wait([ 210 return Future.wait([
209 _stdoutLog.toList(), 211 _stdoutLog.toList(),
210 _stderrLog.toList() 212 _stderrLog.toList()
211 ]).then((results) { 213 ]).then((results) {
212 var stdout = results[0].join("\n"); 214 var stdout = results[0].join("\n");
213 var stderr = results[1].join("\n"); 215 var stderr = results[1].join("\n");
214 216
215 var exitDescription = killedPrematurely 217 var exitDescription = killedPrematurely
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 schedule(() { 299 schedule(() {
298 _endExpected = true; 300 _endExpected = true;
299 return _exitCode.then((exitCode) { 301 return _exitCode.then((exitCode) {
300 if (expectedExitCode != null) { 302 if (expectedExitCode != null) {
301 expect(exitCode, equals(expectedExitCode)); 303 expect(exitCode, equals(expectedExitCode));
302 } 304 }
303 }); 305 });
304 }, "waiting for process '$description' to exit"); 306 }, "waiting for process '$description' to exit");
305 } 307 }
306 } 308 }
OLDNEW
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/scheduled_test.dart » ('j') | pkg/scheduled_test/lib/src/schedule.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698