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 // OtherResources=process_detached_script.dart | 5 // OtherResources=process_detached_script.dart |
6 | 6 |
7 // Process test program to test detached processes. | 7 // Process test program to test detached processes. |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 29 matching lines...) Expand all Loading... |
40 var future = Process.start( | 40 var future = Process.start( |
41 Platform.executable, | 41 Platform.executable, |
42 [script, 'echo'], | 42 [script, 'echo'], |
43 mode: ProcessStartMode.DETACHED_WITH_STDIO); | 43 mode: ProcessStartMode.DETACHED_WITH_STDIO); |
44 future.then((process) { | 44 future.then((process) { |
45 Expect.isNotNull(process.pid); | 45 Expect.isNotNull(process.pid); |
46 Expect.isTrue(process.pid is int); | 46 Expect.isTrue(process.pid is int); |
47 Expect.isNull(process.exitCode); | 47 Expect.isNull(process.exitCode); |
48 var message = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | 48 var message = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; |
49 process.stdin.add(message); | 49 process.stdin.add(message); |
50 process.stdin.close(); | 50 process.stdin.flush().then((_) => process.stdin.close()); |
51 var f1 = process.stdout.fold([], (p, e) => p..addAll(e)); | 51 var f1 = process.stdout.fold([], (p, e) => p..addAll(e)); |
52 var f2 = process.stderr.fold([], (p, e) => p..addAll(e)); | 52 var f2 = process.stderr.fold([], (p, e) => p..addAll(e)); |
53 Future.wait([f1, f2]) | 53 Future.wait([f1, f2]) |
54 .then((values) { | 54 .then((values) { |
55 Expect.listEquals(values[0], message); | 55 Expect.listEquals(values[0], message); |
56 Expect.listEquals(values[1], message); | 56 Expect.listEquals(values[1], message); |
57 }) | 57 }) |
58 .whenComplete(() { | 58 .whenComplete(() { |
59 Expect.isTrue(process.kill()); | 59 Expect.isTrue(process.kill()); |
60 }); | 60 }); |
(...skipping 16 matching lines...) Expand all Loading... |
77 asyncEnd(); | 77 asyncEnd(); |
78 }); | 78 }); |
79 }); | 79 }); |
80 } | 80 } |
81 | 81 |
82 main() { | 82 main() { |
83 test(); | 83 test(); |
84 testWithStdio(); | 84 testWithStdio(); |
85 testFailure(); | 85 testFailure(); |
86 } | 86 } |
OLD | NEW |