Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(675)

Unified Diff: tests/standalone/io/process_sync_test.dart

Issue 21816002: Add Process.runSync for running processe synchronously. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Combined the code from https://codereview.chromium.org/22827002/ into this change Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/standalone/io/process_sync_test.dart
diff --git a/tests/standalone/io/process_sync_test.dart b/tests/standalone/io/process_sync_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c3b8996f27faca551ab47b0ae4b0f56adb79c7f9
--- /dev/null
+++ b/tests/standalone/io/process_sync_test.dart
@@ -0,0 +1,58 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "dart:io";
+
+test(int blockCount,
+ int stdoutBlockSize,
+ int stderrBlockSize,
+ int exitCode,
+ [int nonWindowsExitCode]) {
+ // Get the Dart script file which generated output.
Bill Hesse 2013/08/13 08:34:48 that generates
Søren Gjesse 2013/08/13 13:00:43 Done.
+ var scriptFile =
Bill Hesse 2013/08/13 08:34:48 Why not use Platform.script, and path package, to
Søren Gjesse 2013/08/13 13:00:43 This is some old code I copied. Changed to var
+ new File("tests/standalone/io/process_sync_script.dart");
+ if (!scriptFile.existsSync()) {
+ scriptFile =
+ new File("../tests/standalone/io/process_sync_script.dart");
+ }
+ var args = [scriptFile.path,
+ blockCount.toString(),
+ stdoutBlockSize.toString(),
+ stderrBlockSize.toString(),
+ exitCode.toString()];
+ ProcessResult syncResult = Process.runSync(Platform.executable, args);
+ Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length);
+ Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length);
+ if (Platform.isWindows) {
+ Expect.equals(exitCode, syncResult.exitCode);
+ } else {
+ if (nonWindowsExitCode == null) {
+ Expect.equals(exitCode, syncResult.exitCode);
+ } else {
+ Expect.equals(nonWindowsExitCode, syncResult.exitCode);
+ }
+ }
+ Process.run(Platform.executable, args).then((asyncResult) {
+ Expect.equals(syncResult.stdout, asyncResult.stdout);
+ Expect.equals(syncResult.stderr, asyncResult.stderr);
+ Expect.equals(syncResult.exitCode, asyncResult.exitCode);
+ });
+}
+
+main() {
+ test(10, 10, 10, 0);
+ test(10, 100, 10, 0);
+ test(10, 10, 100, 0);
+ test(100, 1, 10, 0);
+ test(100, 10, 1, 0);
+ test(100, 1, 1, 0);
+ test(1, 100000, 100000, 0);
Bill Hesse 2013/08/13 08:34:48 Maybe buffer blocksize and buffer blocksize - 1 he
Søren Gjesse 2013/08/13 13:00:43 Done.
+
+ test(10, 10, 10, 1);
+ test(10, 10, 10, 255);
+ test(10, 10, 10, -1, 255);
+ test(10, 10, 10, -255, 1);
+}
+
« tests/standalone/io/process_sync_script.dart ('K') | « tests/standalone/io/process_sync_script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698