private void gatherCoverageData(final Collection<ClassInfo> tests,
final CoverageData coverage) throws IOException, InterruptedException,
ExecutionException {
final List<String> filteredTests = FCollection
.map(tests, classInfoToName());
final SideEffect1<CoverageResult> handler = resultProcessor(coverage);
final SocketFinder sf = new SocketFinder();
final ServerSocket socket = sf.getNextAvailableServerSocket();
final CoverageProcess process = new CoverageProcess(ProcessArgs
.withClassPath(this.code.getClassPath()).andBaseDir(this.workingDir)
.andLaunchOptions(this.launchOptions).andStderr(logInfo())
.andStdout(captureStandardOutIfVerbose()), this.coverageOptions,
socket, filteredTests, handler);
process.start();
final ExitCode exitCode = process.waitToDie();
if (exitCode == ExitCode.JUNIT_ISSUE) {
LOG.severe("Error generating coverage. Please check that your classpath contains JUnit 4.6 or above.");
throw new PitError(
"Coverage generation minion exited abnormally. Please check the classpath.");
} else if (!exitCode.isOk()) {
LOG.severe("Coverage generator Minion exited abnormally due to "
+ exitCode);
throw new PitError("Coverage generation minion exited abnormally!");
} else {
LOG.fine("Coverage generator Minion exited ok");
}
}