| 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:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // We purposefully avoid using wrapFuture here. If an error occurs while a | 178 // We purposefully avoid using wrapFuture here. If an error occurs while a |
| 179 // process is running, we want the schedule to move to the onException | 179 // process is running, we want the schedule to move to the onException |
| 180 // queue where the process will be killed, rather than blocking the tasks | 180 // queue where the process will be killed, rather than blocking the tasks |
| 181 // queue waiting for the process to exit. | 181 // queue waiting for the process to exit. |
| 182 _process.then((p) => Chain.track(p.exitCode)).then((exitCode) { | 182 _process.then((p) => Chain.track(p.exitCode)).then((exitCode) { |
| 183 _actualExitTask = currentSchedule.currentTask; | 183 _actualExitTask = currentSchedule.currentTask; |
| 184 exitCodeCompleter.complete(exitCode); | 184 exitCodeCompleter.complete(exitCode); |
| 185 }); | 185 }); |
| 186 } | 186 } |
| 187 | 187 |
| 188 /// Converts a stream of bytes to a stream of lines and returns that along | 188 /// Converts a stream of byte lists to a stream of lines and returns that |
| 189 /// with a [StreamCanceller] controlling it. | 189 /// along with a [StreamCanceller] controlling it. |
| 190 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( | 190 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( |
| 191 Future<Stream<List<int>>> streamFuture) { | 191 Future<Stream<List<int>>> streamFuture) { |
| 192 return streamWithCanceller(futureStream(streamFuture) | 192 return streamWithCanceller(futureStream(streamFuture) |
| 193 .handleError(currentSchedule.signalError) | 193 .handleError(currentSchedule.signalError) |
| 194 .map((chunk) { | 194 .map((chunk) { |
| 195 // Whenever the process produces any sort of output, reset the schedule's | 195 // Whenever the process produces any sort of output, reset the schedule's |
| 196 // timer. | 196 // timer. |
| 197 currentSchedule.heartbeat(); | 197 currentSchedule.heartbeat(); |
| 198 return chunk; | 198 return chunk; |
| 199 }) | 199 }) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 schedule(() { | 316 schedule(() { |
| 317 return _exitCode.then((exitCode) { | 317 return _exitCode.then((exitCode) { |
| 318 if (expectedExitCode != null) { | 318 if (expectedExitCode != null) { |
| 319 expect(exitCode, equals(expectedExitCode)); | 319 expect(exitCode, equals(expectedExitCode)); |
| 320 } | 320 } |
| 321 }); | 321 }); |
| 322 }, "waiting for process '$description' to exit"); | 322 }, "waiting for process '$description' to exit"); |
| 323 _scheduledExitTask = currentSchedule.tasks.contents.last; | 323 _scheduledExitTask = currentSchedule.tasks.contents.last; |
| 324 } | 324 } |
| 325 } | 325 } |
| OLD | NEW |