-
Notifications
You must be signed in to change notification settings - Fork 349
/
CoveragePipe.java
66 lines (50 loc) · 1.71 KB
/
CoveragePipe.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.pitest.coverage.execute;
import java.io.OutputStream;
import java.util.Collection;
import org.pitest.coverage.CoverageReceiver;
import org.pitest.testapi.Description;
import org.pitest.util.ExitCode;
import org.pitest.util.Id;
import org.pitest.util.SafeDataOutputStream;
import sun.pitest.CodeCoverageStore;
public class CoveragePipe implements CoverageReceiver {
private final SafeDataOutputStream dos;
public CoveragePipe(final OutputStream dos) {
this.dos = new SafeDataOutputStream(dos);
}
@Override
public synchronized void recordTestOutcome(final Description description,
final boolean wasGreen, final int executionTime) {
final Collection<Long> hits = CodeCoverageStore.getHits();
this.dos.writeByte(Id.OUTCOME);
this.dos.write(description);
this.dos.writeInt(hits.size());
for (final Long each : hits) {
this.dos.writeLong(each);
}
this.dos.writeBoolean(wasGreen);
this.dos.writeInt(executionTime);
CodeCoverageStore.reset();
}
public synchronized void end(final ExitCode exitCode) {
this.dos.writeByte(Id.DONE);
this.dos.writeInt(exitCode.getCode());
this.dos.flush();
}
@Override
public synchronized void registerClass(final int id, final String className) {
this.dos.writeByte(Id.CLAZZ);
this.dos.writeInt(id);
this.dos.writeString(className);
}
@Override
public synchronized void registerProbes(int classId, String methodName,
String methodDesc, int firstProbe, int lastProbe) {
this.dos.writeByte(Id.PROBES);
this.dos.writeInt(classId);
this.dos.writeString(methodName);
this.dos.writeString(methodDesc);
this.dos.writeInt(firstProbe);
this.dos.writeInt(lastProbe);
}
}