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

Side by Side Diff: tests/standalone/src/ProcessStdoutTest.dart

Issue 8365032: Process tests work across platforms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More line endings. Created 9 years, 1 month 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
« no previous file with comments | « tests/standalone/src/ProcessStderrTest.dart ('k') | tests/standalone/src/ProcessTestUtil.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Process test program to test process communication. 5 // Process test program to test process communication.
6 // 6 //
7 // VMOptions= 7 // VMOptions=
8 // VMOptions=--short_socket_read 8 // VMOptions=--short_socket_read
9 // VMOptions=--short_socket_write 9 // VMOptions=--short_socket_write
10 // VMOptions=--short_socket_read --short_socket_write 10 // VMOptions=--short_socket_read --short_socket_write
11 11
12 #source("ProcessTestUtil.dart");
13
12 class ProcessStdoutTest { 14 class ProcessStdoutTest {
13 15
14 static void testStdout() { 16 static void testExit() {
15 Process process = new Process("out/Debug_ia32//process_test", 17 Process process = new Process(getProcessTestFileName(),
16 const ["0", "1", "99", "0"]); 18 const ["0", "1", "99", "0"]);
17 final int BUFFERSIZE = 10; 19 final int BUFFERSIZE = 10;
18 final int STARTCHAR = 65; 20 final int STARTCHAR = 65;
19 List<int> data = new List<int>(BUFFERSIZE); 21 List<int> data = new List<int>(BUFFERSIZE);
20 for (int i = 0; (i < BUFFERSIZE - 1); i++) { 22 for (int i = 0; (i < BUFFERSIZE - 1); i++) {
21 data[i] = STARTCHAR + i; 23 data[i] = STARTCHAR + i;
22 } 24 }
23 data[BUFFERSIZE - 1] = 10; 25 data[BUFFERSIZE - 1] = 10;
24 26
25 InputStream input = process.stdout; 27 InputStream input = process.stdout;
26 OutputStream output = process.stdin; 28 OutputStream output = process.stdin;
27 29
28 process.start(); 30 process.start();
29 31
30 int received = 0; 32 int received = 0;
33 List<int> buffer = [];
31 34
32 void readData() { 35 void readData() {
33 List<int> buffer = input.read(); 36 buffer.addAll(input.read());
34 for (int i = 0; i < buffer.length; i++) { 37 for (int i = received; i < Math.min(data.length, buffer.length) - 1; i++) {
35 Expect.equals(data[received + i], buffer[i]); 38 Expect.equals(data[i], buffer[i]);
36 } 39 }
37 received += buffer.length; 40 received = buffer.length;
41 if (received >= BUFFERSIZE) {
42 // We expect an extra character on windows due to carriage return.
43 if (13 === buffer[BUFFERSIZE - 1] && BUFFERSIZE + 1 === received) {
44 Expect.equals(13, buffer[BUFFERSIZE - 1]);
45 Expect.equals(10, buffer[BUFFERSIZE]);
46 buffer.removeLast();
47 process.close();
48 } else if (received === BUFFERSIZE) {
49 Expect.equals(10, buffer[BUFFERSIZE - 1]);
50 process.close();
51 }
52 }
38 } 53 }
39 54
40 void streamClosed() { 55 void streamClosed() {
41 Expect.equals(BUFFERSIZE, received); 56 Expect.equals(BUFFERSIZE, received);
42 process.close();
43 } 57 }
44 58
45 output.write(data); 59 output.write(data);
46 output.close(); 60 output.close();
47 input.dataHandler = readData; 61 input.dataHandler = readData;
48 input.closeHandler = streamClosed; 62 input.closeHandler = streamClosed;
49 } 63 }
50 64
51 static void testMain() { 65 static void testMain() {
52 testStdout(); 66 testExit();
53 } 67 }
54 } 68 }
55 69
56 main() { 70 main() {
57 ProcessStdoutTest.testStdout(); 71 ProcessStdoutTest.testMain();
58 } 72 }
OLDNEW
« no previous file with comments | « tests/standalone/src/ProcessStderrTest.dart ('k') | tests/standalone/src/ProcessTestUtil.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698