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

Side by Side Diff: tests/standalone/io/process_run_output_test.dart

Issue 16309014: Add support for binary stdout/stderr data when using Process.run (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed debug print Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Test script for testing that output is handled correctly for 5 // Test script for testing that output is handled correctly for
6 // non-interactive processes started with Process.run. 6 // non-interactive processes started with Process.run.
7 7
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "dart:io"; 9 import "dart:io";
10 import "process_test_util.dart"; 10 import "process_test_util.dart";
11 11
12 checkOutput(encoding, output) { 12 checkOutput(encoding, output) {
13 if (encoding == 'ascii') { 13 if (encoding == 'ascii') {
14 Expect.equals(output, 'abc'); 14 Expect.equals(output, 'abc');
15 } else if (encoding == 'latin1') { 15 } else if (encoding == 'latin1') {
16 Expect.equals(output, 'æøå'); 16 Expect.equals(output, 'æøå');
17 } else if (encoding == 'utf8') { 17 } else if (encoding == 'utf8') {
18 Expect.listEquals(output.codeUnits, [955]); 18 Expect.listEquals(output.codeUnits, [955]);
19 } else if (encoding == 'binary') {
20 print(output);
21 Expect.listEquals(output, [0, 1, 2]);
19 } 22 }
20 } 23 }
21 24
22 test(scriptFile, encoding, stream) { 25 test(scriptFile, encoding, stream) {
23 var enc; 26 var enc;
24 if (encoding == 'ascii') { 27 if (encoding == 'ascii') {
25 enc = Encoding.ASCII; 28 enc = Encoding.ASCII;
26 } else if (encoding == 'latin1') { 29 } else if (encoding == 'latin1') {
27 enc = Encoding.ISO_8859_1; 30 enc = Encoding.ISO_8859_1;
28 } else if (encoding == 'utf8') { 31 } else if (encoding == 'utf8') {
29 enc = Encoding.UTF_8; 32 enc = Encoding.UTF_8;
33 } else if (encoding == 'binary') {
34 enc = Encoding.BINARY;
30 } 35 }
31 36
32 if (stream == 'stdout') { 37 if (stream == 'stdout') {
33 Process.run(new Options().executable, 38 Process.run(new Options().executable,
34 [scriptFile, encoding, stream], 39 [scriptFile, encoding, stream],
35 stdoutEncoding: enc). then((result) { 40 stdoutEncoding: enc). then((result) {
36 Expect.equals(result.exitCode, 0); 41 Expect.equals(result.exitCode, 0);
37 Expect.equals(result.stderr, ''); 42 Expect.equals(result.stderr, '');
38 checkOutput(encoding, result.stdout); 43 checkOutput(encoding, result.stdout);
39 }); 44 });
(...skipping 14 matching lines...) Expand all
54 scriptFile = 59 scriptFile =
55 new File("../tests/standalone/io/process_std_io_script2.dart"); 60 new File("../tests/standalone/io/process_std_io_script2.dart");
56 } 61 }
57 Expect.isTrue(scriptFile.existsSync()); 62 Expect.isTrue(scriptFile.existsSync());
58 test(scriptFile.path, 'ascii', 'stdout'); 63 test(scriptFile.path, 'ascii', 'stdout');
59 test(scriptFile.path, 'ascii', 'stderr'); 64 test(scriptFile.path, 'ascii', 'stderr');
60 test(scriptFile.path, 'latin1', 'stdout'); 65 test(scriptFile.path, 'latin1', 'stdout');
61 test(scriptFile.path, 'latin1', 'stderr'); 66 test(scriptFile.path, 'latin1', 'stderr');
62 test(scriptFile.path, 'utf8', 'stdout'); 67 test(scriptFile.path, 'utf8', 'stdout');
63 test(scriptFile.path, 'utf8', 'stderr'); 68 test(scriptFile.path, 'utf8', 'stderr');
64 69 test(scriptFile.path, 'binary', 'stdout');
70 test(scriptFile.path, 'binary', 'stderr');
65 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698