OLD | NEW |
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_test.scheduled_process; | 5 library scheduled_test.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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 "'$description'"); | 181 "'$description'"); |
182 }); | 182 }); |
183 } | 183 } |
184 | 184 |
185 /// Converts a stream of bytes to a stream of lines and returns that along | 185 /// Converts a stream of bytes to a stream of lines and returns that along |
186 /// with a [StreamCanceller] controlling it. | 186 /// with a [StreamCanceller] controlling it. |
187 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( | 187 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( |
188 Future<Stream<List<int>>> streamFuture) { | 188 Future<Stream<List<int>>> streamFuture) { |
189 return streamWithCanceller(futureStream(streamFuture) | 189 return streamWithCanceller(futureStream(streamFuture) |
190 .handleError((e) => currentSchedule.signalError(e)) | 190 .handleError((e) => currentSchedule.signalError(e)) |
| 191 .map((chunk) { |
| 192 // Whenever the process produces any sort of output, reset the schedule's |
| 193 // timer. |
| 194 currentSchedule.heartbeat(); |
| 195 return chunk; |
| 196 }) |
191 .transform(new StringDecoder(_encoding)) | 197 .transform(new StringDecoder(_encoding)) |
192 .transform(new LineTransformer())); | 198 .transform(new LineTransformer())); |
193 } | 199 } |
194 | 200 |
195 /// Schedule an exception handler that will clean up the process and provide | 201 /// Schedule an exception handler that will clean up the process and provide |
196 /// debug information if an error occurs. | 202 /// debug information if an error occurs. |
197 void _scheduleExceptionCleanup() { | 203 void _scheduleExceptionCleanup() { |
198 currentSchedule.onException.schedule(() { | 204 currentSchedule.onException.schedule(() { |
199 _stdoutCanceller(); | 205 _stdoutCanceller(); |
200 _stderrCanceller(); | 206 _stderrCanceller(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 schedule(() { | 336 schedule(() { |
331 _endExpected = true; | 337 _endExpected = true; |
332 return _exitCode.then((exitCode) { | 338 return _exitCode.then((exitCode) { |
333 if (expectedExitCode != null) { | 339 if (expectedExitCode != null) { |
334 expect(exitCode, equals(expectedExitCode)); | 340 expect(exitCode, equals(expectedExitCode)); |
335 } | 341 } |
336 }); | 342 }); |
337 }, "waiting for process '$description' to exit"); | 343 }, "waiting for process '$description' to exit"); |
338 } | 344 } |
339 } | 345 } |
OLD | NEW |