OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // | |
5 // Process test program to test detached processes. | |
6 // | |
7 // VMOptions= | |
8 // VMOptions=--short_socket_read | |
9 // VMOptions=--short_socket_write | |
10 // VMOptions=--short_socket_read --short_socket_write | |
kustermann
2015/01/16 16:11:04
Since we don't do any I/O here, I don't think we n
Søren Gjesse
2015/01/21 12:32:35
Good point. Removed.
| |
11 | |
12 import 'dart:async'; | |
13 import 'dart:io'; | |
14 | |
15 import "package:async_helper/async_helper.dart"; | |
16 import "package:expect/expect.dart"; | |
17 | |
18 import "process_test_util.dart"; | |
19 | |
20 void test() { | |
21 asyncStart(); | |
22 var script = | |
23 Platform.script.resolve('process_detached_script.dart').toFilePath(); | |
24 var future = Process.start(Platform.executable, [script], detached: true); | |
25 future.then((process) { | |
26 print(process.pid); | |
Lasse Reichstein Nielsen
2015/01/15 09:55:40
Expect.isNotNull(process.pid);
?
Søren Gjesse
2015/01/21 12:32:35
Done added
Expect.isTrue(process.pid is int);
as
| |
27 Expect.isNull(process.exitCode); | |
28 Expect.isNull(process.stderr); | |
29 Expect.isNull(process.stdin); | |
30 Expect.isNull(process.stdout); | |
31 Expect.isTrue(process.kill()); | |
32 }).whenComplete(() { | |
33 asyncEnd(); | |
34 }); | |
35 } | |
36 | |
37 void testFailure() { | |
38 asyncStart(); | |
39 Directory.systemTemp.createTemp('dart_detached_process').then((temp) { | |
40 var future = Process.start(temp.path, ['a', 'b'], detached: true); | |
41 future.then((process) { | |
42 Expect.fail('Starting process from invalid executable succeeded'); | |
43 }).catchError((e) { | |
44 Expect.isTrue(e is ProcessException); | |
Lasse Reichstein Nielsen
2015/01/15 09:55:40
Won't this catch the expect.fail from above (but t
Søren Gjesse
2015/01/21 12:32:35
Good catch, thanks!
| |
45 }).whenComplete(() { | |
46 temp.deleteSync(); | |
47 asyncEnd(); | |
48 }); | |
49 }); | |
50 } | |
51 | |
52 main() { | |
53 test(); | |
54 testFailure(); | |
55 } | |
OLD | NEW |