| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.util.compiler_pool; | 5 library test.util.compiler_pool; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 /// This prints all [compiler]'s standard output and error. | 104 /// This prints all [compiler]'s standard output and error. |
| 105 void _showProcess(_Compiler compiler) { | 105 void _showProcess(_Compiler compiler) { |
| 106 print("Compiling ${compiler.path}..."); | 106 print("Compiling ${compiler.path}..."); |
| 107 | 107 |
| 108 invoke(() async { | 108 invoke(() async { |
| 109 try { | 109 try { |
| 110 // We wait for stdout and stderr to close and for exitCode to fire to | 110 // We wait for stdout and stderr to close and for exitCode to fire to |
| 111 // ensure that we're done printing everything about one process before | 111 // ensure that we're done printing everything about one process before |
| 112 // we start the next. | 112 // we start the next. |
| 113 await Future.wait([ | 113 await Future.wait([ |
| 114 santizeForWindows(compiler.process.stdout).listen(stdout.add) | 114 sanitizeForWindows(compiler.process.stdout).listen(stdout.add) |
| 115 .asFuture(), | 115 .asFuture(), |
| 116 santizeForWindows(compiler.process.stderr).listen(stderr.add) | 116 sanitizeForWindows(compiler.process.stderr).listen(stderr.add) |
| 117 .asFuture(), | 117 .asFuture(), |
| 118 compiler.process.exitCode.then((exitCode) { | 118 compiler.process.exitCode.then((exitCode) { |
| 119 if (exitCode == 0 || _closed) return; | 119 if (exitCode == 0 || _closed) return; |
| 120 throw new LoadException(compiler.path, "dart2js failed."); | 120 throw new LoadException(compiler.path, "dart2js failed."); |
| 121 }) | 121 }) |
| 122 ]); | 122 ]); |
| 123 | 123 |
| 124 if (_closed) return; | 124 if (_closed) return; |
| 125 compiler.onDoneCompleter.complete(); | 125 compiler.onDoneCompleter.complete(); |
| 126 } catch (error, stackTrace) { | 126 } catch (error, stackTrace) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 /// The underlying process. | 165 /// The underlying process. |
| 166 final Process process; | 166 final Process process; |
| 167 | 167 |
| 168 /// A future that will complete once this instance has finished running and | 168 /// A future that will complete once this instance has finished running and |
| 169 /// all its output has been printed. | 169 /// all its output has been printed. |
| 170 Future get onDone => onDoneCompleter.future; | 170 Future get onDone => onDoneCompleter.future; |
| 171 final onDoneCompleter = new Completer(); | 171 final onDoneCompleter = new Completer(); |
| 172 | 172 |
| 173 _Compiler(this.path, this.process); | 173 _Compiler(this.path, this.process); |
| 174 } | 174 } |
| OLD | NEW |