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 import 'dart:async'; | |
8 import 'dart:io'; | |
9 | |
10 import "package:async_helper/async_helper.dart"; | |
11 import "package:expect/expect.dart"; | |
12 | |
13 import "process_test_util.dart"; | |
14 | |
15 void test() { | |
16 asyncStart(); | |
17 var script = | |
18 Platform.script.resolve('process_detached_script.dart').toFilePath(); | |
19 var future = Process.start(Platform.executable, [script], detach: true); | |
20 future.then((process) { | |
21 print(process.pid); | |
22 Expect.isNotNull(process.pid); | |
23 Expect.isTrue(process.pid is int); | |
24 Expect.isNull(process.exitCode); | |
25 Expect.isNull(process.stderr); | |
26 Expect.isNull(process.stdin); | |
27 Expect.isNull(process.stdout); | |
28 Expect.isTrue(process.kill()); | |
29 }).whenComplete(() { | |
30 asyncEnd(); | |
31 }); | |
kustermann
2015/01/22 09:33:02
Regarding this test: Assuming we would actually no
Søren Gjesse
2015/01/22 11:47:25
Sounds like a good idea. I will think of something
| |
32 } | |
33 | |
34 void testFailure() { | |
35 asyncStart(); | |
36 Directory.systemTemp.createTemp('dart_detached_process').then((temp) { | |
37 var future = Process.start(temp.path, ['a', 'b'], detach: true); | |
38 future.then((process) { | |
39 Expect.fail('Starting process from invalid executable succeeded'); | |
40 }, onError: (e) { | |
41 Expect.isTrue(e is ProcessException); | |
42 }).whenComplete(() { | |
43 temp.deleteSync(); | |
44 asyncEnd(); | |
45 }); | |
46 }); | |
47 } | |
48 | |
49 main() { | |
50 test(); | |
51 testFailure(); | |
52 } | |
OLD | NEW |