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

Side by Side Diff: pkg/testing/lib/src/stdio_process.dart

Issue 2687963003: [dart:io] flush() stdin before close()ing (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | sdk/lib/io/io_sink.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/io_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698