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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:async/async.dart'; | 9 import 'package:async/async.dart'; |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
11 import 'package:pool/pool.dart'; | 11 import 'package:pool/pool.dart'; |
12 | 12 |
13 import '../../util/io.dart'; | 13 import '../../util/io.dart'; |
14 import '../configuration.dart'; | 14 import '../configuration.dart'; |
15 import '../load_exception.dart'; | 15 import '../load_exception.dart'; |
16 | 16 |
| 17 /// A regular expression matching the first status line printed by dart2js. |
| 18 final _dart2jsStatus = |
| 19 new RegExp(r"^Dart file \(.*\) compiled to JavaScript: .*\n?"); |
| 20 |
17 /// A pool of `dart2js` instances. | 21 /// A pool of `dart2js` instances. |
18 /// | 22 /// |
19 /// This limits the number of compiler instances running concurrently. | 23 /// This limits the number of compiler instances running concurrently. |
20 class CompilerPool { | 24 class CompilerPool { |
21 /// The internal pool that controls the number of process running at once. | 25 /// The internal pool that controls the number of process running at once. |
22 final Pool _pool; | 26 final Pool _pool; |
23 | 27 |
24 /// The test runner configuration. | 28 /// The test runner configuration. |
25 final Configuration _config; | 29 final Configuration _config; |
26 | 30 |
(...skipping 68 matching lines...) Loading... |
95 | 99 |
96 await Future.wait([ | 100 await Future.wait([ |
97 _printOutputStream(process.stdout, buffer), | 101 _printOutputStream(process.stdout, buffer), |
98 _printOutputStream(process.stderr, buffer), | 102 _printOutputStream(process.stderr, buffer), |
99 ]); | 103 ]); |
100 | 104 |
101 var exitCode = await process.exitCode; | 105 var exitCode = await process.exitCode; |
102 _processes.remove(process); | 106 _processes.remove(process); |
103 if (_closed) return; | 107 if (_closed) return; |
104 | 108 |
105 if (buffer.isNotEmpty) print(buffer); | 109 var output = buffer.toString().replaceFirst(_dart2jsStatus, ''); |
| 110 if (output.isNotEmpty) print(output); |
106 | 111 |
107 if (exitCode != 0) throw new LoadException(dartPath, "dart2js failed."); | 112 if (exitCode != 0) throw new LoadException(dartPath, "dart2js failed."); |
108 | 113 |
109 _fixSourceMap(jsPath + '.map'); | 114 _fixSourceMap(jsPath + '.map'); |
110 }); | 115 }); |
111 }); | 116 }); |
112 } | 117 } |
113 | 118 |
114 // TODO(nweiz): Remove this when sdk#17544 is fixed. | 119 // TODO(nweiz): Remove this when sdk#17544 is fixed. |
115 /// Fix up the source map at [mapPath] so that it points to absolute file: | 120 /// Fix up the source map at [mapPath] so that it points to absolute file: |
(...skipping 26 matching lines...) Loading... |
142 /// have been killed and all resources released. | 147 /// have been killed and all resources released. |
143 Future close() { | 148 Future close() { |
144 return _closeMemo.runOnce(() async { | 149 return _closeMemo.runOnce(() async { |
145 await Future.wait(_processes.map((process) async { | 150 await Future.wait(_processes.map((process) async { |
146 process.kill(); | 151 process.kill(); |
147 await process.exitCode; | 152 await process.exitCode; |
148 })); | 153 })); |
149 }); | 154 }); |
150 } | 155 } |
151 } | 156 } |
OLD | NEW |