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

Unified 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: Handle Windows 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/src/ProcessSegfaultTest.dart ('k') | tests/standalone/src/ProcessStdoutTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/ProcessStderrTest.dart
diff --git a/tests/standalone/src/ProcessStderrTest.dart b/tests/standalone/src/ProcessStderrTest.dart
index 741eb16358bcd5229d1fe71c625b1e67b755d467..298fc59a5acd362241ac49b72864096619b3ae49 100644
--- a/tests/standalone/src/ProcessStderrTest.dart
+++ b/tests/standalone/src/ProcessStderrTest.dart
@@ -9,10 +9,12 @@
// VMOptions=--short_socket_write
// VMOptions=--short_socket_read --short_socket_write
+#source("ProcessTestUtil.dart");
+
class ProcessStderrTest {
static void testExit() {
- Process process = new Process("out/Debug_ia32/process_test",
+ Process process = new Process(getProcessTestFileName(),
const ["1", "1", "99", "0"]);
final int BUFFERSIZE = 10;
final int STARTCHAR = 65;
@@ -28,20 +30,34 @@ class ProcessStderrTest {
process.start();
int received = 0;
+ List<int> buffer = [];
+
void readData() {
- List<int> buffer = input.read();
- for (int i = 0; i < buffer.length; i++) {
- Expect.equals(data[received + i], buffer[i]);
+ buffer.addAll(input.read());
+ for (int i = received; i < Math.min(data.length, buffer.length); i++) {
Søren Gjesse 2011/11/08 08:43:38 Math.min(data.length, buffer.length) should be Mat
jrgfogh 2011/11/08 09:15:15 Done.
+ Expect.equals(data[i], buffer[i]);
}
- received += buffer.length;
- if (received == BUFFERSIZE) {
- process.close();
+ received = buffer.length;
+ if (received >= BUFFERSIZE) {
+ // We expect an extra character on windows due to carriage return.
+ if (13 === buffer[BUFFERSIZE - 1] && BUFFERSIZE + 1 == received) {
+ Expect.equals(10, buffer[BUFFERSIZE]);
+ buffer.removeLast();
+ process.close();
+ } else if (received == BUFFERSIZE) {
Søren Gjesse 2011/11/08 08:43:38 Expect 10 === buffer[BUFFERSIZE - 1] here.
jrgfogh 2011/11/08 09:15:15 Done.
+ process.close();
+ }
}
}
+ void streamClosed() {
+ Expect.equals(BUFFERSIZE, received);
+ }
+
output.write(data);
output.end();
input.dataHandler = readData;
+ input.closeHandler = streamClosed;
}
static void testMain() {
« 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