OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // OtherResources=process_sync_script.dart | 5 // OtherResources=process_sync_script.dart |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import 'package:path/path.dart'; | 8 import 'package:path/path.dart'; |
9 import "dart:io"; | 9 import "dart:io"; |
10 | 10 |
11 test(int blockCount, | 11 test(int blockCount, int stdoutBlockSize, int stderrBlockSize, int exitCode, |
12 int stdoutBlockSize, | 12 [int nonWindowsExitCode]) { |
13 int stderrBlockSize, | |
14 int exitCode, | |
15 [int nonWindowsExitCode]) { | |
16 // Get the Dart script file that generates output. | 13 // Get the Dart script file that generates output. |
17 var scriptFile = new File(Platform.script | 14 var scriptFile = new File( |
18 .resolve("process_sync_script.dart") | 15 Platform.script.resolve("process_sync_script.dart").toFilePath()); |
19 .toFilePath()); | 16 var args = [ |
20 var args = [scriptFile.path, | 17 scriptFile.path, |
21 blockCount.toString(), | 18 blockCount.toString(), |
22 stdoutBlockSize.toString(), | 19 stdoutBlockSize.toString(), |
23 stderrBlockSize.toString(), | 20 stderrBlockSize.toString(), |
24 exitCode.toString()]; | 21 exitCode.toString() |
| 22 ]; |
25 ProcessResult syncResult = Process.runSync(Platform.executable, args); | 23 ProcessResult syncResult = Process.runSync(Platform.executable, args); |
26 Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length); | 24 Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length); |
27 Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length); | 25 Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length); |
28 if (Platform.isWindows) { | 26 if (Platform.isWindows) { |
29 Expect.equals(exitCode, syncResult.exitCode); | 27 Expect.equals(exitCode, syncResult.exitCode); |
30 } else { | 28 } else { |
31 if (nonWindowsExitCode == null) { | 29 if (nonWindowsExitCode == null) { |
32 Expect.equals(exitCode, syncResult.exitCode); | 30 Expect.equals(exitCode, syncResult.exitCode); |
33 } else { | 31 } else { |
34 Expect.equals(nonWindowsExitCode, syncResult.exitCode); | 32 Expect.equals(nonWindowsExitCode, syncResult.exitCode); |
(...skipping 19 matching lines...) Expand all Loading... |
54 var kBufferSize = 16 * 1024; | 52 var kBufferSize = 16 * 1024; |
55 test(1, kBufferSize, kBufferSize, 0); | 53 test(1, kBufferSize, kBufferSize, 0); |
56 test(1, kBufferSize - 1, kBufferSize - 1, 0); | 54 test(1, kBufferSize - 1, kBufferSize - 1, 0); |
57 test(1, kBufferSize + 1, kBufferSize + 1, 0); | 55 test(1, kBufferSize + 1, kBufferSize + 1, 0); |
58 | 56 |
59 test(10, 10, 10, 1); | 57 test(10, 10, 10, 1); |
60 test(10, 10, 10, 255); | 58 test(10, 10, 10, 255); |
61 test(10, 10, 10, -1, 255); | 59 test(10, 10, 10, -1, 255); |
62 test(10, 10, 10, -255, 1); | 60 test(10, 10, 10, -255, 1); |
63 } | 61 } |
64 | |
OLD | NEW |