| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import "dart:io"; |
| 7 |
| 8 test(int blockCount, |
| 9 int stdoutBlockSize, |
| 10 int stderrBlockSize, |
| 11 int exitCode, |
| 12 [int nonWindowsExitCode]) { |
| 13 // Get the Dart script file which generated output. |
| 14 var scriptFile = |
| 15 new File("tests/standalone/io/process_sync_script.dart"); |
| 16 if (!scriptFile.existsSync()) { |
| 17 scriptFile = |
| 18 new File("../tests/standalone/io/process_sync_script.dart"); |
| 19 } |
| 20 var args = [scriptFile.path, |
| 21 blockCount.toString(), |
| 22 stdoutBlockSize.toString(), |
| 23 stderrBlockSize.toString(), |
| 24 exitCode.toString()]; |
| 25 ProcessResult syncResult = Process.runSync(Platform.executable, args); |
| 26 Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length); |
| 27 Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length); |
| 28 if (Platform.isWindows) { |
| 29 Expect.equals(exitCode, syncResult.exitCode); |
| 30 } else { |
| 31 if (nonWindowsExitCode == null) { |
| 32 Expect.equals(exitCode, syncResult.exitCode); |
| 33 } else { |
| 34 Expect.equals(nonWindowsExitCode, syncResult.exitCode); |
| 35 } |
| 36 } |
| 37 Process.run(Platform.executable, args).then((asyncResult) { |
| 38 Expect.equals(syncResult.stdout, asyncResult.stdout); |
| 39 Expect.equals(syncResult.stderr, asyncResult.stderr); |
| 40 Expect.equals(syncResult.exitCode, asyncResult.exitCode); |
| 41 }); |
| 42 } |
| 43 |
| 44 main() { |
| 45 test(10, 10, 10, 0); |
| 46 test(10, 100, 10, 0); |
| 47 test(10, 10, 100, 0); |
| 48 test(100, 1, 10, 0); |
| 49 test(100, 10, 1, 0); |
| 50 test(100, 1, 1, 0); |
| 51 test(1, 100000, 100000, 0); |
| 52 |
| 53 test(10, 10, 10, 1); |
| 54 test(10, 10, 10, 255); |
| 55 test(10, 10, 10, -1, 255); |
| 56 test(10, 10, 10, -255, 1); |
| 57 } |
| 58 |
| OLD | NEW |