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:io"; | 9 import "dart:io"; |
10 import "process_test_util.dart"; | 10 import "process_test_util.dart"; |
(...skipping 11 matching lines...) Expand all Loading... |
22 test(scriptFile, encoding, stream) { | 22 test(scriptFile, encoding, stream) { |
23 var enc; | 23 var enc; |
24 if (encoding == 'ascii') { | 24 if (encoding == 'ascii') { |
25 enc = Encoding.ASCII; | 25 enc = Encoding.ASCII; |
26 } else if (encoding == 'latin1') { | 26 } else if (encoding == 'latin1') { |
27 enc = Encoding.ISO_8859_1; | 27 enc = Encoding.ISO_8859_1; |
28 } else if (encoding == 'utf8') { | 28 } else if (encoding == 'utf8') { |
29 enc = Encoding.UTF_8; | 29 enc = Encoding.UTF_8; |
30 } | 30 } |
31 | 31 |
32 var options = new ProcessOptions(); | |
33 if (stream == 'stdout') { | 32 if (stream == 'stdout') { |
34 options.stdoutEncoding = enc; | |
35 Process.run(new Options().executable, | 33 Process.run(new Options().executable, |
36 [scriptFile, encoding, stream], | 34 [scriptFile, encoding, stream], |
37 options). then((result) { | 35 stdoutEncoding: enc). then((result) { |
38 Expect.equals(result.exitCode, 0); | 36 Expect.equals(result.exitCode, 0); |
39 Expect.equals(result.stderr, ''); | 37 Expect.equals(result.stderr, ''); |
40 checkOutput(encoding, result.stdout); | 38 checkOutput(encoding, result.stdout); |
41 }); | 39 }); |
42 } else { | 40 } else { |
43 options.stderrEncoding = enc; | |
44 Process.run(new Options().executable, | 41 Process.run(new Options().executable, |
45 [scriptFile, encoding, stream], | 42 [scriptFile, encoding, stream], |
46 options).then((result) { | 43 stderrEncoding: enc).then((result) { |
47 Expect.equals(result.exitCode, 0); | 44 Expect.equals(result.exitCode, 0); |
48 Expect.equals(result.stdout, ''); | 45 Expect.equals(result.stdout, ''); |
49 checkOutput(encoding, result.stderr); | 46 checkOutput(encoding, result.stderr); |
50 }); | 47 }); |
51 } | 48 } |
52 } | 49 } |
53 | 50 |
54 main() { | 51 main() { |
55 var scriptFile = new File("tests/standalone/io/process_std_io_script2.dart"); | 52 var scriptFile = new File("tests/standalone/io/process_std_io_script2.dart"); |
56 if (!scriptFile.existsSync()) { | 53 if (!scriptFile.existsSync()) { |
57 scriptFile = | 54 scriptFile = |
58 new File("../tests/standalone/io/process_std_io_script2.dart"); | 55 new File("../tests/standalone/io/process_std_io_script2.dart"); |
59 } | 56 } |
60 Expect.isTrue(scriptFile.existsSync()); | 57 Expect.isTrue(scriptFile.existsSync()); |
61 test(scriptFile.path, 'ascii', 'stdout'); | 58 test(scriptFile.path, 'ascii', 'stdout'); |
62 test(scriptFile.path, 'ascii', 'stderr'); | 59 test(scriptFile.path, 'ascii', 'stderr'); |
63 test(scriptFile.path, 'latin1', 'stdout'); | 60 test(scriptFile.path, 'latin1', 'stdout'); |
64 test(scriptFile.path, 'latin1', 'stderr'); | 61 test(scriptFile.path, 'latin1', 'stderr'); |
65 test(scriptFile.path, 'utf8', 'stdout'); | 62 test(scriptFile.path, 'utf8', 'stdout'); |
66 test(scriptFile.path, 'utf8', 'stderr'); | 63 test(scriptFile.path, 'utf8', 'stderr'); |
67 | 64 |
68 } | 65 } |
OLD | NEW |