Java Code Examples for org.gradle.api.tasks.testing.TestOutputEvent#Destination

The following examples show how to use org.gradle.api.tasks.testing.TestOutputEvent#Destination . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean hasOutput(long classId, TestOutputEvent.Destination destination) {
    if (dataFile == null) {
        return false;
    }

    Index classIndex = index.children.get(classId);
    if (classIndex == null) {
        return false;
    } else {
        Region region = destination == TestOutputEvent.Destination.StdOut ? classIndex.stdOut : classIndex.stdErr;
        return region.start >= 0;
    }
}
 
Example 2
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public boolean hasOutput(long classId, TestOutputEvent.Destination destination) {
    if (dataFile == null) {
        return false;
    }

    Index classIndex = index.children.get(classId);
    if (classIndex == null) {
        return false;
    } else {
        Region region = destination == TestOutputEvent.Destination.StdOut ? classIndex.stdOut : classIndex.stdErr;
        return region.start >= 0;
    }
}
 
Example 3
Source File: JUnitXmlResultWriter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void writeOutputs(SimpleXmlWriter writer, long classId, boolean allClassOutput, TestOutputEvent.Destination destination) throws IOException {
    writer.startCDATA();
    if (allClassOutput) {
        testResultsProvider.writeAllOutput(classId, destination, writer);
    } else {
        testResultsProvider.writeNonTestOutput(classId, destination, writer);
    }
    writer.endCDATA();
}
 
Example 4
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doRead(long classId, long testId, boolean allClassOutput, TestOutputEvent.Destination destination, java.io.Writer writer) {
    if (dataFile == null) {
        return;
    }

    Index targetIndex = index.children.get(classId);
    if (targetIndex != null && testId != 0) {
        targetIndex = targetIndex.children.get(testId);
    }

    if (targetIndex == null) {
        return;
    }

    boolean stdout = destination == TestOutputEvent.Destination.StdOut;
    Region region = stdout ? targetIndex.stdOut : targetIndex.stdErr;

    if (region.start < 0) {
        return;
    }

    boolean ignoreClassLevel = !allClassOutput && testId != 0;
    boolean ignoreTestLevel = !allClassOutput && testId == 0;

    try {
        dataFile.seek(region.start);
        long maxPos = region.stop - region.start;
        KryoBackedDecoder decoder = new KryoBackedDecoder(new RandomAccessFileInputStream(dataFile));
        while (decoder.getReadPosition() <= maxPos) {
            boolean readStdout = decoder.readBoolean();
            long readClassId = decoder.readSmallLong();
            long readTestId = decoder.readSmallLong();
            int readLength = decoder.readSmallInt();

            boolean isClassLevel = readTestId == 0;

            if (stdout != readStdout || classId != readClassId) {
                decoder.skipBytes(readLength);
                continue;
            }

            if (ignoreClassLevel && isClassLevel) {
                decoder.skipBytes(readLength);
                continue;
            }

            if (ignoreTestLevel && !isClassLevel) {
                decoder.skipBytes(readLength);
                continue;
            }

            if (testId == 0 || testId == readTestId) {
                byte[] stringBytes = new byte[readLength];
                decoder.readBytes(stringBytes);
                String message;
                try {
                    message = new String(stringBytes, messageStorageCharset.name());
                } catch (UnsupportedEncodingException e) {
                    // shouldn't happen
                    throw UncheckedException.throwAsUncheckedException(e);
                }

                writer.write(message);
            } else {
                decoder.skipBytes(readLength);
            }
        }
    } catch (IOException e1) {
        throw new UncheckedIOException(e1);
    }
}
 
Example 5
Source File: BinaryResultBackedTestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public boolean hasOutput(long id, TestOutputEvent.Destination destination) {
    return outputReader.hasOutput(id, destination);
}
 
Example 6
Source File: TestOutputStore.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long classId, TestOutputEvent.Destination destination, java.io.Writer writer) {
    doRead(classId, 0, false, destination, writer);
}
 
Example 7
Source File: TestEventSerializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultTestOutputEvent read(Decoder decoder) throws Exception {
    TestOutputEvent.Destination destination = destinationSerializer.read(decoder);
    String message = decoder.readString();
    return new DefaultTestOutputEvent(destination, message);
}
 
Example 8
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, java.io.Writer writer) {
    doRead(classId, testId, false, destination, writer);
}
 
Example 9
Source File: TestEventSerializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public DefaultTestOutputEvent read(Decoder decoder) throws Exception {
    TestOutputEvent.Destination destination = destinationSerializer.read(decoder);
    String message = decoder.readString();
    return new DefaultTestOutputEvent(destination, message);
}
 
Example 10
Source File: InMemoryTestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) {
    outputReader.writeNonTestOutput(id, destination, writer);
}
 
Example 11
Source File: TestOutputStore.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long classId, TestOutputEvent.Destination destination, java.io.Writer writer) {
    doRead(classId, 0, false, destination, writer);
}
 
Example 12
Source File: InMemoryTestResultsProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public boolean hasOutput(long id, TestOutputEvent.Destination destination) {
    return outputReader.hasOutput(id, destination);
}
 
Example 13
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeTestOutput(long classId, long testId, TestOutputEvent.Destination destination, java.io.Writer writer) {
    doRead(classId, testId, false, destination, writer);
}
 
Example 14
Source File: InMemoryTestResultsProvider.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public boolean hasOutput(long id, TestOutputEvent.Destination destination) {
    return outputReader.hasOutput(id, destination);
}
 
Example 15
Source File: TestOutputStore.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeAllOutput(long classId, TestOutputEvent.Destination destination, java.io.Writer writer) {
    doRead(classId, 0, true, destination, writer);
}
 
Example 16
Source File: BinaryResultBackedTestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) {
    outputReader.writeNonTestOutput(id, destination, writer);
}
 
Example 17
Source File: AggregateTestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) {
    for (DelegateProvider delegateProvider : classOutputProviders.get(id)) {
        delegateProvider.provider.writeNonTestOutput(delegateProvider.id, destination, writer);
    }
}
 
Example 18
Source File: InMemoryTestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void writeNonTestOutput(long id, TestOutputEvent.Destination destination, Writer writer) {
    outputReader.writeNonTestOutput(id, destination, writer);
}
 
Example 19
Source File: JUnitXmlResultWriter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void writeOutputs(SimpleXmlWriter writer, long classId, long testId, TestOutputEvent.Destination destination) throws IOException {
    writer.startCDATA();
    testResultsProvider.writeTestOutput(classId, testId, destination, writer);
    writer.endCDATA();
}
 
Example 20
Source File: TestResultsProvider.java    From pushfish-android with BSD 2-Clause "Simplified" License votes vote down vote up
boolean hasOutput(long id, TestOutputEvent.Destination destination);