Skip to content

Commit

Permalink
Merge pull request #1245 from hcoles/bug/misleading_incremental_analy…
Browse files Browse the repository at this point in the history
…sis_log

prevent logging of incremental analysis during dummy first scan
  • Loading branch information
hcoles committed Aug 9, 2023
2 parents 10bb6c1 + 97a21eb commit 8244aed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ public class IncrementalAnalyser implements MutationAnalyser {
private final CoverageDatabase coverage;
private final Map<DetectionStatus, Long> preAnalysed = new EnumMap<>(DetectionStatus.class);

public IncrementalAnalyser(final CodeHistory history,
final CoverageDatabase coverage) {
private final boolean enableLog;

public IncrementalAnalyser(CodeHistory history, CoverageDatabase coverage) {
this(history, coverage, true);
}

public IncrementalAnalyser(CodeHistory history, CoverageDatabase coverage, boolean enableLog) {
this.history = history;
this.coverage = coverage;
this.enableLog = enableLog;
}

@Override
Expand All @@ -52,7 +58,9 @@ public Collection<MutationResult> analyse(
}
}

logTotals();
if (enableLog) {
logTotals();
}

return mrs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,9 @@ private List<MutationAnalysisUnit> buildMutationTests(CoverageDatabase coverageD

final MutationSource source = new MutationSource(mutationConfig, testPrioritiser, bas, interceptor);

final MutationAnalyser analyser = new IncrementalAnalyser(
new DefaultCodeHistory(this.code, history), coverageData);
final MutationAnalyser analyser = new IncrementalAnalyser(new DefaultCodeHistory(this.code, history),
coverageData,
enableIncrementalAnalysisLogging(history));

final WorkerFactory wf = new WorkerFactory(this.baseDir, coverage()
.getConfiguration(), mutationConfig, args,
Expand All @@ -394,6 +395,13 @@ private List<MutationAnalysisUnit> buildMutationTests(CoverageDatabase coverageD
return builder.createMutationTestUnits(this.code.getCodeUnderTestNames());
}

private boolean enableIncrementalAnalysisLogging(HistoryStore history) {
// Horrible hack to prevent logging during pre scan phase. This would
// cause confusion as if only part of the log is read it appears that
// incremental analysis has affected no mutants
return !(history instanceof NullHistoryStore);
}

private void checkMutationsFound(final List<MutationAnalysisUnit> tus) {
if (tus.isEmpty()) {
if (this.data.shouldFailWhenNoMutations()) {
Expand Down

0 comments on commit 8244aed

Please sign in to comment.