/** * New instance to combine session infos and execution data from multiple * files. */ public ExecFileLoader() { sessionInfos = new SessionInfoStore(); executionData = new ExecutionDataStore(); }
private void mergeReports(File reportOverall, File... reports) { SessionInfoStore infoStore = new SessionInfoStore(); ExecutionDataStore dataStore = new ExecutionDataStore(); loadSourceFiles(infoStore, dataStore, reports); BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall)); ExecutionDataWriter dataWriter = new ExecutionDataWriter(outputStream); infoStore.accept(dataWriter); dataStore.accept(dataWriter); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath(), e)); } finally { Closeables.closeQuietly(outputStream); } }
public List<SessionInfo> getSessionInfos() { return sessioninfostore.getInfos(); }
public void accept(IExecutionDataVisitor executionDataVisitor, ISessionInfoVisitor sessionInfoVisitor) throws CoreException { sessionInfoStore.accept(sessionInfoVisitor); executionDataStore.accept(executionDataVisitor); }
public boolean isEmpty() { return sessionInfoStore.isEmpty(); }
/** * Saves the current content into the given output stream. * * @param stream * stream to save content to * @throws IOException * in case of problems while writing to the stream */ public void save(final OutputStream stream) throws IOException { final ExecutionDataWriter dataWriter = new ExecutionDataWriter(stream); sessionInfos.accept(dataWriter); executionData.accept(dataWriter); }
public MemoryExecutionDataSource() { sessionInfoStore = new SessionInfoStore(); executionDataStore = new ExecutionDataStore(); }
private void mergeReports(File reportOverall, File... reports) { SessionInfoStore infoStore = new SessionInfoStore(); ExecutionDataStore dataStore = new ExecutionDataStore(); loadSourceFiles(infoStore, dataStore, reports); BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall)); ExecutionDataWriter dataWriter = new ExecutionDataWriter(outputStream); infoStore.accept(dataWriter); dataStore.accept(dataWriter); } catch (IOException e) { throw new SonarException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e); } finally { Closeables.closeQuietly(outputStream); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { ExecFileLoader loader = new ExecFileLoader(); for (File exec : files) { loader.load(exec); } rsp.setContentType("application/octet-stream"); final ExecutionDataWriter dataWriter = new ExecutionDataWriter(rsp.getOutputStream()); loader.getSessionInfoStore().accept(dataWriter); loader.getExecutionDataStore().accept(dataWriter); } };
/** * Writes all contained {@link SessionInfo} objects into the given visitor. * The info objects are emitted in chronological order by dump timestamp. * * @param visitor * visitor to emit {@link SessionInfo} objects to */ public void accept(final ISessionInfoVisitor visitor) { for (final SessionInfo i : getInfos()) { visitor.visitSessionInfo(i); } }
private void loadExecutionData() throws IOException { executionDataStore = new ExecutionDataStore(); sessionInfoStore = new SessionInfoStore(); for (FilePath filePath : execFiles) { File executionDataFile = new File(filePath.getRemote()); try { try (final InputStream inputStream = new BufferedInputStream( new FileInputStream(executionDataFile))) { final ExecutionDataReader reader = new ExecutionDataReader(inputStream); reader.setSessionInfoVisitor(sessionInfoStore); reader.setExecutionDataVisitor(executionDataStore); reader.read(); } } catch (final IOException e) { throw new IOException("While reading execution data-file: " + executionDataFile, e); } } } private IBundleCoverage analyzeStructure() throws IOException {
private void mergeReports(File reportOverall, File... reports) { SessionInfoStore infoStore = new SessionInfoStore(); ExecutionDataStore dataStore = new ExecutionDataStore(); loadSourceFiles(infoStore, dataStore, reports); BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall)); ExecutionDataWriter dataWriter = new ExecutionDataWriter(outputStream); infoStore.accept(dataWriter); dataStore.accept(dataWriter); } catch (IOException e) { throw new SonarException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e); } finally { Closeables.closeQuietly(outputStream); } }
private void writeReports(final IBundleCoverage bundle, final ExecFileLoader loader, final PrintWriter out) throws IOException { out.printf("[INFO] Analyzing %s classes.%n", Integer.valueOf(bundle.getClassCounter().getTotalCount())); final IReportVisitor visitor = createReportVisitor(); visitor.visitInfo(loader.getSessionInfoStore().getInfos(), loader.getExecutionDataStore().getContents()); visitor.visitBundle(bundle, getSourceLocator()); visitor.visitEnd(); }
private void loadExecutionData() throws IOException { File executionDataFile = new File(execFile.getRemote()); final FileInputStream fis = new FileInputStream(executionDataFile); final ExecutionDataReader executionDataReader = new ExecutionDataReader( fis); executionDataStore = new ExecutionDataStore(); sessionInfoStore = new SessionInfoStore(); executionDataReader.setExecutionDataVisitor(executionDataStore); executionDataReader.setSessionInfoVisitor(sessionInfoStore); while (executionDataReader.read()) { } fis.close(); } private IBundleCoverage analyzeStructure() throws IOException {
/** * Merge all reports in reportOverall. * @param reportOverall destination file of merge. * @param reports files to be merged. */ public static void mergeReports(File reportOverall, File... reports) { SessionInfoStore infoStore = new SessionInfoStore(); ExecutionDataStore dataStore = new ExecutionDataStore(); boolean isCurrentVersionFormat = loadSourceFiles(infoStore, dataStore, reports); try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall))) { Object visitor; if (isCurrentVersionFormat) { visitor = new ExecutionDataWriter(outputStream); } else { visitor = new org.jacoco.previous.core.data.ExecutionDataWriter(outputStream); } infoStore.accept((ISessionInfoVisitor) visitor); dataStore.accept((IExecutionDataVisitor) visitor); } catch (IOException e) { throw new IllegalStateException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e); } }
visitor.visitInfo(sessionInfoStore.getInfos(), executionDataStore.getContents());
public void storeCoverageData(@Observes CoverageDataCommand coverageDataCommandEvent) { try { ExecutionDataStore dataStore = new ExecutionDataStore(); SessionInfoStore sessionStore = new SessionInfoStore(); read(new ByteArrayInputStream(coverageDataCommandEvent.getCoverageDate()), dataStore, sessionStore); copyToAgentExecutionStore(dataStore); coverageDataCommandEvent.setResult("SUCCESS"); } catch (Exception e) { coverageDataCommandEvent.setResult("FAILURE"); e.printStackTrace(); } }
public void storeCoverageData(@Observes CoverageDataCommand coverageDataCommandEvent) { try { ExecutionDataStore dataStore = new ExecutionDataStore(); SessionInfoStore sessionStore = new SessionInfoStore(); read(new ByteArrayInputStream(coverageDataCommandEvent.getCoverageDate()), dataStore, sessionStore); copyToAgentExecutionStore(dataStore); coverageDataCommandEvent.setResult("SUCCESS"); } catch (Exception e) { coverageDataCommandEvent.setResult("FAILURE"); e.printStackTrace(); } }
final RuntimeData data = new RuntimeData(); final ExecutionDataStore executionData = new ExecutionDataStore(); final SessionInfoStore sessionInfos = new SessionInfoStore(); URLClassLoader classLoader; try {
final RuntimeData data = new RuntimeData(); final ExecutionDataStore executionData = new ExecutionDataStore(); final SessionInfoStore sessionInfos = new SessionInfoStore(); URLClassLoader classLoader; try {