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

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

Issue 2920283002: Fix type argument for Result. (Closed)
Patch Set: Created 3 years, 6 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 | no next file » | 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 EventSink, Future, Stream, StreamTransformer, Timer; 7 import 'dart:async' show EventSink, Future, Stream, StreamTransformer, Timer;
8 8
9 import 'dart:convert' show UTF8; 9 import 'dart:convert' show UTF8;
10 10
11 import 'dart:io' show Process, ProcessSignal, Stdout; 11 import 'dart:io' show Process, ProcessSignal, Stdout;
12 12
13 import 'dart:io' as io show stderr, stdout; 13 import 'dart:io' as io show stderr, stdout;
14 14
15 import 'chain.dart' show Result; 15 import 'chain.dart' show Result;
16 16
17 import 'expectation.dart' show ExpectationSet; 17 import 'expectation.dart' show ExpectationSet;
18 18
19 class StdioProcess { 19 class StdioProcess {
20 final int exitCode; 20 final int exitCode;
21 21
22 final String output; 22 final String output;
23 23
24 StdioProcess(this.exitCode, this.output); 24 StdioProcess(this.exitCode, this.output);
25 25
26 Result<int> toResult({int expected: 0}) { 26 Result<int> toResult({int expected: 0}) {
27 if (exitCode == expected) { 27 if (exitCode == expected) {
28 return new Result<int>.pass(exitCode); 28 return new Result<int>.pass(exitCode);
29 } else { 29 } else {
30 return new Result<Program>( 30 return new Result<int>(
31 exitCode, ExpectationSet.Default["RuntimeError"], output, null); 31 exitCode, ExpectationSet.Default["RuntimeError"], output, null);
32 } 32 }
33 } 33 }
34 34
35 static StreamTransformer<String, String> transformToStdio(Stdout stdio) { 35 static StreamTransformer<String, String> transformToStdio(Stdout stdio) {
36 return new StreamTransformer<String, String>.fromHandlers( 36 return new StreamTransformer<String, String>.fromHandlers(
37 handleData: (String data, EventSink<String> sink) { 37 handleData: (String data, EventSink<String> sink) {
38 sink.add(data); 38 sink.add(data);
39 stdio.write(data); 39 stdio.write(data);
40 }); 40 });
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 Future<List<String>> stdoutFuture = stdoutStream.toList(); 76 Future<List<String>> stdoutFuture = stdoutStream.toList();
77 Future<List<String>> stderrFuture = stderrStream.toList(); 77 Future<List<String>> stderrFuture = stderrStream.toList();
78 int exitCode = await process.exitCode; 78 int exitCode = await process.exitCode;
79 timer?.cancel(); 79 timer?.cancel();
80 sb.writeAll(await stdoutFuture); 80 sb.writeAll(await stdoutFuture);
81 sb.writeAll(await stderrFuture); 81 sb.writeAll(await stderrFuture);
82 await closeFuture; 82 await closeFuture;
83 return new StdioProcess(exitCode, "$sb"); 83 return new StdioProcess(exitCode, "$sb");
84 } 84 }
85 } 85 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698