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 unittest.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 |
11 import 'package:path/path.dart' as p; | 11 import 'package:path/path.dart' as p; |
12 import 'package:pool/pool.dart'; | 12 import 'package:pool/pool.dart'; |
13 | 13 |
14 import '../../util/io.dart'; | 14 import '../../util/io.dart'; |
15 import '../load_exception.dart'; | 15 import '../load_exception.dart'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 /// [packageRoot] is provided, it's used as the package root for the | 51 /// [packageRoot] is provided, it's used as the package root for the |
52 /// compilation. | 52 /// compilation. |
53 /// | 53 /// |
54 /// The returned [Future] will complete once the `dart2js` process completes | 54 /// The returned [Future] will complete once the `dart2js` process completes |
55 /// *and* all its output has been printed to the command line. | 55 /// *and* all its output has been printed to the command line. |
56 Future compile(String dartPath, String jsPath, {String packageRoot}) { | 56 Future compile(String dartPath, String jsPath, {String packageRoot}) { |
57 return _pool.withResource(() { | 57 return _pool.withResource(() { |
58 return withTempDir((dir) { | 58 return withTempDir((dir) { |
59 var wrapperPath = p.join(dir, "runInBrowser.dart"); | 59 var wrapperPath = p.join(dir, "runInBrowser.dart"); |
60 new File(wrapperPath).writeAsStringSync(''' | 60 new File(wrapperPath).writeAsStringSync(''' |
61 import "package:unittest/src/runner/browser/iframe_listener.dart"; | 61 import "package:test/src/runner/browser/iframe_listener.dart"; |
62 | 62 |
63 import "${p.toUri(p.absolute(dartPath))}" as test; | 63 import "${p.toUri(p.absolute(dartPath))}" as test; |
64 | 64 |
65 void main(_) { | 65 void main(_) { |
66 IframeListener.start(() => test.main); | 66 IframeListener.start(() => test.main); |
67 } | 67 } |
68 '''); | 68 '''); |
69 | 69 |
70 var dart2jsPath = p.join(sdkDir, 'bin', 'dart2js'); | 70 var dart2jsPath = p.join(sdkDir, 'bin', 'dart2js'); |
71 if (Platform.isWindows) dart2jsPath += '.bat'; | 71 if (Platform.isWindows) dart2jsPath += '.bat'; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /// The underlying process. | 129 /// The underlying process. |
130 final Process process; | 130 final Process process; |
131 | 131 |
132 /// A future that will complete once this instance has finished running and | 132 /// A future that will complete once this instance has finished running and |
133 /// all its output has been printed. | 133 /// all its output has been printed. |
134 Future get onDone => onDoneCompleter.future; | 134 Future get onDone => onDoneCompleter.future; |
135 final onDoneCompleter = new Completer(); | 135 final onDoneCompleter = new Completer(); |
136 | 136 |
137 _Compiler(this.path, this.process); | 137 _Compiler(this.path, this.process); |
138 } | 138 } |
OLD | NEW |