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

Side by Side Diff: tests/standalone/src/ProcessStderrTest.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
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 ProcessStderrTest { 14 class ProcessStderrTest {
13 static void testStderr() { 15
14 Process process = new Process("out/Debug_ia32/process_test", 16 static void testExit() {
17 Process process = new Process(getProcessTestFileName(),
15 const ["1", "1", "99", "0"]); 18 const ["1", "1", "99", "0"]);
16 final int BUFFERSIZE = 10; 19 final int BUFFERSIZE = 10;
17 final int STARTCHAR = 65; 20 final int STARTCHAR = 65;
18 List<int> data = new List<int>(BUFFERSIZE); 21 List<int> data = new List<int>(BUFFERSIZE);
19 for (int i = 0; (i < BUFFERSIZE - 1); i++) { 22 for (int i = 0; (i < BUFFERSIZE - 1); i++) {
20 data[i] = STARTCHAR + i; 23 data[i] = STARTCHAR + i;
21 } 24 }
22 data[BUFFERSIZE - 1] = 10; 25 data[BUFFERSIZE - 1] = 10;
23 26
24 InputStream input = process.stderr; 27 InputStream input = process.stderr;
25 OutputStream output = process.stdin; 28 OutputStream output = process.stdin;
26 29
27 process.start(); 30 process.start();
28 31
29 int received = 0; 32 int received = 0;
33 List<int> buffer = [];
30 34
31 void readData() { 35 void readData() {
32 List<int> buffer = input.read(); 36 buffer.addAll(input.read());
33 for (int i = 0; i < buffer.length; i++) { 37 for (int i = received; i < Math.min(data.length, buffer.length) - 1; i++) {
34 Expect.equals(data[received + i], buffer[i]); 38 Expect.equals(data[i], buffer[i]);
35 } 39 }
36 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 }
37 } 53 }
38 54
39 void streamClosed() { 55 void streamClosed() {
40 Expect.equals(BUFFERSIZE, received); 56 Expect.equals(BUFFERSIZE, received);
41 process.close();
42 } 57 }
43 58
44 output.write(data); 59 output.write(data);
45 output.close(); 60 output.close();
46 input.dataHandler = readData; 61 input.dataHandler = readData;
47 input.closeHandler = streamClosed; 62 input.closeHandler = streamClosed;
48 } 63 }
49 64
50 static void testMain() { 65 static void testMain() {
51 testStderr(); 66 testExit();
52 } 67 }
53 } 68 }
54 69
55 main() { 70 main() {
56 ProcessStderrTest.testStderr(); 71 ProcessStderrTest.testMain();
57 } 72 }
OLDNEW
« no previous file with comments | « tests/standalone/src/ProcessSegfaultTest.dart ('k') | tests/standalone/src/ProcessStdoutTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698