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