Chromium Code Reviews| Index: tests/standalone/io/process_detached_test.dart |
| diff --git a/tests/standalone/io/process_detached_test.dart b/tests/standalone/io/process_detached_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2de960ea12e8cfeada8c8b6388f85c71fe869fa4 |
| --- /dev/null |
| +++ b/tests/standalone/io/process_detached_test.dart |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| +// |
| +// Process test program to test detached processes. |
| +// |
| +// VMOptions= |
| +// VMOptions=--short_socket_read |
| +// VMOptions=--short_socket_write |
| +// 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.
|
| + |
| +import 'dart:async'; |
| +import 'dart:io'; |
| + |
| +import "package:async_helper/async_helper.dart"; |
| +import "package:expect/expect.dart"; |
| + |
| +import "process_test_util.dart"; |
| + |
| +void test() { |
| + asyncStart(); |
| + var script = |
| + Platform.script.resolve('process_detached_script.dart').toFilePath(); |
| + var future = Process.start(Platform.executable, [script], detached: true); |
| + future.then((process) { |
| + 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
|
| + Expect.isNull(process.exitCode); |
| + Expect.isNull(process.stderr); |
| + Expect.isNull(process.stdin); |
| + Expect.isNull(process.stdout); |
| + Expect.isTrue(process.kill()); |
| + }).whenComplete(() { |
| + asyncEnd(); |
| + }); |
| +} |
| + |
| +void testFailure() { |
| + asyncStart(); |
| + Directory.systemTemp.createTemp('dart_detached_process').then((temp) { |
| + var future = Process.start(temp.path, ['a', 'b'], detached: true); |
| + future.then((process) { |
| + Expect.fail('Starting process from invalid executable succeeded'); |
| + }).catchError((e) { |
| + 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!
|
| + }).whenComplete(() { |
| + temp.deleteSync(); |
| + asyncEnd(); |
| + }); |
| + }); |
| +} |
| + |
| +main() { |
| + test(); |
| + testFailure(); |
| +} |