| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 wrapFuture(pumpEventQueue().then((_) { | 176 wrapFuture(pumpEventQueue().then((_) { |
| 177 if (currentSchedule.currentTask != _taskBeforeEnd) return; | 177 if (currentSchedule.currentTask != _taskBeforeEnd) return; |
| 178 // If we're one task before the end was scheduled, wait for that task | 178 // If we're one task before the end was scheduled, wait for that task |
| 179 // to complete and pump the event queue so that _endExpected will be | 179 // to complete and pump the event queue so that _endExpected will be |
| 180 // set. | 180 // set. |
| 181 return _taskBeforeEnd.result.then((_) => pumpEventQueue()); | 181 return _taskBeforeEnd.result.then((_) => pumpEventQueue()); |
| 182 }).then((_) { | 182 }).then((_) { |
| 183 exitCodeCompleter.complete(exitCode); | 183 exitCodeCompleter.complete(exitCode); |
| 184 | 184 |
| 185 if (!_endExpected) { | 185 if (!_endExpected) { |
| 186 throw "Process '$description' ended earlier than scheduled " | 186 fail("Process '$description' ended earlier than scheduled " |
| 187 "with exit code $exitCode."; | 187 "with exit code $exitCode."); |
| 188 } | 188 } |
| 189 }), "waiting to reach shouldExit() or kill() for process " | 189 }), "waiting to reach shouldExit() or kill() for process " |
| 190 "'$description'"); | 190 "'$description'"); |
| 191 }); | 191 }); |
| 192 } | 192 } |
| 193 | 193 |
| 194 /// Converts a stream of bytes to a stream of lines and returns that along | 194 /// Converts a stream of bytes to a stream of lines and returns that along |
| 195 /// with a [StreamCanceller] controlling it. | 195 /// with a [StreamCanceller] controlling it. |
| 196 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( | 196 Pair<Stream<String>, StreamCanceller> _lineStreamWithCanceller( |
| 197 Future<Stream<List<int>>> streamFuture) { | 197 Future<Stream<List<int>>> streamFuture) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 schedule(() { | 344 schedule(() { |
| 345 _endExpected = true; | 345 _endExpected = true; |
| 346 return _exitCode.then((exitCode) { | 346 return _exitCode.then((exitCode) { |
| 347 if (expectedExitCode != null) { | 347 if (expectedExitCode != null) { |
| 348 expect(exitCode, equals(expectedExitCode)); | 348 expect(exitCode, equals(expectedExitCode)); |
| 349 } | 349 } |
| 350 }); | 350 }); |
| 351 }, "waiting for process '$description' to exit"); | 351 }, "waiting for process '$description' to exit"); |
| 352 } | 352 } |
| 353 } | 353 } |
| OLD | NEW |