OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 // | |
5 // Test script for testing that output is handled correctly for | |
6 // non-interactive processes started with Process.run. | |
7 | |
8 #import("dart:io"); | |
9 #source("ProcessTestUtil.dart"); | |
10 | |
11 checkOutput(encoding, output) { | |
12 if (encoding == 'ascii') { | |
13 Expect.equals(output, 'abc'); | |
14 } else if (encoding == 'latin1') { | |
15 Expect.equals(output, 'æøå'); | |
16 } else if (encoding == 'utf8') { | |
17 Expect.listEquals(output.charCodes(), [955]); | |
18 } | |
19 } | |
20 | |
21 test(scriptFile, encoding, stream) { | |
22 var enc; | |
23 if (encoding == 'ascii') { | |
24 enc = Encoding.ASCII; | |
25 } else if (encoding == 'latin1') { | |
26 enc = Encoding.ISO_8859_1; | |
27 } else if (encoding == 'utf8') { | |
28 enc = Encoding.UTF_8; | |
29 } | |
30 | |
31 var options = new ProcessOptions(); | |
32 if (stream == 'stdout') { | |
33 options.stdoutEncoding = enc; | |
34 new Process.run(getDartFileName(), [scriptFile, encoding, stream], | |
35 options, (exit, out, err) { | |
36 Expect.equals(exit, 0); | |
37 Expect.equals(err, ''); | |
38 checkOutput(encoding, out); | |
39 }); | |
40 } else { | |
41 options.stderrEncoding = enc; | |
42 new Process.run(getDartFileName(), [scriptFile, encoding, stream], | |
43 options, (exit, out, err) { | |
44 Expect.equals(exit, 0); | |
45 Expect.equals(out, ''); | |
46 checkOutput(encoding, err); | |
47 }); | |
48 } | |
49 } | |
50 | |
51 main() { | |
52 var scriptFile = new File("tests/standalone/src/io/ProcessStdIOScript2.dart"); | |
53 if (!scriptFile.existsSync()) { | |
54 scriptFile = | |
55 new File("../tests/standalone/src/io/ProcessStdIOScript2.dart"); | |
56 } | |
57 Expect.isTrue(scriptFile.existsSync()); | |
58 test(scriptFile.name, 'ascii', 'stdout'); | |
59 test(scriptFile.name, 'ascii', 'stderr'); | |
60 test(scriptFile.name, 'latin1', 'stdout'); | |
61 test(scriptFile.name, 'latin1', 'stderr'); | |
62 test(scriptFile.name, 'utf8', 'stdout'); | |
63 test(scriptFile.name, 'utf8', 'stderr'); | |
64 | |
65 } | |
OLD | NEW |