Skip to content

Commit

Permalink
review up
Browse files Browse the repository at this point in the history
  • Loading branch information
brig committed Dec 3, 2024
1 parent 0cf9242 commit c6f75ec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ private void generateReport(Runtime runtime) {

try {
var reportProducer = new LcovReportProducer(runtime.getService(ProcessDefinition.class));
reportProducer.onSteps(steps.list());

steps.stream().forEach(reportProducer::onStep);
steps.cleanup();

persistenceService.persistFile(COVERAGE_INFO_FILENAME, reportProducer::produce, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public class CodecoverageModule implements Module {
@Override
public void configure (Binder binder){
var executionListeners = Multibinder.newSetBinder(binder, ExecutionListener.class);
taskProviders.addBinding().to(CodeCoverage.class);
executionListeners.addBinding().to(CodeCoverage.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LcovReportProducer {
Expand All @@ -41,6 +42,10 @@ public LcovReportProducer(ProcessDefinition processDefinition) {
init(processDefinition);
}

public void onSteps(List<StepInfo> steps) {
steps.forEach(this::onStep);
}

public void onStep(StepInfo step) {
var fileName = step.fileName();

Expand Down Expand Up @@ -70,6 +75,7 @@ public void onStep(StepInfo step) {
}
}


public void produce(OutputStream out) throws IOException {
try (var writer = new BufferedWriter(new OutputStreamWriter(out))) {
for (var statsEntry : statsPerFile.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public synchronized void record(StepInfo step) {
StandardOpenOption.CREATE, StandardOpenOption.APPEND);
}

public synchronized Stream<StepInfo> stream() {
public List<StepInfo> list() {
var result = persistenceService.loadPersistedFile(FILE_NAME, in -> objectMapper.readValue(in, STEPS_TYPE));
if (result == null) {
return Stream.empty();
return List.of();
}
return result.stream();
return result;
}

public synchronized void cleanup() {
Expand Down

0 comments on commit c6f75ec

Please sign in to comment.