Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: tests/standalone/io/process_detached_test.dart

Issue 798743004: Add support for starting a detached process (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor fixes + rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+}

Powered by Google App Engine
This is Rietveld 408576698