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

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

Issue 890633002: Add an option for starting a detached process with stdio connected (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased 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
« no previous file with comments | « tests/standalone/io/process_detached_script.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index 483b9ca24dfd9dbe6a1dedbe8c5a332ae794ae3e..194e756776297a7e3ab89b009f00831ae08c1ff1 100644
--- a/tests/standalone/io/process_detached_test.dart
+++ b/tests/standalone/io/process_detached_test.dart
@@ -16,9 +16,9 @@ void test() {
asyncStart();
var script =
Platform.script.resolve('process_detached_script.dart').toFilePath();
- var future = Process.start(Platform.executable, [script], detach: true);
+ var future = Process.start(
+ Platform.executable, [script], mode: ProcessStartMode.DETACHED);
future.then((process) {
- print(process.pid);
Expect.isNotNull(process.pid);
Expect.isTrue(process.pid is int);
Expect.isNull(process.exitCode);
@@ -31,10 +31,41 @@ void test() {
});
}
+void testWithStdio() {
+ asyncStart();
+ var script =
+ Platform.script.resolve('process_detached_script.dart').toFilePath();
+ var future = Process.start(
+ Platform.executable,
+ [script, 'echo'],
+ mode: ProcessStartMode.DETACHED_WITH_STDIO);
+ future.then((process) {
+ Expect.isNotNull(process.pid);
+ Expect.isTrue(process.pid is int);
+ Expect.isNull(process.exitCode);
+ var message = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ process.stdin.add(message);
+ process.stdin.close();
+ var f1 = process.stdout.fold([], (p, e) => p..addAll(e));
+ var f2 = process.stderr.fold([], (p, e) => p..addAll(e));
+ Future.wait([f1, f2])
+ .then((values) {
+ Expect.listEquals(values[0], message);
+ Expect.listEquals(values[1], message);
+ })
+ .whenComplete(() {
+ 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'], detach: true);
+ var future = Process.start(
+ temp.path, ['a', 'b'], mode: ProcessStartMode.DETACHED);
future.then((process) {
Expect.fail('Starting process from invalid executable succeeded');
}, onError: (e) {
@@ -48,5 +79,6 @@ void testFailure() {
main() {
test();
+ testWithStdio();
testFailure();
}
« no previous file with comments | « tests/standalone/io/process_detached_script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698