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(); |
} |