OLD | NEW |
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:convert"; |
9 import "dart:io"; | 10 import "dart:io"; |
10 import "process_test_util.dart"; | 11 import "process_test_util.dart"; |
11 | 12 |
12 checkOutput(encoding, output) { | 13 checkOutput(String encoding, output) { |
13 if (encoding == 'ascii') { | 14 if (encoding == 'ascii') { |
14 Expect.equals(output, 'abc'); | 15 Expect.equals(output, 'abc'); |
15 } else if (encoding == 'latin1') { | 16 } else if (encoding == 'latin1') { |
16 Expect.equals(output, 'æøå'); | 17 Expect.equals(output, 'æøå'); |
17 } else if (encoding == 'utf8') { | 18 } else if (encoding == 'utf8') { |
18 Expect.listEquals(output.codeUnits, [955]); | 19 Expect.listEquals(output.codeUnits, [955]); |
19 } else if (encoding == 'binary') { | 20 } else if (encoding == 'binary') { |
20 print(output); | 21 print(output); |
21 Expect.listEquals(output, [0, 1, 2]); | 22 Expect.listEquals(output, [0, 1, 2]); |
22 } | 23 } |
23 } | 24 } |
24 | 25 |
25 test(scriptFile, encoding, stream) { | 26 test(scriptFile, String encoding, stream) { |
26 var enc; | 27 var enc; |
27 if (encoding == 'ascii') { | 28 if (encoding == 'ascii') { |
28 enc = Encoding.ASCII; | 29 enc = ASCII; |
29 } else if (encoding == 'latin1') { | 30 } else if (encoding == 'latin1') { |
30 enc = Encoding.ISO_8859_1; | 31 enc = LATIN1; |
31 } else if (encoding == 'utf8') { | 32 } else if (encoding == 'utf8') { |
32 enc = Encoding.UTF_8; | 33 enc = UTF8; |
33 } else if (encoding == 'binary') { | 34 } else if (encoding == 'binary') { |
34 enc = null; | 35 enc = null; |
35 } | 36 } |
36 | 37 |
37 if (stream == 'stdout') { | 38 if (stream == 'stdout') { |
38 Process.run(Platform.executable, | 39 Process.run(Platform.executable, |
39 [scriptFile, encoding, stream], | 40 [scriptFile, encoding, stream], |
40 stdoutEncoding: enc). then((result) { | 41 stdoutEncoding: enc). then((result) { |
41 Expect.equals(result.exitCode, 0); | 42 Expect.equals(result.exitCode, 0); |
42 Expect.equals(result.stderr, ''); | 43 Expect.equals(result.stderr, ''); |
(...skipping 19 matching lines...) Expand all Loading... |
62 Expect.isTrue(scriptFile.existsSync()); | 63 Expect.isTrue(scriptFile.existsSync()); |
63 test(scriptFile.path, 'ascii', 'stdout'); | 64 test(scriptFile.path, 'ascii', 'stdout'); |
64 test(scriptFile.path, 'ascii', 'stderr'); | 65 test(scriptFile.path, 'ascii', 'stderr'); |
65 test(scriptFile.path, 'latin1', 'stdout'); | 66 test(scriptFile.path, 'latin1', 'stdout'); |
66 test(scriptFile.path, 'latin1', 'stderr'); | 67 test(scriptFile.path, 'latin1', 'stderr'); |
67 test(scriptFile.path, 'utf8', 'stdout'); | 68 test(scriptFile.path, 'utf8', 'stdout'); |
68 test(scriptFile.path, 'utf8', 'stderr'); | 69 test(scriptFile.path, 'utf8', 'stderr'); |
69 test(scriptFile.path, 'binary', 'stdout'); | 70 test(scriptFile.path, 'binary', 'stdout'); |
70 test(scriptFile.path, 'binary', 'stderr'); | 71 test(scriptFile.path, 'binary', 'stderr'); |
71 } | 72 } |
OLD | NEW |