OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // OtherResources=regress_7191_script.dart | 5 // OtherResources=regress_7191_script.dart |
6 | 6 |
7 // Regression test for http://dartbug.com/7191. | 7 // Regression test for http://dartbug.com/7191. |
8 | 8 |
9 // Starts a sub-process which in turn starts another sub-process and then closes | 9 // Starts a sub-process which in turn starts another sub-process and then closes |
10 // its standard output. If handles are incorrectly inherited on Windows, this | 10 // its standard output. If handles are incorrectly inherited on Windows, this |
11 // will lead to a situation where the stdout of the first sub-process is never | 11 // will lead to a situation where the stdout of the first sub-process is never |
12 // closed which will make this test hang. | 12 // closed which will make this test hang. |
13 | 13 |
14 import 'dart:io'; | 14 import 'dart:io'; |
15 | 15 |
16 import "package:async_helper/async_helper.dart"; | 16 import "package:async_helper/async_helper.dart"; |
17 import "package:expect/expect.dart"; | 17 import "package:expect/expect.dart"; |
18 import 'package:path/path.dart'; | 18 import 'package:path/path.dart'; |
19 | 19 |
20 main() { | 20 main() { |
21 asyncStart(); | 21 asyncStart(); |
22 var executable = Platform.executable; | 22 var executable = Platform.executable; |
23 var script = Platform.script.resolve('regress_7191_script.dart').toFilePath(); | 23 var script = Platform.script.resolve('regress_7191_script.dart').toFilePath(); |
24 Process.start(executable, [script]).then((process) { | 24 Process.start(executable, [script]).then((process) { |
25 process.stdin.add([0]); | 25 process.stdin.add([0]); |
26 process.stdout.listen((_) { }, | 26 process.stdout.listen((_) {}, onDone: () { |
27 onDone: () { process.stdin.add([0]); }); | 27 process.stdin.add([0]); |
28 process.stderr.listen((_) { }); | 28 }); |
| 29 process.stderr.listen((_) {}); |
29 process.exitCode.then((exitCode) { | 30 process.exitCode.then((exitCode) { |
30 asyncEnd(); | 31 asyncEnd(); |
31 if (exitCode != 0) throw "Bad exit code"; | 32 if (exitCode != 0) throw "Bad exit code"; |
32 }); | 33 }); |
33 }); | 34 }); |
34 } | 35 } |
OLD | NEW |