use special symbols for delimiters (better distinguish between users output and our control sequences)

This commit is contained in:
anna
2011-07-15 10:53:39 +04:00
parent 3786a0bfa5
commit 6eb944e693
2 changed files with 14 additions and 11 deletions
@@ -21,7 +21,7 @@ package com.intellij.rt.execution.junit.segments;
public interface SegmentedStream {
char SPECIAL_SYMBOL = '/';
String SPECIAL_SYMBOL_STRING = String.valueOf(SPECIAL_SYMBOL);
String MARKER_PREFIX = SPECIAL_SYMBOL_STRING + "M";
String MARKER_PREFIX = SPECIAL_SYMBOL_STRING + '\u0001';
String LENGTH_DELIMITER = " ";
String STARTUP_MESSAGE = "@#IJIDEA#JUnitSupport#@";
}
@@ -23,6 +23,9 @@ import java.io.*;
*/
class ForkedVMWrapper extends DataOutputStream {
public static final char DELIMITER = '\u0002';
public static final byte[] ERROR = new byte[] {'\u0003'};
public static final byte[] OUTPUT = new byte[] {'\u0004'};
private FileOutputStream myOutputStream;
private boolean myError;
@@ -38,12 +41,12 @@ class ForkedVMWrapper extends DataOutputStream {
}
private void printPrefix() throws IOException {
myOutputStream.write("/K".getBytes());
myOutputStream.write(("/" + DELIMITER).getBytes());
if (myError) {
myOutputStream.write("e".getBytes());
myOutputStream.write(ERROR);
}
else {
myOutputStream.write("o".getBytes());
myOutputStream.write(OUTPUT);
}
}
@@ -70,7 +73,7 @@ class ForkedVMWrapper extends DataOutputStream {
try {
boolean error = false;
boolean afterSymbol = false;
boolean afterM = false;
boolean afterDelimiter = false;
while (stream.available() > 0) {
char read = (char)stream.read();
if (read == '/') {
@@ -78,13 +81,13 @@ class ForkedVMWrapper extends DataOutputStream {
continue;
}
if (afterSymbol) {
if (afterM) {
error = read == 'e';
if (afterDelimiter) {
error = read == ERROR[0];
afterSymbol = false;
afterM = false;
afterDelimiter = false;
continue;
}
if (read != 'K') {
if (read != DELIMITER) {
if (error) {
err.write("/".getBytes());
err.write(read);
@@ -94,11 +97,11 @@ class ForkedVMWrapper extends DataOutputStream {
out.write(read);
}
afterSymbol = false;
afterM = false;
afterDelimiter = false;
continue;
}
else {
afterM = true;
afterDelimiter = true;
continue;
}
}