| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library testing.stdio_process; | 5 library testing.stdio_process; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future, | 8 Future, |
| 9 Timer; | 9 Timer; |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 sb.writeln(); | 47 sb.writeln(); |
| 48 sb.writeln("Sending SIGTERM to process"); | 48 sb.writeln("Sending SIGTERM to process"); |
| 49 process.kill(); | 49 process.kill(); |
| 50 timer = new Timer(const Duration(seconds: 10), () { | 50 timer = new Timer(const Duration(seconds: 10), () { |
| 51 sb.writeln("Sending SIGKILL to process"); | 51 sb.writeln("Sending SIGKILL to process"); |
| 52 process.kill(ProcessSignal.SIGKILL); | 52 process.kill(ProcessSignal.SIGKILL); |
| 53 }); | 53 }); |
| 54 }); | 54 }); |
| 55 if (input != null) { | 55 if (input != null) { |
| 56 process.stdin.write(input); | 56 process.stdin.write(input); |
| 57 await process.stdin.flush(); |
| 57 } | 58 } |
| 58 Future closeFuture = process.stdin.close(); | 59 Future closeFuture = process.stdin.close(); |
| 59 Future<List<String>> stdoutFuture = | 60 Future<List<String>> stdoutFuture = |
| 60 process.stdout.transform(UTF8.decoder).toList(); | 61 process.stdout.transform(UTF8.decoder).toList(); |
| 61 Future<List<String>> stderrFuture = | 62 Future<List<String>> stderrFuture = |
| 62 process.stderr.transform(UTF8.decoder).toList(); | 63 process.stderr.transform(UTF8.decoder).toList(); |
| 63 int exitCode = await process.exitCode; | 64 int exitCode = await process.exitCode; |
| 64 timer.cancel(); | 65 timer.cancel(); |
| 65 sb.writeAll(await stdoutFuture); | 66 sb.writeAll(await stdoutFuture); |
| 66 sb.writeAll(await stderrFuture); | 67 sb.writeAll(await stderrFuture); |
| 67 await closeFuture; | 68 await closeFuture; |
| 68 return new StdioProcess(exitCode, "$sb"); | 69 return new StdioProcess(exitCode, "$sb"); |
| 69 } | 70 } |
| 70 } | 71 } |
| OLD | NEW |