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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 /// Mark [compiler] as the visible instance. | 101 /// Mark [compiler] as the visible instance. |
102 /// | 102 /// |
103 /// This prints all [compiler]'s standard output and error. | 103 /// This prints all [compiler]'s standard output and error. |
104 void _showProcess(_Compiler compiler) { | 104 void _showProcess(_Compiler compiler) { |
105 print("Compiling ${compiler.path}..."); | 105 print("Compiling ${compiler.path}..."); |
106 | 106 |
107 // We wait for stdout and stderr to close and for exitCode to fire to ensure | 107 // We wait for stdout and stderr to close and for exitCode to fire to ensure |
108 // that we're done printing everything about one process before we start the | 108 // that we're done printing everything about one process before we start the |
109 // next. | 109 // next. |
110 Future.wait([ | 110 Future.wait([ |
111 compiler.process.stdout.listen(stdout.add).asFuture(), | 111 santizeForWindows(compiler.process.stdout).listen(stdout.add).asFuture(), |
112 compiler.process.stderr.listen(stderr.add).asFuture(), | 112 santizeForWindows(compiler.process.stderr).listen(stderr.add).asFuture(), |
113 compiler.process.exitCode.then((exitCode) { | 113 compiler.process.exitCode.then((exitCode) { |
114 if (exitCode == 0 || _closed) return; | 114 if (exitCode == 0 || _closed) return; |
115 throw new LoadException(compiler.path, "dart2js failed."); | 115 throw new LoadException(compiler.path, "dart2js failed."); |
116 }) | 116 }) |
117 ]).then((_) { | 117 ]).then((_) { |
118 if (_closed) return; | 118 if (_closed) return; |
119 compiler.onDoneCompleter.complete(); | 119 compiler.onDoneCompleter.complete(); |
120 }).catchError((error, stackTrace) { | 120 }).catchError((error, stackTrace) { |
121 if (_closed) return; | 121 if (_closed) return; |
122 compiler.onDoneCompleter.completeError(error, stackTrace); | 122 compiler.onDoneCompleter.completeError(error, stackTrace); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 /// The underlying process. | 161 /// The underlying process. |
162 final Process process; | 162 final Process process; |
163 | 163 |
164 /// A future that will complete once this instance has finished running and | 164 /// A future that will complete once this instance has finished running and |
165 /// all its output has been printed. | 165 /// all its output has been printed. |
166 Future get onDone => onDoneCompleter.future; | 166 Future get onDone => onDoneCompleter.future; |
167 final onDoneCompleter = new Completer(); | 167 final onDoneCompleter = new Completer(); |
168 | 168 |
169 _Compiler(this.path, this.process); | 169 _Compiler(this.path, this.process); |
170 } | 170 } |
OLD | NEW |