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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
Bill Hesse 2013/08/13 08:34:48 that generates
Søren Gjesse 2013/08/13 13:00:43 Done.
14 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
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);
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.
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
OLDNEW
« 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