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; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 /// | 50 /// |
51 /// The returned [Future] will complete once the `dart2js` process completes | 51 /// The returned [Future] will complete once the `dart2js` process completes |
52 /// *and* all its output has been printed to the command line. | 52 /// *and* all its output has been printed to the command line. |
53 Future compile(String dartPath, String jsPath, {String packageRoot}) { | 53 Future compile(String dartPath, String jsPath, {String packageRoot}) { |
54 return _pool.withResource(() { | 54 return _pool.withResource(() { |
55 if (_closed) return null; | 55 if (_closed) return null; |
56 | 56 |
57 return withTempDir((dir) async { | 57 return withTempDir((dir) async { |
58 var wrapperPath = p.join(dir, "runInBrowser.dart"); | 58 var wrapperPath = p.join(dir, "runInBrowser.dart"); |
59 new File(wrapperPath).writeAsStringSync(''' | 59 new File(wrapperPath).writeAsStringSync(''' |
60 import "package:test/src/runner/browser/iframe_listener.dart"; | 60 import "package:stream_channel/stream_channel.dart"; |
61 | 61 |
62 import "${p.toUri(p.absolute(dartPath))}" as test; | 62 import "package:test/src/runner/plugin/remote_platform_helpers.dart"; |
| 63 import "package:test/src/runner/browser/post_message_channel.dart"; |
63 | 64 |
64 void main(_) { | 65 import "${p.toUri(p.absolute(dartPath))}" as test; |
65 IframeListener.start(() => test.main); | 66 |
66 } | 67 main(_) async { |
67 '''); | 68 var channel = serializeSuite(() => test.main, hidePrints: false); |
| 69 postMessageChannel().pipe(channel); |
| 70 } |
| 71 '''); |
68 | 72 |
69 var dart2jsPath = p.join(sdkDir, 'bin', 'dart2js'); | 73 var dart2jsPath = p.join(sdkDir, 'bin', 'dart2js'); |
70 if (Platform.isWindows) dart2jsPath += '.bat'; | 74 if (Platform.isWindows) dart2jsPath += '.bat'; |
71 | 75 |
72 var args = ["--checked", wrapperPath, "--out=$jsPath"]; | 76 var args = ["--checked", wrapperPath, "--out=$jsPath"]; |
73 | 77 |
74 if (packageRoot != null) { | 78 if (packageRoot != null) { |
75 args.add("--package-root=${p.toUri(p.absolute(packageRoot))}"); | 79 args.add("--package-root=${p.toUri(p.absolute(packageRoot))}"); |
76 } | 80 } |
77 | 81 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 /// have been killed and all resources released. | 145 /// have been killed and all resources released. |
142 Future close() { | 146 Future close() { |
143 return _closeMemo.runOnce(() async { | 147 return _closeMemo.runOnce(() async { |
144 await Future.wait(_processes.map((process) async { | 148 await Future.wait(_processes.map((process) async { |
145 process.kill(); | 149 process.kill(); |
146 await process.exitCode; | 150 await process.exitCode; |
147 })); | 151 })); |
148 }); | 152 }); |
149 } | 153 } |
150 } | 154 } |
OLD | NEW |