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

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: Fixed another Windows issue 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 'package:path/path.dart';
7 import "dart:io";
8
9 test(int blockCount,
10 int stdoutBlockSize,
11 int stderrBlockSize,
12 int exitCode,
13 [int nonWindowsExitCode]) {
14 // Get the Dart script file that generates output.
15 var scriptFile = new File(join(dirname(Platform.script),
16 "process_sync_script.dart"));
17 var args = [scriptFile.path,
18 blockCount.toString(),
19 stdoutBlockSize.toString(),
20 stderrBlockSize.toString(),
21 exitCode.toString()];
22 ProcessResult syncResult = Process.runSync(Platform.executable, args);
23 Expect.equals(blockCount * stdoutBlockSize, syncResult.stdout.length);
24 Expect.equals(blockCount * stderrBlockSize, syncResult.stderr.length);
25 if (Platform.isWindows) {
26 Expect.equals(exitCode, syncResult.exitCode);
27 } else {
28 if (nonWindowsExitCode == null) {
29 Expect.equals(exitCode, syncResult.exitCode);
30 } else {
31 Expect.equals(nonWindowsExitCode, syncResult.exitCode);
32 }
33 }
34 Process.run(Platform.executable, args).then((asyncResult) {
35 Expect.equals(syncResult.stdout, asyncResult.stdout);
36 Expect.equals(syncResult.stderr, asyncResult.stderr);
37 Expect.equals(syncResult.exitCode, asyncResult.exitCode);
38 });
39 }
40
41 main() {
42 test(10, 10, 10, 0);
43 test(10, 100, 10, 0);
44 test(10, 10, 100, 0);
45 test(100, 1, 10, 0);
46 test(100, 10, 1, 0);
47 test(100, 1, 1, 0);
48 test(1, 100000, 100000, 0);
49
50 // The buffer size used in process.h.
51 var kBufferSize = 16 * 1024;
52 test(1, kBufferSize, kBufferSize, 0);
53 test(1, kBufferSize - 1, kBufferSize + 1, 0);
54 test(kBufferSize - 1, 1, 1, 0);
55 test(kBufferSize, 1, 1, 0);
56 test(kBufferSize + 1, 1, 1, 0);
57
58 test(10, 10, 10, 1);
59 test(10, 10, 10, 255);
60 test(10, 10, 10, -1, 255);
61 test(10, 10, 10, -255, 1);
62 }
63
OLDNEW
« runtime/bin/process_win.cc ('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