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